Skip to content

Commit

Permalink
add time dimension config in custom config json
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurmarakana89 committed Feb 16, 2024
1 parent b401431 commit acb81a5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
"defaultValue": "",
"temporalDimension": {
"field": "datetime",
"default": "1696-01-01T05:00:00Z",
"default": ["1950-01-01T05:00:00Z", "1970-01-01T05:00:00Z"],
"unitSymbol": "",
"range": [
"1696-01-01T05:00:00Z",
"1704-01-01T05:00:00Z",
"1712-01-01T05:00:00Z",
"1720-01-01T05:00:00Z",
"1728-01-01T05:00:00Z",
"1736-01-01T05:00:00Z",
"1744-01-01T05:00:00Z",
"1752-01-01T05:00:00Z",
"1760-01-01T05:00:00Z",
"1768-01-01T05:00:00Z",
"1776-01-01T05:00:00Z",
"1784-01-01T05:00:00Z",
"1792-01-01T05:00:00Z",
"1800-01-01T05:00:00Z",
"1808-01-01T05:00:00Z",
"1816-01-01T05:00:00Z",
"1824-01-01T05:00:00Z",
"1832-01-01T05:00:00Z",
"1900-01-01T05:00:00Z",
"1905-01-01T05:00:00Z",
"1910-01-01T05:00:00Z",
"1915-01-01T05:00:00Z",
"1920-01-01T05:00:00Z",
"1930-01-01T05:00:00Z",
"1940-01-01T05:00:00Z",
"1945-01-01T05:00:00Z",
"1950-01-01T05:00:00Z",
"1955-01-01T05:00:00Z",
"1960-01-01T05:00:00Z",
"1965-01-01T05:00:00Z",
"1970-01-01T05:00:00Z",
"1975-01-01T05:00:00Z",
"1980-01-01T05:00:00Z",
"1985-01-01T05:00:00Z",
"1990-01-01T05:00:00Z",
"1995-01-01T05:00:00Z",
"1840-01-01T05:00:00Z",
"1848-01-01T05:00:00Z",
"1856-01-01T05:00:00Z",
Expand All @@ -58,9 +58,9 @@
"1992-01-01T04:47:32Z",
"2000-01-01T04:47:32Z",
"2008-01-01T04:47:32Z",
"2016-01-01T04:47:32Z"
"2000-01-01T04:47:32Z"
],
"nearestValues": "discrete",
"nearestValues": "absolute",
"singleHandle": true
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ export type TimeSliderLayerSet = {
[layerPath: string]: TypeTimeSliderValues;
};

export type TemporalDimensionProps = {
field: string;
default: string;
unitSymbol: string;
range: string[];
nearestValues: string;
singleHandle: boolean;
};

// #region INTERFACES
export interface TypeTimeSliderValues {
title?: string;
Expand All @@ -35,7 +26,6 @@ export interface TypeTimeSliderValues {
reversed?: boolean;
nearestValues?: string;
unitSymbol?: string;
temporalDimension?: TemporalDimensionProps | null;
}

export interface ITimeSliderState {
Expand All @@ -54,7 +44,6 @@ export interface ITimeSliderState {
setDefaultValue: (layerPath: string, defaultValue: string) => void;
setValues: (layerPath: string, values: number[]) => void;
setVisibleTimeSliderLayers: (visibleLayerPaths: string[]) => void;
setTemporalDimension: (layerPath: string, temporalDimension: TemporalDimensionProps | null) => void;
};
}
// #endregion INTERFACES
Expand Down Expand Up @@ -171,34 +160,6 @@ export function initializeTimeSliderState(set: TypeSetStore, get: TypeGetStore):
get().timeSliderState.actions.applyFilters(layerPath, values);
},
// #endregion ACTIONS
setTemporalDimension(layerPath: string, temporalDimension: TemporalDimensionProps | null): void {
const sliderLayers = get().timeSliderState.timeSliderLayers;
if (temporalDimension?.field) {
sliderLayers[layerPath].field = temporalDimension.field;
}
if (temporalDimension?.default) {
sliderLayers[layerPath].defaultValue = temporalDimension.default;
}
if (temporalDimension?.singleHandle) {
sliderLayers[layerPath].singleHandle = temporalDimension.singleHandle;
}
if (temporalDimension?.nearestValues) {
sliderLayers[layerPath].nearestValues = temporalDimension.nearestValues;
}
if (temporalDimension?.unitSymbol) {
sliderLayers[layerPath].unitSymbol = temporalDimension.unitSymbol;
}
if (temporalDimension?.range) {
sliderLayers[layerPath].range = temporalDimension.range;
}
sliderLayers[layerPath].temporalDimension = temporalDimension;
set({
timeSliderState: {
...get().timeSliderState,
timeSliderLayers: { ...sliderLayers },
},
});
},
},
} as ITimeSliderState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ export abstract class AbstractGeoViewLayer {
if (layerStatus === 'processed') this.setLayerPhase('processed', layerPath);
}

/** ***************************************************************************************************************************
* Change the layer temporal dimension property and emit an event to update existing layer sets.
*
* @param {TimeDimension} timeDimension The value to assign to the layer temporal dimension property.
* @param {string} layerPath The layer path to the layer's configuration affected by the change.
*/
setLayerTemporalDimension(timeDimension: TimeDimension, layerPath?: string) {
layerPath = layerPath || this.layerPathAssociatedToTheGeoviewLayer;
this.layerTemporalDimension[layerPath] = timeDimension;
}

/** ***************************************************************************************************************************
* Process recursively the list of layer entries to see if all of them are processed.
*
Expand Down
7 changes: 2 additions & 5 deletions packages/geoview-time-slider/src/time-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +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, setDefaultValue, setValues, setLocked, setReversed, setDelay, setFiltering, setTemporalDimension } =
const { setTitle, setDescription, setDefaultValue, setValues, setLocked, setReversed, setDelay, setFiltering } =
useTimeSliderStoreActions();

// TODO: check performance as we should technically have one selector by constant
Expand All @@ -69,8 +69,7 @@ export function TimeSlider(TimeSliderPanelProps: TimeSliderPanelProps) {
values,
delay,
locked,
reversed,
temporalDimension,
reversed
} = useTimeSliderLayers()[layerPath];

// slider config
Expand All @@ -82,8 +81,6 @@ export function TimeSlider(TimeSliderPanelProps: TimeSliderPanelProps) {
if (defaultValue === undefined) setDefaultValue(layerPath, sliderConfig?.defaultValue || '');
if (locked === undefined) setLocked(layerPath, sliderConfig?.locked !== undefined ? sliderConfig?.locked : false);
if (reversed === undefined) setReversed(layerPath, sliderConfig?.reversed !== undefined ? sliderConfig?.reversed : false);
if (temporalDimension === undefined)
setTemporalDimension(layerPath, sliderConfig?.temporalDimension !== undefined ? sliderConfig?.temporalDimension : null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit acb81a5

Please sign in to comment.