Skip to content

Commit

Permalink
feat: handle export of circle-heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
MAudelGisaia committed Jan 30, 2024
1 parent 55e9dc3 commit bfcb3e7
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 4 deletions.
59 changes: 57 additions & 2 deletions src/app/services/main-form-manager/config-map-export-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ import {
Layer,
Layout,
MapConfig,
Paint,
Paint, PaintValue,
SELECT_LAYER_PREFIX
} from './models-map-config';
import {InterpolatedProperty, ModesValues} from '@shared/interfaces/config-map.interfaces';
import {circleHeatMapRadiusGranularity} from '@shared-models/circle-heat-map-radius-granularity';
export enum VISIBILITY {
visible = 'visible',
none = 'none'
}

export const NORMALIZED = 'normalized';
export class ConfigMapExportHelper {

Expand Down Expand Up @@ -282,9 +285,11 @@ export class ConfigMapExportHelper {
break;
}
case GEOMETRY_TYPE.circleHeat: {

paint['circle-opacity'] = opacity;
paint['circle-color'] = color;
paint['circle-radius'] = this.getMapProperty(modeValues.styleStep.radiusFg, mode, colorService, taggableFields);
paint['circle-radius'] = this.getRadPropFromGranularity(modeValues as ModesValues);
paint['circle-blur'] = 1;
break;
}
}
Expand All @@ -310,6 +315,10 @@ export class ConfigMapExportHelper {
layout['symbol-placement'] = modeValues.styleStep.labelPlacementCtrl;
break;
}
case GEOMETRY_TYPE.circleHeat: {
layout['circle-sort-key'] = this.getCircleHeatMapSortKey(modeValues.styleStep.colorFg);
break;
}
}
return layout;
}
Expand Down Expand Up @@ -490,6 +499,51 @@ export class ConfigMapExportHelper {
}
}

/**
* Methode used to construct the key props
*/
public static getCircleHeatMapSortKey(fgValues: any): PaintValue {
switch (fgValues.propertySource) {
case PROPERTY_SELECTOR_SOURCE.fix_color:
return 1;
case PROPERTY_SELECTOR_SOURCE.interpolated:
const interpolatedValues = fgValues.propertyInterpolatedFg as InterpolatedProperty;
const minValue = interpolatedValues.propertyInterpolatedValuesCtrl[0].proportion;
const maxValue = interpolatedValues
.propertyInterpolatedValuesCtrl[interpolatedValues.propertyInterpolatedValuesCtrl.length - 1]
.proportion;
return [
'interpolate',
[
'linear'
],
[
'get',
'count_:normalized'
],
minValue, 0,
maxValue, 8
];
}
}

/**
* set default Radius according to granularity. WARNING : only for circle-heatMap
*/
public static getRadPropFromGranularity(modeValues: ModesValues): PaintValue {
const granularity = modeValues.geometryStep.granularity?.toLowerCase();
const radiusSteps = circleHeatMapRadiusGranularity[granularity] || [];
return [
'interpolate',
[
'linear'
],
['zoom'],
...radiusSteps
];
}


public static getFieldPath(field: string, taggableFields: Set<string>): string {
return (taggableFields && taggableFields.has(field)) ? field + '.0' : field;
}
Expand Down Expand Up @@ -563,4 +617,5 @@ export class ConfigMapExportHelper {
return value as number + nbPixel;
}
}

}
4 changes: 3 additions & 1 deletion src/app/services/main-form-manager/models-map-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export interface Layout {
'text-allow-overlap'?: boolean;
'text-anchor'?: string;
'symbol-placement'?: string;
'circle-sort-key'?: PaintValue;
}

type PaintValue = Array<string | Array<string> | number> | PaintColor | string | number;
export type PaintValue = Array<string | Array<string> | number> | PaintColor | string | number;
export interface Paint {
'fill-color'?: PaintValue;
'fill-opacity'?: number;
Expand All @@ -69,6 +70,7 @@ export interface Paint {
'line-width'?: PaintValue;
'line-dasharray'?: PaintValue;
'circle-radius'?: PaintValue;
'circle-blur'?: number;
'circle-stroke-width'?: PaintValue;
'heatmap-color'?: PaintValue;
'heatmap-radius'?: PaintValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export class ConfigFormGroupComponent implements OnInit, OnDestroy {
* depend on a displayed field, this was not managed.
*/
if (!this.isSubGroup) {
console.error(this.configFormGroup);
ConfigFormGroupComponent.listenToAllControlsOnDependencyChange(this.configFormGroup, this.toUnsubscribe);
this.initDependentControls();
this.markChildControls();
Expand Down
67 changes: 67 additions & 0 deletions src/app/shared/interfaces/config-map.interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
interface InterpolatedValue {
proportion: number;
}

export interface InterpolatedValueNumber extends InterpolatedValue {
value: number;
}

export interface InterpolatedValueString extends InterpolatedValue {
value: string;
}

export interface Propriety {
propertySource: string;
propertyFixColor?: string;
propertyFixSlider?: string;
}

export interface InterpolatedProperty {
propertyInterpolatedCountOrMetricCtrl?: string;
propertyInterpolatedCountNormalizeCtrl?: boolean;
propertyInterpolatedValuesCtrl?: interpolatedValues[];
propertyInterpolatedMinValueCtrl?: number;
propertyInterpolatedMaxValueCtrl?: number;
propertyInterpolatedValuesButton?: string;
propertyInterpolatedValuesPreview?: interpolatedValues[];
}

export interface VisibilityStep {
visible: boolean;
zoomMin: number;
zoomMax: number;
featuresMin: number;
}

export interface GeometryStep {
aggGeometry: string;
aggType: string;
granularity: string;
clusterGeometryType: string;
aggregatedGeometry: string;
}

export interface StylesStep {
geometryType: string;
filter?: [];
opacity?: {
propertySource: string;
propertyInterpolatedFg?: InterpolatedProperty | any;
};
colorFg?: {
propertySource: string;
propertyInterpolatedFg?: InterpolatedProperty | any;
};
radiusFg?: Propriety;
strokeColorFg?: Propriety;
strokeWidthFg?: Propriety;
strokeOpacityFg?: Propriety;
}

type interpolatedValues = InterpolatedValueString | InterpolatedValueNumber;

export interface ModesValues {
geometryStep: GeometryStep | any;
styleStep: StylesStep | any;
visibilityStep: VisibilityStep;
}
60 changes: 60 additions & 0 deletions src/app/shared/models/circle-heat-map-radius-granularity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export const circleHeatMapRadiusGranularity = {
'finest': [
0, 9,
2.9999999999999, 25,
3, 9,
4.9999999999999, 12,
5, 4,
7.9999999999999, 20,
8, 10,
10.9999999999999, 25,
11, 60,
13.9999999999999, 200,
14, 200,
16.9999999999999, 1000,
17, 1000,
19.9999999999999, 1500,
20, 2000
],
'fine': [
0, 10,
1.999, 30,
4.999999, 90,
5, 30,
7.999999, 120,
8, 40,
10.499999, 180,
10.5, 30,
13.999999, 210,
14, 300,
16.999999, 1000,
17, 2000
],
'medium': [
0, 50,
2.999999, 110,
3, 30,
5.999999, 180,
6, 40,
8.999999, 200,
9, 50,
11.999999, 360,
12, 70,
14.999999, 460,
15, 600,
17, 2000
],
'coarse': [
0, 30,
3.999999, 250,
4, 50,
6.999999, 320,
7, 120,
9.999999, 480,
10, 120,
12.999999, 580,
13, 160,
14, 600,
17, 1000
],
};

0 comments on commit bfcb3e7

Please sign in to comment.