Skip to content

Commit 343b554

Browse files
authored
[feat] wms layer improvements (#3151)
* [feat] wms layer improvements Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * fix lint Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * more tests Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * check for queryable Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * fixes Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * nit Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * nit Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * nit Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * test fixes Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * test fixes; lint Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> --------- Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
1 parent c1d2b86 commit 343b554

13 files changed

Lines changed: 711 additions & 38 deletions

File tree

src/actions/src/action-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export const ActionTypes = {
148148
REMOVE_NOTIFICATION: `${ACTION_PREFIX}REMOVE_NOTIFICATION`,
149149
SET_LOCALE: `${ACTION_PREFIX}SET_LOCALE`,
150150
LAYER_FILTERED_ITEMS_CHANGE: `${ACTION_PREFIX}LAYER_FILTERED_ITEMS_CHANGE`,
151+
WMS_FEATURE_INFO: `${ACTION_PREFIX}WMS_FEATURE_INFO`,
151152
SYNC_TIME_FILTER_WITH_LAYER_TIMELINE: `${ACTION_PREFIX}SYNC_TIME_FILTER_WITH_LAYER_TIMELINE`,
152153
SYNC_TIME_FILTER_TIMELINE_MODE: `${ACTION_PREFIX}SYNC_TIME_FILTER_TIMELINE_MODE`,
153154
TOGGLE_PANEL_LIST_VIEW: `${ACTION_PREFIX}TOGGLE_PANEL_LIST_VIEW`,

src/actions/src/vis-state-actions.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,33 @@ export function layerFilteredItemsChange(
16291629
};
16301630
}
16311631

1632+
export type WMSFeatureInfoAction = {
1633+
layer: Layer;
1634+
featureInfo: Array<{name: string; value: string}> | string | null;
1635+
coordinate?: [number, number] | null;
1636+
};
1637+
1638+
/**
1639+
* WMS layer feature info callback
1640+
* @memberof visStateActions
1641+
* @param layer
1642+
* @param featureInfo
1643+
* @param coordinate
1644+
* @return action
1645+
*/
1646+
export function wmsFeatureInfo(
1647+
layer: WMSFeatureInfoAction['layer'],
1648+
featureInfo: WMSFeatureInfoAction['featureInfo'],
1649+
coordinate?: WMSFeatureInfoAction['coordinate']
1650+
): Merge<WMSFeatureInfoAction, {type: typeof ActionTypes.WMS_FEATURE_INFO}> {
1651+
return {
1652+
type: ActionTypes.WMS_FEATURE_INFO,
1653+
layer,
1654+
featureInfo,
1655+
coordinate
1656+
};
1657+
}
1658+
16321659
export type SyncTimeFilterWithLayerTimelineAction = {
16331660
idx: number;
16341661
enable: boolean;

src/components/src/map-container.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,20 @@ export default function MapContainerFactory(
526526
this.props.visStateActions.layerFilteredItemsChange(this.props.visState.layers[idx], event);
527527
};
528528

529+
_onWMSFeatureInfo = (
530+
idx: number,
531+
data: {
532+
featureInfo: Array<{name: string; value: string}> | string | null;
533+
coordinate?: [number, number] | null;
534+
}
535+
) => {
536+
this.props.visStateActions.wmsFeatureInfo(
537+
this.props.visState.layers[idx],
538+
data.featureInfo,
539+
data.coordinate
540+
);
541+
};
542+
529543
_handleMapToggleLayer = layerId => {
530544
const {index: mapIndex = 0, visStateActions} = this.props;
531545
visStateActions.toggleLayerForMap(mapIndex, layerId);
@@ -823,7 +837,8 @@ export default function MapContainerFactory(
823837
{
824838
onLayerHover: this._onLayerHover,
825839
onSetLayerDomain: this._onLayerSetDomain,
826-
onFilteredItemsChange: this._onLayerFilteredItemsChange
840+
onFilteredItemsChange: this._onLayerFilteredItemsChange,
841+
onWMSFeatureInfo: this._onWMSFeatureInfo
827842
},
828843
deckGlProps
829844
);

src/components/src/map/layer-hover-info.tsx

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,37 @@ const EntryInfoRow: React.FC<EntryInfoRowProps> = ({
138138
const field = fields[fieldIdx];
139139
const fieldValueAccessor = layer.accessVSFieldValue(field, currentTime);
140140
const value = fieldValueAccessor(field, data instanceof DataRow ? {index: data._rowIndex} : data);
141-
const primaryValue = primaryData
142-
? fieldValueAccessor(
143-
field,
144-
primaryData instanceof DataRow ? {index: primaryData._rowIndex} : primaryData
145-
)
146-
: null;
147-
const displayValue = getTooltipDisplayValue({item, field, value});
148141

149-
const displayDeltaValue = primaryData
150-
? getTooltipDisplayDeltaValue({
151-
field,
152-
value,
153-
primaryValue,
154-
compareType
155-
})
156-
: null;
142+
// Handle WMS layer data in comparison mode - WMS layers don't have comparable field data
143+
let primaryValue = null;
144+
let displayDeltaValue: string | null = null;
145+
146+
if (primaryData) {
147+
try {
148+
// Only calculate primary value if primaryData has a compatible structure
149+
if (
150+
primaryData instanceof DataRow ||
151+
(primaryData && typeof primaryData === 'object' && 'index' in primaryData)
152+
) {
153+
primaryValue = fieldValueAccessor(
154+
field,
155+
primaryData instanceof DataRow ? {index: primaryData._rowIndex} : primaryData
156+
);
157+
158+
displayDeltaValue = getTooltipDisplayDeltaValue({
159+
field,
160+
value,
161+
primaryValue,
162+
compareType
163+
});
164+
}
165+
} catch (error) {
166+
// If there's an error accessing primaryData (e.g., WMS layer data), skip comparison
167+
primaryValue = null;
168+
}
169+
}
170+
171+
const displayValue = getTooltipDisplayValue({item, field, value});
157172

158173
return (
159174
<Row
@@ -236,6 +251,7 @@ const LayerHoverInfoFactory = () => {
236251

237252
const hasFieldsToShow =
238253
(data.fieldValues && Object.keys(data.fieldValues).length > 0) ||
254+
(data.wmsFeatureData && data.wmsFeatureData.length > 0) ||
239255
(props.fieldsToShow && props.fieldsToShow.length > 0);
240256

241257
return (
@@ -246,7 +262,13 @@ const LayerHoverInfoFactory = () => {
246262
</StyledLayerName>
247263
{hasFieldsToShow && <StyledDivider />}
248264
<StyledTable>
249-
{data.fieldValues ? (
265+
{data.wmsFeatureData ? (
266+
<tbody>
267+
{data.wmsFeatureData.map(({name, value}, i) => (
268+
<Row key={i} name={name} value={value} />
269+
))}
270+
</tbody>
271+
) : data.fieldValues ? (
250272
<tbody>
251273
{data.fieldValues.map(({labelMessage, value}, i) => (
252274
<Row key={i} name={intl.formatMessage({id: labelMessage})} value={value} />

src/deckgl-layers/src/wms/wms-layer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export default class WMSLayer extends CompositeLayer<Required<_WMSLayerProps>> {
130130
? COORDINATE_SYSTEM.LNGLAT
131131
: COORDINATE_SYSTEM.CARTESIAN,
132132
bounds,
133-
image
133+
image,
134+
pickable: this.props.pickable
134135
})
135136
);
136137
}

0 commit comments

Comments
 (0)