Skip to content

Commit

Permalink
[Feat] use fixed height in geojson layer (#2533)
Browse files Browse the repository at this point in the history
- Added a toggle to render absolute height without domain-based scaling.

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta authored Mar 7, 2024
1 parent 400120f commit 4932e76
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ export default function LayerConfiguratorFactory(
{...layerChannelConfigProps}
/>
<VisConfigSwitch
{...layer.visConfigSettings.enableElevationZoomFactor}
{...layer.visConfigSettings.fixedHeight}
{...visConfiguratorProps}
/>
<VisConfigSwitch {...visConfiguratorProps} {...layer.visConfigSettings.wireframe} />
Expand Down
8 changes: 8 additions & 0 deletions src/constants/src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ export const LAYER_VIS_CONFIGS: LayerVisConfigSettings = {
group: PROPERTY_GROUPS.radius,
property: 'fixedRadius'
},
fixedHeight: {
defaultValue: false,
type: 'boolean',
label: 'layerVisConfigs.fixedHeight',
description: 'layerVisConfigs.fixedHeightDescription',
group: PROPERTY_GROUPS.height,
property: 'fixedHeight'
},
radiusRange: {
type: 'number',
defaultValue: [0, 50],
Expand Down
15 changes: 10 additions & 5 deletions src/layers/src/geojson-layer/geojson-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export const geojsonVisConfigs: {
radiusRange: 'radiusRange';
heightRange: 'elevationRange';
elevationScale: 'elevationScale';
enableElevationZoomFactor: 'enableElevationZoomFactor';
stroked: 'stroked';
filled: 'filled';
enable3d: 'enable3d';
wireframe: 'wireframe';
fixedHeight: 'fixedHeight';
} = {
opacity: 'opacity',
strokeOpacity: {
Expand All @@ -90,11 +90,11 @@ export const geojsonVisConfigs: {
radiusRange: 'radiusRange',
heightRange: 'elevationRange',
elevationScale: 'elevationScale',
enableElevationZoomFactor: 'enableElevationZoomFactor',
stroked: 'stroked',
filled: 'filled',
enable3d: 'enable3d',
wireframe: 'wireframe'
wireframe: 'wireframe',
fixedHeight: 'fixedHeight'
};

export type GeoJsonVisConfigSettings = {
Expand All @@ -110,7 +110,7 @@ export type GeoJsonVisConfigSettings = {
radiusRange: VisConfigRange;
heightRange: VisConfigRange;
elevationScale: VisConfigNumber;
enableElevationZoomFactor: VisConfigBoolean;
fixedHeight: VisConfigBoolean;
stroked: VisConfigBoolean;
filled: VisConfigBoolean;
enable3d: VisConfigBoolean;
Expand All @@ -134,11 +134,11 @@ export type GeoJsonLayerVisConfig = {
radiusRange: [number, number];
heightRange: [number, number];
elevationScale: number;
enableElevationZoomFactor: boolean;
stroked: boolean;
filled: boolean;
enable3d: boolean;
wireframe: boolean;
fixedHeight: boolean;
};

type GeoJsonLayerVisualChannelConfig = LayerColorConfig &
Expand Down Expand Up @@ -266,6 +266,7 @@ export default class GeoJsonLayer extends Layer {
domain: 'heightDomain',
range: 'heightRange',
key: 'height',
fixed: 'fixedHeight',
channelScaleType: CHANNEL_SCALES.size,
accessor: 'getElevation',
condition: config => config.visConfig.enable3d,
Expand Down Expand Up @@ -496,6 +497,10 @@ export default class GeoJsonLayer extends Layer {
: super.hasHoveredObject(objectInfo);
}

getElevationZoomFactor({zoom, zoomOffset = 0}) {
return this.config.visConfig.fixedHeight ? 1 : Math.pow(2, Math.max(8 - zoom + zoomOffset, 0));
}

renderLayer(opts) {
const {data: dataProps, gpuFilter, objectHovered, mapState, interactionConfig} = opts;

Expand Down
4 changes: 3 additions & 1 deletion src/localization/src/translations/ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ export default {
weightIntensity: 'Intensitat de pes',
zoomScale: 'Escala de zoom',
heightRange: 'Rang alçada',
heightMultiplier: "Multiplicador d'alçada"
heightMultiplier: "Multiplicador d'alçada",
fixedHeight: 'Alçada fixa',
fixedHeightDescription: "Utilitzeu l'alçada sense modificacions"
},
layerManager: {
addData: 'Afegeix Dades',
Expand Down
2 changes: 2 additions & 0 deletions src/localization/src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ export default {
weightIntensity: 'Weight Intensity',
zoomScale: 'Zoom Scale',
heightRange: 'Height Range',
fixedHeight: 'Fixed height',
fixedHeightDescription: 'Use height without modifications',
heightMultiplier: 'Height Multiplier',
darkModeEnabled: 'Dark base map'
},
Expand Down
2 changes: 2 additions & 0 deletions src/localization/src/translations/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export default {
weightIntensity: 'Intensidad de peso',
zoomScale: 'Escala de zoom',
heightRange: 'Rango de alturas',
fixedHeight: 'Altura fija',
fixedHeightDescription: 'Usar altura sin modificaciones',
heightMultiplier: 'Multiplicador de altura'
},
layerManager: {
Expand Down
2 changes: 2 additions & 0 deletions src/localization/src/translations/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export default {
weightIntensity: 'Painotuksen intensiteetti',
zoomScale: 'Zoomausskaala',
heightRange: 'Korkeuden rajat',
fixedHeight: 'Kiinteä korkeus',
fixedHeightDescription: 'Käytä korkeutta ilman muutoksia',
heightMultiplier: 'Korkeuskerroin'
},
layerManager: {
Expand Down
2 changes: 2 additions & 0 deletions src/localization/src/translations/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export default {
weightIntensity: '重みづけの強さ',
zoomScale: 'ズームのスケール',
heightRange: '高さの範囲',
fixedHeight: '固定高さ',
fixedHeightDescription: '高さを変更せずに使用する',
heightMultiplier: '高さ乗数'
},
layerManager: {
Expand Down
2 changes: 2 additions & 0 deletions src/localization/src/translations/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export default {
weightIntensity: 'Intensidade da Espessura',
zoomScale: 'Escala do Zoom',
heightRange: 'Alcance da Altura',
fixedHeight: 'Altura fixa',
fixedHeightDescription: 'Use a altura sem modificações',
heightMultiplier: 'Multiplicador de altura'
},
layerManager: {
Expand Down
1 change: 1 addition & 0 deletions src/types/layers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export type LayerVisConfigSettings = {
weight: VisConfigNumber;
heatmapRadius: VisConfigNumber;
darkBaseMapEnabled: VisConfigBoolean;
fixedHeight: VisConfigBoolean;
};

// TODO: Move this to individual layers
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/state-saved-v0.js
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ mergedLayer4.config = {
radiusRange: [0, 50],
heightRange: [0, 500],
elevationScale: 5,
enableElevationZoomFactor: true,
fixedHeight: false,
stroked: false,
filled: true,
enable3d: false,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/state-saved-v1-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ mergedLayer0.config = {
radiusRange: [0, 50],
heightRange: [0, 500],
elevationScale: 18,
enableElevationZoomFactor: true,
fixedHeight: false,
stroked: true,
filled: true,
strokeColor: [181, 18, 65],
Expand Down Expand Up @@ -2740,7 +2740,7 @@ mergedLayer1.config = {
radiusRange: [0, 50],
heightRange: [0, 500],
elevationScale: 5,
enableElevationZoomFactor: true,
fixedHeight: false,
stroked: true,
filled: false,
enable3d: false,
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/mock-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ export const expectedSavedLayer2 = {
radiusRange: [0, 50],
heightRange: [0, 500],
elevationScale: 5,
enableElevationZoomFactor: true,
fixedHeight: false,
stroked: true,
filled: true,
enable3d: false,
Expand Down Expand Up @@ -866,7 +866,7 @@ export const expectedLoadedLayer2 = {
radiusRange: [0, 50],
heightRange: [0, 500],
elevationScale: 5,
enableElevationZoomFactor: true,
fixedHeight: false,
stroked: true,
filled: true,
enable3d: false,
Expand Down

0 comments on commit 4932e76

Please sign in to comment.