Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/actions/src/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const ActionTypes = {
REMOVE_NOTIFICATION: `${ACTION_PREFIX}REMOVE_NOTIFICATION`,
SET_LOCALE: `${ACTION_PREFIX}SET_LOCALE`,
LAYER_FILTERED_ITEMS_CHANGE: `${ACTION_PREFIX}LAYER_FILTERED_ITEMS_CHANGE`,
WMS_FEATURE_INFO: `${ACTION_PREFIX}WMS_FEATURE_INFO`,
SYNC_TIME_FILTER_WITH_LAYER_TIMELINE: `${ACTION_PREFIX}SYNC_TIME_FILTER_WITH_LAYER_TIMELINE`,
SYNC_TIME_FILTER_TIMELINE_MODE: `${ACTION_PREFIX}SYNC_TIME_FILTER_TIMELINE_MODE`,
TOGGLE_PANEL_LIST_VIEW: `${ACTION_PREFIX}TOGGLE_PANEL_LIST_VIEW`,
Expand Down
27 changes: 27 additions & 0 deletions src/actions/src/vis-state-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,33 @@ export function layerFilteredItemsChange(
};
}

export type WMSFeatureInfoAction = {
layer: Layer;
featureInfo: Array<{name: string; value: string}> | string | null;
coordinate?: [number, number] | null;
};

/**
* WMS layer feature info callback
* @memberof visStateActions
* @param layer
* @param featureInfo
* @param coordinate
* @return action
*/
export function wmsFeatureInfo(
layer: WMSFeatureInfoAction['layer'],
featureInfo: WMSFeatureInfoAction['featureInfo'],
coordinate?: WMSFeatureInfoAction['coordinate']
): Merge<WMSFeatureInfoAction, {type: typeof ActionTypes.WMS_FEATURE_INFO}> {
return {
type: ActionTypes.WMS_FEATURE_INFO,
layer,
featureInfo,
coordinate
};
}

export type SyncTimeFilterWithLayerTimelineAction = {
idx: number;
enable: boolean;
Expand Down
17 changes: 16 additions & 1 deletion src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ export default function MapContainerFactory(
this.props.visStateActions.layerFilteredItemsChange(this.props.visState.layers[idx], event);
};

_onWMSFeatureInfo = (
idx: number,
data: {
featureInfo: Array<{name: string; value: string}> | string | null;
coordinate?: [number, number] | null;
}
) => {
this.props.visStateActions.wmsFeatureInfo(
this.props.visState.layers[idx],
data.featureInfo,
data.coordinate
);
};

_handleMapToggleLayer = layerId => {
const {index: mapIndex = 0, visStateActions} = this.props;
visStateActions.toggleLayerForMap(mapIndex, layerId);
Expand Down Expand Up @@ -823,7 +837,8 @@ export default function MapContainerFactory(
{
onLayerHover: this._onLayerHover,
onSetLayerDomain: this._onLayerSetDomain,
onFilteredItemsChange: this._onLayerFilteredItemsChange
onFilteredItemsChange: this._onLayerFilteredItemsChange,
onWMSFeatureInfo: this._onWMSFeatureInfo
},
deckGlProps
);
Expand Down
54 changes: 38 additions & 16 deletions src/components/src/map/layer-hover-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,37 @@ const EntryInfoRow: React.FC<EntryInfoRowProps> = ({
const field = fields[fieldIdx];
const fieldValueAccessor = layer.accessVSFieldValue(field, currentTime);
const value = fieldValueAccessor(field, data instanceof DataRow ? {index: data._rowIndex} : data);
const primaryValue = primaryData
? fieldValueAccessor(
field,
primaryData instanceof DataRow ? {index: primaryData._rowIndex} : primaryData
)
: null;
const displayValue = getTooltipDisplayValue({item, field, value});

const displayDeltaValue = primaryData
? getTooltipDisplayDeltaValue({
field,
value,
primaryValue,
compareType
})
: null;
// Handle WMS layer data in comparison mode - WMS layers don't have comparable field data
let primaryValue = null;
let displayDeltaValue: string | null = null;

if (primaryData) {
try {
// Only calculate primary value if primaryData has a compatible structure
if (
primaryData instanceof DataRow ||
(primaryData && typeof primaryData === 'object' && 'index' in primaryData)
) {
primaryValue = fieldValueAccessor(
field,
primaryData instanceof DataRow ? {index: primaryData._rowIndex} : primaryData
);

displayDeltaValue = getTooltipDisplayDeltaValue({
field,
value,
primaryValue,
compareType
});
}
} catch (error) {
// If there's an error accessing primaryData (e.g., WMS layer data), skip comparison
primaryValue = null;
}
}

const displayValue = getTooltipDisplayValue({item, field, value});

return (
<Row
Expand Down Expand Up @@ -236,6 +251,7 @@ const LayerHoverInfoFactory = () => {

const hasFieldsToShow =
(data.fieldValues && Object.keys(data.fieldValues).length > 0) ||
(data.wmsFeatureData && data.wmsFeatureData.length > 0) ||
(props.fieldsToShow && props.fieldsToShow.length > 0);

return (
Expand All @@ -246,7 +262,13 @@ const LayerHoverInfoFactory = () => {
</StyledLayerName>
{hasFieldsToShow && <StyledDivider />}
<StyledTable>
{data.fieldValues ? (
{data.wmsFeatureData ? (
<tbody>
{data.wmsFeatureData.map(({name, value}, i) => (
<Row key={i} name={name} value={value} />
))}
</tbody>
) : data.fieldValues ? (
<tbody>
{data.fieldValues.map(({labelMessage, value}, i) => (
<Row key={i} name={intl.formatMessage({id: labelMessage})} value={value} />
Expand Down
3 changes: 2 additions & 1 deletion src/deckgl-layers/src/wms/wms-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default class WMSLayer extends CompositeLayer<Required<_WMSLayerProps>> {
? COORDINATE_SYSTEM.LNGLAT
: COORDINATE_SYSTEM.CARTESIAN,
bounds,
image
image,
pickable: this.props.pickable
})
);
}
Expand Down
Loading