Skip to content

Commit

Permalink
override default value inside temporal dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurmarakana89 committed Feb 22, 2024
1 parent eebf65b commit 9f727a4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1505,17 +1505,21 @@ export abstract class AbstractGeoViewLayer {
* @param {string} layerPath The layer path to the layer's configuration affected by the change.
* @param {TimeDimension} temporalDimension The value to assign to the layer temporal dimension property.
*/
setTemporalDimension(layerPath: string, temporalDimension: TimeDimension): void {
setTemporalDimension(layerPath: string, temporalDimension: TimeDimension, override: boolean): void {
layerPath = layerPath || this.layerPathAssociatedToTheGeoviewLayer;
const timeDimension: TimeDimension = {
field: temporalDimension.field,
default: temporalDimension.default,
unitSymbol: temporalDimension.unitSymbol,
nearestValues: temporalDimension.nearestValues,
range: api.dateUtilities.createRangeOGC(temporalDimension.range as unknown as string),
singleHandle: temporalDimension.singleHandle,
};
this.layerTemporalDimension[layerPath] = timeDimension;
if (override) {
const timeDimension: TimeDimension = {
field: temporalDimension.field,
default: temporalDimension.default,
unitSymbol: temporalDimension.unitSymbol,
nearestValues: temporalDimension.nearestValues,
range: api.dateUtilities.createRangeOGC(temporalDimension.range as unknown as string),
singleHandle: temporalDimension.singleHandle,
};
this.layerTemporalDimension[layerPath] = timeDimension;
} else {
this.layerTemporalDimension[layerPath] = temporalDimension;
}
}

/** ***************************************************************************************************************************
Expand Down
21 changes: 18 additions & 3 deletions packages/geoview-time-slider/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,24 @@ class TimeSliderPlugin extends FooterPlugin {
// Set custom time dimension if applicable
this.configObj.sliders.forEach((obj: SliderProps) => {
if (obj.temporalDimension) {
api.maps[this.pluginProps.mapId].layer
.geoviewLayer(obj.layerPaths[0])
.setTemporalDimension(obj.layerPaths[0], obj.temporalDimension);
api.maps[this.pluginProps.mapId].layer.geoviewLayer(obj.layerPaths[0]).setTemporalDimension(obj.layerPaths[0], {
...obj.temporalDimension,
},
true
);
}
// Set override default value under time dimension if applicable
if (obj.defaultValue) {
const layerPath = obj.layerPaths[0];
const timeDimension = api.maps[this.pluginProps.mapId].layer.geoviewLayer(layerPath).layerTemporalDimension[layerPath];
api.maps[this.pluginProps.mapId].layer.geoviewLayer(layerPath).setTemporalDimension(
layerPath,
{
...timeDimension,
default: obj.defaultValue,
},
false
);
}
});

Expand Down

0 comments on commit 9f727a4

Please sign in to comment.