From 7fb9bb51a22fd2393ef6d7e68a600e1d1ce722af Mon Sep 17 00:00:00 2001
From: Damon Ulmi <63123585+DamonU2@users.noreply.github.com>
Date: Tue, 10 Dec 2024 07:18:55 -0800
Subject: [PATCH] fix(feature info): repairs feature info for geocore layers
(#2631)
Closes #2593
Closes #2210
Closes #563
---
.../core/components/details/details-style.ts | 14 ++++++++++++-
.../components/details/feature-info-table.tsx | 20 ++++++++++++++-----
.../geoview-core/src/core/utils/date-mgt.ts | 2 +-
.../geo/layer/gv-layers/abstract-gv-layer.ts | 7 ++++---
.../layer/gv-layers/raster/gv-esri-dynamic.ts | 4 ++--
.../src/geo/layer/gv-layers/raster/gv-wms.ts | 20 ++++++++++++++++++-
packages/geoview-core/src/geo/layer/layer.ts | 2 +-
7 files changed, 55 insertions(+), 14 deletions(-)
diff --git a/packages/geoview-core/src/core/components/details/details-style.ts b/packages/geoview-core/src/core/components/details/details-style.ts
index a3e4ec35dde..52a0a9537ac 100644
--- a/packages/geoview-core/src/core/components/details/details-style.ts
+++ b/packages/geoview-core/src/core/components/details/details-style.ts
@@ -52,8 +52,20 @@ export const getSxClasses = (theme: Theme): SxStyles => ({
featureInfoItemValue: {
marginRight: 0,
wordBreak: 'break-word',
- overflow: 'hidden',
+ overflowX: 'auto',
textOverflow: 'ellipsis',
+ ' table': {
+ border: '1px solid',
+ width: '100%',
+ borderCollapse: 'collapse',
+ },
+ ' th, td': {
+ border: '1px solid',
+ wordBreak: 'normal',
+ textAllign: 'center',
+ padding: '5px',
+ whiteSpace: 'nowrap',
+ },
},
boxContainerFeatureInfo: {
wordWrap: 'break-word',
diff --git a/packages/geoview-core/src/core/components/details/feature-info-table.tsx b/packages/geoview-core/src/core/components/details/feature-info-table.tsx
index 5892ab01480..ff33a8aa5f0 100644
--- a/packages/geoview-core/src/core/components/details/feature-info-table.tsx
+++ b/packages/geoview-core/src/core/components/details/feature-info-table.tsx
@@ -59,7 +59,13 @@ export function FeatureInfoTable({ featureInfoList }: FeatureInfoTableProps): JS
function setFeatureItem(featureInfoItem: TypeFieldEntry): JSX.Element | JSX.Element[] {
function process(item: string, alias: string, index: number): JSX.Element {
let element: JSX.Element;
- if (typeof item === 'string' && isImage(item)) {
+ if (alias === 'html') {
+ element = (
+
+
+
+ );
+ } else if (typeof item === 'string' && isImage(item)) {
element = (
process(item, alias, index))
: process(values, alias, 0);
@@ -110,9 +118,11 @@ export function FeatureInfoTable({ featureInfoList }: FeatureInfoTableProps): JS
}}
key={`${featureInfoItem.alias} ${index.toString()}`}
>
-
- {featureInfoItem.alias}
-
+ {featureInfoItem.alias !== 'html' && (
+
+ {featureInfoItem.alias}
+
+ )}
{setFeatureItem(featureInfoItem)}
))}
diff --git a/packages/geoview-core/src/core/utils/date-mgt.ts b/packages/geoview-core/src/core/utils/date-mgt.ts
index 8f6355fcdd7..445a237a96b 100644
--- a/packages/geoview-core/src/core/utils/date-mgt.ts
+++ b/packages/geoview-core/src/core/utils/date-mgt.ts
@@ -703,7 +703,7 @@ export abstract class DateMgt {
if (index[SECOND_DATE_ELEMENT] + 1) returnValue = `${returnValue}${dateFragments[index[SECOND_DATE_ELEMENT]]}`;
if (returnValue && index[THIRD_DATE_ELEMENT] + 1) returnValue = `${returnValue}${separators[DATE]}`;
if (index[THIRD_DATE_ELEMENT] + 1) returnValue = `${returnValue}${dateFragments[index[THIRD_DATE_ELEMENT]]}`;
- if (index[TIME] + 1) returnValue = `${returnValue}${separators[DATE_TIME]}${timeString.slice(0, 8)}`;
+ if (index[TIME] + 1 && timeString) returnValue = `${returnValue}${separators[DATE_TIME]}${timeString.slice(0, 8)}`;
return returnValue;
}
diff --git a/packages/geoview-core/src/geo/layer/gv-layers/abstract-gv-layer.ts b/packages/geoview-core/src/geo/layer/gv-layers/abstract-gv-layer.ts
index c901d6709bc..cc1fb0a9fa8 100644
--- a/packages/geoview-core/src/geo/layer/gv-layers/abstract-gv-layer.ts
+++ b/packages/geoview-core/src/geo/layer/gv-layers/abstract-gv-layer.ts
@@ -251,9 +251,10 @@ export abstract class AbstractGVLayer extends AbstractBaseLayer {
// Get the layer config
const layerConfig = this.getLayerConfig();
- // If queryable
- if (!layerConfig.source?.featureInfo?.queryable) {
- logger.logError(`Layer at path ${layerConfig.layerPath} is not queryable`);
+ // If the layer is not queryable
+ // GV: This should always be set by now. There were instances where that was not happeneing, recheck once config API is being used
+ if (layerConfig.source?.featureInfo?.queryable === false) {
+ logger.logWarning(`Layer at path ${layerConfig.layerPath} is not queryable`);
return null;
}
diff --git a/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-esri-dynamic.ts b/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-esri-dynamic.ts
index 8d5df444ea6..b1188aba624 100644
--- a/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-esri-dynamic.ts
+++ b/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-esri-dynamic.ts
@@ -249,9 +249,9 @@ export class GVEsriDynamic extends AbstractGVRaster {
const layerConfig = this.getLayerConfig();
// If not queryable
- if (!layerConfig.source?.featureInfo?.queryable) return [];
+ if (!layerConfig.source.featureInfo?.queryable) return [];
- let identifyUrl = layerConfig.source?.dataAccessPath;
+ let identifyUrl = layerConfig.source.dataAccessPath;
if (!identifyUrl) return [];
identifyUrl = identifyUrl.endsWith('/') ? identifyUrl : `${identifyUrl}/`;
diff --git a/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-wms.ts b/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-wms.ts
index 032051934a0..16daf08ab06 100644
--- a/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-wms.ts
+++ b/packages/geoview-core/src/geo/layer/gv-layers/raster/gv-wms.ts
@@ -18,6 +18,7 @@ import { TypeFeatureInfoEntry } from '@/geo/map/map-schema-types';
import { loadImage } from '@/geo/utils/renderer/geoview-renderer';
import { AbstractGVRaster } from './abstract-gv-raster';
import { TypeLegend } from '@/core/stores/store-interface-and-intial-values/layer-state';
+import { Projection } from '@/geo/utils/projection';
/**
* Manages a WMS layer.
@@ -117,6 +118,18 @@ export class GVWMS extends AbstractGVRaster {
// Get the layer config and source
const layerConfig = this.getLayerConfig();
+ // Check if bounds are properly set
+ if (!layerConfig.initialSettings!.bounds) {
+ const newBounds = this.getBounds(this.getLayerPath());
+ if (newBounds)
+ layerConfig.initialSettings!.bounds = Projection.transformExtentFromProj(
+ newBounds,
+ this.getMapViewer().getView().getProjection(),
+ Projection.PROJECTION_NAMES.LNGLAT
+ );
+ else return [];
+ }
+
const clickCoordinate = this.getMapViewer().convertCoordinateLngLatToMapProj(lnglat);
if (
lnglat[0] < layerConfig.initialSettings!.bounds![0] ||
@@ -130,8 +143,9 @@ export class GVWMS extends AbstractGVRaster {
const featureInfoFormat = this.getLayerConfig().getServiceMetadata()?.Capability?.Request?.GetFeatureInfo?.Format as TypeJsonArray;
if (featureInfoFormat)
if (featureInfoFormat.includes('text/xml' as TypeJsonObject)) infoFormat = 'text/xml';
+ else if (featureInfoFormat.includes('text/html' as TypeJsonObject)) infoFormat = 'text/html';
else if (featureInfoFormat.includes('text/plain' as TypeJsonObject)) infoFormat = 'text/plain';
- else throw new Error('Parameter info_format of GetFeatureInfo only support text/xml and text/plain for WMS services.');
+ else throw new Error('Parameter info_format of GetFeatureInfo only support text/xml, text/html and text/plain for WMS services.');
const wmsSource = this.getOLSource();
const viewResolution = this.getMapViewer().getView().getResolution()!;
@@ -166,12 +180,16 @@ export class GVWMS extends AbstractGVRaster {
}
}
}
+ } else if (infoFormat === 'text/html') {
+ featureMember = { html: response.data };
} else featureMember = { plain_text: { '#text': response.data } };
+
if (featureMember) {
const featureInfoResult = GVWMS.#formatWmsFeatureInfoResult(featureMember, clickCoordinate);
return featureInfoResult;
}
}
+
return [];
} catch (error) {
// Log
diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts
index e122a828a6f..4f139e8deb4 100644
--- a/packages/geoview-core/src/geo/layer/layer.ts
+++ b/packages/geoview-core/src/geo/layer/layer.ts
@@ -384,7 +384,7 @@ export class LayerApi {
const newOrderedLayerInfos: TypeOrderedLayerInfo[] = [];
const addSubLayerPathToLayerOrder = (layerEntryConfig: TypeLayerEntryConfig, layerPath: string): void => {
- const subLayerPath = layerPath.endsWith(layerEntryConfig.layerId) ? layerPath : `${layerPath}/${layerEntryConfig.layerId}`;
+ const subLayerPath = layerPath.endsWith(`/${layerEntryConfig.layerId}`) ? layerPath : `${layerPath}/${layerEntryConfig.layerId}`;
const layerInfo: TypeOrderedLayerInfo = {
layerPath: subLayerPath,
visible: layerEntryConfig.initialSettings?.states?.visible !== false,