diff --git a/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json b/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json index 529d2bd5a12..b944db591bb 100644 --- a/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json +++ b/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json @@ -16,37 +16,7 @@ "field": "datetime", "default": ["1940-01-01T05:00:00Z", "1980-01-01T05:00:00Z"], "unitSymbol": "", - "range": { - "type": "absolute", - "range": [ - "1900-01-01T05:00:00Z", - "1904-01-01T05:00:00Z", - "1908-01-01T05:00:00Z", - "1912-01-01T05:00:00Z", - "1916-01-01T05:00:00Z", - "1920-01-01T05:00:00Z", - "1924-01-01T05:00:00Z", - "1928-01-01T05:00:00Z", - "1932-01-01T05:00:00Z", - "1936-01-01T05:00:00Z", - "1940-01-01T05:00:00Z", - "1944-01-01T05:00:00Z", - "1948-01-01T05:00:00Z", - "1952-01-01T05:00:00Z", - "1956-01-01T05:00:00Z", - "1960-01-01T05:00:00Z", - "1964-01-01T05:00:00Z", - "1968-01-01T05:00:00Z", - "1972-01-01T05:00:00Z", - "1976-01-01T05:00:00Z", - "1980-01-01T05:00:00Z", - "1984-01-01T05:00:00Z", - "1988-01-01T05:00:00Z", - "1992-01-01T05:00:00Z", - "1996-01-01T05:00:00Z", - "2000-01-01T05:00:00Z" - ] - }, + "range": "1900-01-01T05:00:00Z/2000-01-01T05:00:00Z/P1Y", "nearestValues": "absolute", "singleHandle": false } diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts index 09550af7c3c..290a991e62e 100644 --- a/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts +++ b/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts @@ -121,7 +121,13 @@ export class TimeSliderEventProcessor extends AbstractEventProcessor { const fieldIndex = localizedOutFields ? localizedOutFields.indexOf(field) : -1; if (fieldIndex !== -1 && localizedAliasFields?.length === localizedOutFields?.length) fieldAlias = localizedAliasFields![fieldIndex]; - const values = singleHandle ? [new Date(temporalDimensionInfo.default).getTime()] : [...minAndMax]; + // eslint-disable-next-line no-nested-ternary + const values = singleHandle + ? [new Date(temporalDimensionInfo.default).getTime()] + : defaultValue + ? [new Date(defaultValue[0]).getTime(), new Date(defaultValue[1]).getTime()] + : [...minAndMax]; + const sliderData: TimeSliderLayerSet = { [layerPath]: { name, diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts index b3b1623cb7a..30627f54db6 100644 --- a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts +++ b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts @@ -1506,8 +1506,16 @@ export abstract class AbstractGeoViewLayer { * @param {string} layerPath The layer path to the layer's configuration affected by the change. * @param {TimeDimension} timeDimension The value to assign to the layer temporal dimension property. */ - setTemporalDimension(layerPath: string, timeDimension: TimeDimension): void { + setTemporalDimension(layerPath: string, temporalDimension: TimeDimension): 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; } diff --git a/packages/geoview-time-slider/src/time-slider.tsx b/packages/geoview-time-slider/src/time-slider.tsx index 5d412dc149c..f31ccbe5b7f 100644 --- a/packages/geoview-time-slider/src/time-slider.tsx +++ b/packages/geoview-time-slider/src/time-slider.tsx @@ -51,8 +51,7 @@ export function TimeSlider(TimeSliderPanelProps: TimeSliderPanelProps) { // Get actions and states from store // TODO: evaluate best option to set value by layer path.... trough a getter? - const { setTitle, setDescription, setValues, setLocked, setReversed, setDelay, setFiltering } = - useTimeSliderStoreActions(); + const { setTitle, setDescription, setValues, setLocked, setReversed, setDelay, setFiltering } = useTimeSliderStoreActions(); // TODO: check performance as we should technically have one selector by constant const { @@ -330,7 +329,6 @@ export function TimeSlider(TimeSliderPanelProps: TimeSliderPanelProps) { style={{ width: '80%', color: 'primary' }} min={minAndMax[0]} max={minAndMax[1]} - defaultValue={defaultValue} value={values} valueLabelFormat={(value) => valueLabelFormat(value)} marks={sliderMarks}