diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts index c41bdee8136..72a32eb0ecd 100644 --- a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts +++ b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts @@ -1271,30 +1271,6 @@ export abstract class AbstractGeoViewLayer { try { if (!features.length) return []; - // Will hold the generic icon to use in formatting - let genericLegendInfo: string | null | undefined; - // We only want 1 task to fetch the generic legend (when we have to) - const semaphore = new AsyncSemaphore(1); - - // Will be executed when we have to use a default canvas for a particular feature - const callbackToFetchDataUrl = (): Promise => { - // TODO: Fix - Don't take 'iconImage' below, it's always the same image... - // TO.DOCONT: Use this.style.fields and this.style.[Geom].fields and this.style.[Geom].uniqueValueStyleInfo with a combination of the 'featureNeedingItsCanvas' to determine the style image - // TO.DOCONT: Also, get rid of 'genericLegendInfo' and 'semaphore' variables once code is rewritten to use the 'featureNeedingItsCanvas' - - // Make sure one task at a time in this - return semaphore.withLock(async () => { - // Only execute this once in the callback. After this, once the semaphore is unlocked, it's either a string or null for as long as we're formatting - if (genericLegendInfo === undefined) { - genericLegendInfo = null; // Turn it to null, we are actively trying to find something (not undefined anymore) - const legend = await this.queryLegend(layerConfig.layerPath); - const legendIcons = LegendEventProcessor.getLayerIconImage(legend); - if (legendIcons) genericLegendInfo = legendIcons![0].iconImage || null; - } - return genericLegendInfo; - }); - }; - const featureInfo = layerConfig?.source?.featureInfo; // Loop on the features to build the array holding the promises for their canvas @@ -1307,8 +1283,8 @@ export abstract class AbstractGeoViewLayer { this.getStyle(layerConfig.layerPath)!, layerConfig.filterEquation, layerConfig.legendFilterIsOff, - true, - callbackToFetchDataUrl + true + // callbackToFetchDataUrl ) .then((canvas) => { resolveCanvas({ feature: featureNeedingItsCanvas, canvas }); diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-dynamic.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-dynamic.ts index 1dc158bd4c5..f0a42e0c9a1 100644 --- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-dynamic.ts +++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-dynamic.ts @@ -337,13 +337,17 @@ export class EsriDynamic extends AbstractGeoViewRaster { const layerConfig = this.getLayerConfig(layerPath)! as EsriDynamicLayerEntryConfig; // Guess the geometry type by taking the first style key - // TODO: Refactor - Layers migration. Johann: This will be modified with new schema, there is no more geometry on style const [geometryType] = layerConfig.getTypeGeometries(); // Fetch the features let urlRoot = layerConfig.geoviewLayerConfig.metadataAccessPath!; if (!urlRoot.endsWith('/')) urlRoot += '/'; - // TODO: we put false so on heavy geometry, dynamic layer can load datatable. If not the fetch fails. + // GV: we put false so on heavy geometry, dynamic layer can load datatable. If not the fetch fails. + // TODO: Because we do not query the geometry anymore, the section below to create geometry is useless + // TODO.CONT: This also have an effect on the style as it use the geometry to define wich one to use + // TODO.CONT: The formatFeatureInfoResult (abstact-geoview-layer) / getFeatureCanvas (geoview-renderer) + // TODO.CONT: needs to be modified to use default style pass to the function.... + // TODO.CONT: We need a refactor to this in background, maybe with workers const url = `${urlRoot}${layerConfig.layerId}/query?where=1=1&outFields=*&f=json&returnGeometry=false`; const response = await fetch(url); 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 c047d4405f4..8f7851c3564 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 @@ -516,26 +516,6 @@ export abstract class AbstractGVLayer extends AbstractBaseLayer { try { if (!features.length) return []; - // Will hold the generic icon to use in formatting - let genericLegendInfo: string | null | undefined; - // We only want 1 task to fetch the generic legend (when we have to) - const semaphore = new AsyncSemaphore(1); - - // Will be executed when we have to use a default canvas for a particular feature - const callbackToFetchDataUrl = (): Promise => { - // Make sure one task at a time in this - return semaphore.withLock(async () => { - // Only execute this once in the callback. After this, once the semaphore is unlocked, it's either a string or null for as long as we're formatting - if (genericLegendInfo === undefined) { - genericLegendInfo = null; // Turn it to null, we are actively trying to find something (not undefined anymore) - const legend = await this.queryLegend(); - const legendIcons = LegendEventProcessor.getLayerIconImage(legend); - if (legendIcons) genericLegendInfo = legendIcons![0].iconImage || null; - } - return genericLegendInfo; - }); - }; - const outfields = layerConfig?.source?.featureInfo?.outfields; // Loop on the features to build the array holding the promises for their canvas @@ -548,8 +528,7 @@ export abstract class AbstractGVLayer extends AbstractBaseLayer { this.getStyle(layerConfig.layerPath)!, layerConfig.filterEquation, layerConfig.legendFilterIsOff, - true, - callbackToFetchDataUrl + true ) .then((canvas) => { resolveCanvas({ feature: featureNeedingItsCanvas, canvas }); 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 0bf60a27acf..caadec3051c 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 @@ -124,13 +124,17 @@ export class GVEsriDynamic extends AbstractGVRaster { const layerConfig = this.getLayerConfig(); // Guess the geometry type by taking the first style key - // TODO: Refactor - Layers migration. Johann: This will be modified with new schema, there is no more geometry on style const [geometryType] = layerConfig.getTypeGeometries(); // Fetch the features let urlRoot = layerConfig.geoviewLayerConfig.metadataAccessPath!; if (!urlRoot.endsWith('/')) urlRoot += '/'; - // TODO: we put false so on heavy geometry, dynamic layer can load datatable. If not the featch fails. + // GV: we put false so on heavy geometry, dynamic layer can load datatable. If not the fetch fails. + // TODO: Because we do not query the geometry anymore, the section below to create geometry is useless + // TODO.CONT: This also have an effect on the style as it use the geometry to define wich one to use + // TODO.CONT: The formatFeatureInfoResult (abstact-geoview-layer) / getFeatureCanvas (geoview-renderer) + // TODO.CONT: needs to be modified to use default style pass to the function.... + // TODO.CONT: We need a refactor to this in background, maybe with workers const url = `${urlRoot}${layerConfig.layerId}/query?where=1=1&outFields=*&f=json&returnGeometry=false`; const response = await fetch(url); diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts index e690bf452c3..a364ac39560 100644 --- a/packages/geoview-core/src/geo/layer/layer.ts +++ b/packages/geoview-core/src/geo/layer/layer.ts @@ -169,7 +169,7 @@ export class LayerApi { // ************************************************************ // INDICATES IF USING HYBRID MODE WITH THE NEW GVLAYERS CLASSES // ************************************************************ - static LAYERS_HYBRID_MODE = false; + static LAYERS_HYBRID_MODE = true; /** * Initializes layer types and listen to add/remove layer events from outside diff --git a/packages/geoview-core/src/geo/utils/renderer/geoview-renderer.ts b/packages/geoview-core/src/geo/utils/renderer/geoview-renderer.ts index c3fcd8e2c2a..6772ea00987 100644 --- a/packages/geoview-core/src/geo/utils/renderer/geoview-renderer.ts +++ b/packages/geoview-core/src/geo/utils/renderer/geoview-renderer.ts @@ -1598,9 +1598,11 @@ export async function getFeatureCanvas( // The canvas that will be returned (if calculated successfully) let canvas: HTMLCanvasElement | undefined; - // If the feature has a geometry - if (feature.getGeometry()) { - const geometryType = getGeometryType(feature); + // GV: Some time, the feature will have no geometry e.g. esriDynamic has we fetch geometry only when needed + // GV: We need to extract geometry from style instead. For esriDynamic there is only one geometry at a time + // If the feature has a geometry or Style has a geometry + if (feature.getGeometry() || Object.keys(style)[0]) { + const geometryType = feature.getGeometry() ? getGeometryType(feature) : (Object.keys(style)[0] as TypeStyleGeometry); // Get the style accordingly to its type and geometry. if (style[geometryType]) {