From 80f184eed69f913746eae1da081a27f197198472 Mon Sep 17 00:00:00 2001 From: Johann Levesque Date: Fri, 17 Jan 2025 12:49:56 -0500 Subject: [PATCH] finish details --- .../public/configs/performance.json | 4 + .../core/components/details/feature-info.tsx | 4 +- .../layer/gv-layers/raster/gv-esri-dynamic.ts | 73 ++++++++++++------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/packages/geoview-core/public/configs/performance.json b/packages/geoview-core/public/configs/performance.json index 6dd39d58cf3..d5ba9db4fa4 100644 --- a/packages/geoview-core/public/configs/performance.json +++ b/packages/geoview-core/public/configs/performance.json @@ -21,6 +21,10 @@ { "geoviewLayerType": "geoCore", "geoviewLayerId": "e2424b6c-db0c-4996-9bc0-2ca2e6714d71" + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "c5c249c4-dea6-40a6-8fae-188a42030908" } ] }, diff --git a/packages/geoview-core/src/core/components/details/feature-info.tsx b/packages/geoview-core/src/core/components/details/feature-info.tsx index d2eee3b6890..c952f8af1b4 100644 --- a/packages/geoview-core/src/core/components/details/feature-info.tsx +++ b/packages/geoview-core/src/core/components/details/feature-info.tsx @@ -69,7 +69,7 @@ const FeatureHeader = memo(function FeatureHeader({ iconSrc, name, hasGeometry, - + @@ -186,7 +186,7 @@ export function FeatureInfo({ feature }: FeatureInfoProps): JSX.Element | null { []; const arrayOfFeatureInfoEntries = await this.formatFeatureInfoResult(features, layerConfig); - this.getFeatureInfoGeometryWorker(layerConfig, objectIds, true, mapViewer.getMapState().currentProjection, maxAllowableOffset) - .then((featuresJSON) => { - (featuresJSON.features as unknown as TypeFeatureInfoEntry[]).forEach((feat: TypeFeatureInfoEntry, index: number) => { - const geom = new EsriJSON().readFeature(feat, { - dataProjection: `EPSG:${mapViewer.getMapState().currentProjection}`, - featureProjection: `EPSG:${mapViewer.getMapState().currentProjection}`, - }) as Feature; - - if ( - arrayOfFeatureInfoEntries![index] && - arrayOfFeatureInfoEntries![index].geometry && - arrayOfFeatureInfoEntries![index].geometry instanceof Feature - ) { - arrayOfFeatureInfoEntries![index].extent = geom.getGeometry()?.getExtent(); - arrayOfFeatureInfoEntries![index].geometry.setGeometry(geom.getGeometry()); - } - }); - - // arrayOfFeatureInfoEntries!.forEach((featureInfoEntry, i) => { - // const feature = features[i]; - // featureInfoEntry.geometry = feature.getGeometry(); - - // arrayOfFeatureInfoEntries[0].geometry.setGeometry(featuresJSON.features[0]) - // }); - logger.logDebug('Features worker', featuresJSON); - }) - .catch((err) => logger.logError('Features worker', err)); + // If geometry is needed, use web worker to query and assing geometry later + if (queryGeometry) + // TODO: Performance - We may need to use chunk and process 50 geom at a time. When we query 500 features (points) we have CORS issue with + // TODO.CONT: the esri query (was working with identify). But identify was failing on huge geometry... + this.getFeatureInfoGeometryWorker(layerConfig, objectIds, true, mapViewer.getMapState().currentProjection, maxAllowableOffset) + .then((featuresJSON) => { + (featuresJSON.features as TypeJsonObject[]).forEach((feat: TypeJsonObject, index: number) => { + // TODO: Performance - There is still a problem when we create the feature with new EsriJSON().readFeature. It goes trought a loop and take minutes on the deflate function + // TODO.CONT: 1dcd28aa-99da-4f62-b157-15631379b170, ocean biology layer has huge amount of verticies and when zoomed in we require more + // TODO.CONT: more definition so the feature creation take more time. Investigate if we can create the geometry instead + // TODO.CONT: Investigate using this approach in esri-feature.ts + // const geom = new EsriJSON().readFeature(feat, { + // dataProjection: `EPSG:${mapViewer.getMapState().currentProjection}`, + // featureProjection: `EPSG:${mapViewer.getMapState().currentProjection}`, + // }) as Feature; + + // TODO: Performance - Relying on style to get geometry is not good. We shold extract it from metadata and keep it in dedicated attribute + const geomType = Object.keys(layerConfig?.layerStyle || []); + + // Get coordinates in right format and create geometry + const coordinates = (feat.geometry?.points || + feat.geometry?.paths || + // eslint-disable-next-line @typescript-eslint/no-explicit-any + feat.geometry?.rings || [feat.geometry?.x, feat.geometry?.y]) as any; // MultiPoint or Line or Polygon or Point schema + const newGeom: Geometry | null = + geomType.length > 0 + ? (GeometryApi.createGeometryFromType(geomType[0] as TypeStyleGeometry, coordinates) as unknown as Geometry) + : null; + + // TODO: Perfromance - We will need a trigger to refresh the higight and detaiils panel (for zoom button) when extent and + // TODO.CONT: is applied. Sometime the delay is too big so we need to change tab or layer in layer list to trigger the refresh + // We assume order of arrayOfFeatureInfoEntries is the same as featuresJSON.features as they are process in same order + const entry = arrayOfFeatureInfoEntries![index]; + if (newGeom !== null && entry.geometry && entry.geometry instanceof Feature) { + entry.extent = newGeom.getExtent(); + entry.geometry.setGeometry(newGeom); + } + }); + }) + .catch((err) => logger.logError('Features worker', err)); return arrayOfFeatureInfoEntries; } catch (error) {