diff --git a/packages/geoview-core/public/templates/demos/demo-function-event.html b/packages/geoview-core/public/templates/demos/demo-function-event.html
index fb0c44b6659..76051d0f411 100644
--- a/packages/geoview-core/public/templates/demos/demo-function-event.html
+++ b/packages/geoview-core/public/templates/demos/demo-function-event.html
@@ -304,7 +304,7 @@
Events that will generate notifications:
});
// listen to individual layer loaded event
- cgpv.api.maps.Map1.layer.getGeoviewLayerHybrid(LYR_PATH_NON_METAL)?.onIndividualLayerLoaded((sender, payload) => {
+ cgpv.api.maps.Map1.layer.getGeoviewLayer(LYR_PATH_NON_METAL)?.onIndividualLayerLoaded((sender, payload) => {
cgpv.api.maps.Map1.notifications.addNotificationSuccess('Nonmetal mines has finished loading');
console.log(sender.olRootLayer.getSource().getFeatures());
});
@@ -331,22 +331,22 @@ Events that will generate notifications:
// !!
// listen to layer visibility changed event (individual geoview layer)
- cgpv.api.maps.Map1.layer.getGeoviewLayerHybrid(LYR_PATH_UNIQUE)?.onVisibleChanged((sender, payload) => {
+ cgpv.api.maps.Map1.layer.getGeoviewLayer(LYR_PATH_UNIQUE)?.onVisibleChanged((sender, payload) => {
cgpv.api.maps.Map1.notifications.addNotificationSuccess(`${LYR_PATH_UNIQUE} visibility set to ${payload.visible} - individual`);
});
// listen to layer visibility changed event (individual geoview layer)
- cgpv.api.maps.Map1.layer.getGeoviewLayerHybrid(LYR_PATH_GEOCORE)?.onVisibleChanged((sender, payload) => {
+ cgpv.api.maps.Map1.layer.getGeoviewLayer(LYR_PATH_GEOCORE)?.onVisibleChanged((sender, payload) => {
cgpv.api.maps.Map1.notifications.addNotificationSuccess(`layer ${payload.layerPath} visibility set to ${payload.visible} - individual`);
});
// listen to layer opacity changed event
- cgpv.api.maps.Map1.layer.getGeoviewLayerHybrid(LYR_PATH_UNIQUE)?.onLayerOpacityChanged((sender, payload) => {
+ cgpv.api.maps.Map1.layer.getGeoviewLayer(LYR_PATH_UNIQUE)?.onLayerOpacityChanged((sender, payload) => {
cgpv.api.maps.Map1.notifications.addNotificationSuccess(`${payload.layerPath} opacity changed to ${payload.opacity}`);
});
// listen to layer filter applied event
- cgpv.api.maps.Map1.layer.getGeoviewLayerHybrid(LYR_PATH_UNIQUE)?.onLayerFilterApplied((sender, payload) => {
+ cgpv.api.maps.Map1.layer.getGeoviewLayer(LYR_PATH_UNIQUE)?.onLayerFilterApplied((sender, payload) => {
cgpv.api.maps.Map1.notifications.addNotificationSuccess(`Filter ${payload.filter} applied to ${payload.layerPath}`);
});
diff --git a/packages/geoview-core/public/templates/ui-components.html b/packages/geoview-core/public/templates/ui-components.html
index c653d1e7740..a2ad8680901 100644
--- a/packages/geoview-core/public/templates/ui-components.html
+++ b/packages/geoview-core/public/templates/ui-components.html
@@ -173,10 +173,10 @@ Accessing slider value from outside of the core viewer using api event liste
track: 'normal',
onChange: (dates) => {
const field = cgpv.api.maps.UI1.layer
- .getGeoviewLayerHybrid('historical-flood/0')
- .getTemporalDimension('historical-flood/0').field;
+ .getGeoviewLayer('historical-flood/0')
+ .getTemporalDimension().field;
cgpv.api.maps.UI1.layer
- .getGeoviewLayerHybrid('historical-flood/0')
+ .getGeoviewLayer('historical-flood/0')
.applyViewFilter('historical-flood/0', `${field} >= date '${dates[0]}-01-01' and ${field} <= date '${dates[1]}-12-31'`);
},
})
diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/legend-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/legend-event-processor.ts
index 21e16b3aaca..ebc800bc3eb 100644
--- a/packages/geoview-core/src/api/event-processors/event-processor-children/legend-event-processor.ts
+++ b/packages/geoview-core/src/api/event-processors/event-processor-children/legend-event-processor.ts
@@ -126,7 +126,7 @@ export class LegendEventProcessor extends AbstractEventProcessor {
* @returns {Promise} The extent of the feature, if available
*/
static getExtentFromFeatures(mapId: string, layerPath: string, objectIds: string[]): Promise | undefined {
- return MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerPath)?.getExtentFromFeatures(layerPath, objectIds);
+ return MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerPath)?.getExtentFromFeatures(layerPath, objectIds);
}
static getLayerIconImage(layerLegend: TypeLegend | null): TypeLegendLayerItem[] | undefined {
@@ -239,7 +239,7 @@ export class LegendEventProcessor extends AbstractEventProcessor {
if (!layerConfig) return;
// Get the layer
- const layer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(entryLayerPath);
+ const layer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(entryLayerPath);
// Interpret the layer name the best we can
const layerName =
@@ -536,7 +536,7 @@ export class LegendEventProcessor extends AbstractEventProcessor {
const layer = LegendEventProcessor.findLayerByPath(curLayers, layerPath);
if (layer) {
layer.opacity = opacity;
- MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerPath)?.setOpacity(opacity, layerPath);
+ MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerPath)?.setOpacity(opacity);
if (isChild) {
layer.opacityFromParent = opacity;
}
diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
index c2801a1cdfa..148bd5e762a 100644
--- a/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
+++ b/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
@@ -1236,7 +1236,7 @@ export class MapEventProcessor extends AbstractEventProcessor {
* @param {string} layerPath The path of the layer to apply filters to.
*/
static applyLayerFilters(mapId: string, layerPath: string): void {
- const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerPath);
+ const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerPath);
if (geoviewLayer) {
if (
geoviewLayer instanceof WMS ||
@@ -1265,7 +1265,7 @@ export class MapEventProcessor extends AbstractEventProcessor {
* @param {string} layerPath The path for the layer to get filters from.
*/
static getActiveVectorFilters(mapId: string, layerPath: string): (string | undefined)[] | undefined {
- const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerPath);
+ const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerPath);
if (geoviewLayer) {
const initialFilter = this.getInitialFilter(mapId, layerPath);
const tableFilter = DataTableEventProcessor.getTableFilter(mapId, layerPath);
diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts
index b6c9ebe6795..77b5383c050 100644
--- a/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts
+++ b/packages/geoview-core/src/api/event-processors/event-processor-children/time-slider-event-processor.ts
@@ -4,7 +4,6 @@ import {
TimeSliderLayerSet,
TypeTimeSliderValues,
} from '@/core/stores/store-interface-and-intial-values/time-slider-state';
-import { AbstractGeoViewLayer } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { WMS } from '@/geo/layer/geoview-layers/raster/wms';
import { TypeFeatureInfoLayerConfig, TypeLayerEntryConfig, layerEntryIsGroupLayer } from '@/geo/map/map-schema-types';
import { EsriImage } from '@/geo/layer/geoview-layers/raster/esri-image';
@@ -123,16 +122,16 @@ export class TimeSliderEventProcessor extends AbstractEventProcessor {
static getInitialTimeSliderValues(mapId: string, layerConfig: TypeLayerEntryConfig): TypeTimeSliderValues | undefined {
// Get the layer using the map event processor, If no temporal dimension OR layerPath, return undefined
if (!layerConfig.layerPath) return undefined;
- const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerConfig.layerPath)!;
+ const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerConfig.layerPath)!;
// If a group
if (layerEntryIsGroupLayer(layerConfig)) return undefined;
// Cast the layer
- const geoviewLayerCasted = geoviewLayer as AbstractGeoViewLayer | AbstractGVLayer;
+ const geoviewLayerCasted = geoviewLayer as AbstractGVLayer | AbstractGVLayer;
// Get the temporal dimension information
- const temporalDimensionInfo = geoviewLayerCasted.getTemporalDimension(layerConfig.layerPath);
+ const temporalDimensionInfo = geoviewLayerCasted.getTemporalDimension();
// If no temporal dimension information
if (!temporalDimensionInfo || !temporalDimensionInfo.range) return undefined;
@@ -259,7 +258,7 @@ export class TimeSliderEventProcessor extends AbstractEventProcessor {
values: number[]
): void {
// Get the layer using the map event processor
- const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayerHybrid(layerPath)!;
+ const geoviewLayer = MapEventProcessor.getMapViewerLayerAPI(mapId).getGeoviewLayer(layerPath)!;
let filter: string;
if (geoviewLayer instanceof WMS || geoviewLayer instanceof GVWMS) {
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 57f3161654d..dc95933360b 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
@@ -33,7 +33,6 @@ import {
TypeLayerStatus,
TypeStyleGeometry,
CONST_LAYER_ENTRY_TYPES,
- TypeLoadEndListenerType,
TypeFeatureInfoEntry,
codedValueType,
rangeDomainType,
@@ -43,7 +42,6 @@ import {
import { GeoViewLayerCreatedTwiceError } from '@/geo/layer/exceptions/layer-exceptions';
import { getLegendStyles, getFeatureCanvas } from '@/geo/utils/renderer/geoview-renderer';
import { ConfigBaseClass } from '@/core/utils/config/validation-classes/config-base-class';
-import { LayerApi } from '../layer';
import { TypeLegend } from '@/core/stores/store-interface-and-intial-values/layer-state';
import { MapViewer } from '@/geo/map/map-viewer';
@@ -1461,49 +1459,6 @@ export abstract class AbstractGeoViewLayer {
return Promise.resolve();
}
- /**
- * The olLayerAndLoadEndListeners setter method for the ConfigBaseClass class and its descendant classes.
- * @param {AbstractBaseLayerEntryConfig} layerConfig - The layer configuration we are creating a layer for.
- * @param {BaseLayer} olLayer - The OpenLayer we are creating
- * @param {TypeLoadEndListenerType} listenerType - The layer listener type.
- */
- setLayerAndLoadEndListeners(layerConfig: AbstractBaseLayerEntryConfig, olLayer: BaseLayer, listenerType: TypeLoadEndListenerType): void {
- // Precond:
- if (!olLayer) throw new Error(`An OpenLayer must be provided to register listeners. Layer path ${layerConfig.layerPath}`);
- if (!listenerType) throw new Error(`A listenerType must be provided to register listeners. Layer path ${layerConfig.layerPath}`);
-
- // If in old LAYERS_HYBRID_MODE (in the new LAYERS_HYBRID_MODE we want the new classes to handle that)
- if (!LayerApi.LAYERS_HYBRID_MODE) {
- // Group layers have no listener
- if (layerConfig.entryType !== CONST_LAYER_ENTRY_TYPES.GROUP) {
- let loadErrorListener: () => void;
-
- // Definition of the load end listener functions
- const loadEndListener = (): void => {
- // Call the overridable loaded function
- this.onLoaded(layerConfig);
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (olLayer.get('source') as any).un(`${listenerType}loaderror`, loadErrorListener);
- };
-
- loadErrorListener = (): void => {
- // Call the overridable error function
- this.onError(layerConfig);
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (olLayer.get('source') as any).un(`${listenerType}loadend`, loadEndListener);
- };
-
- // Activation of the load end listeners
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (olLayer.get('source') as any).once(`${listenerType}loaderror`, loadErrorListener);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (olLayer.get('source') as any).once(`${listenerType}loadend`, loadEndListener);
- }
- }
- }
-
/**
* Recursively gets all layer entry configs in the GeoView Layer.
* @returns {ConfigBaseClass[]} The list of layer entry configs
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 fd2c669396c..4d33e184d0d 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
@@ -2,7 +2,6 @@
// We have many reassign for layerPath-layerConfig. We keep it global...
import { ImageArcGISRest } from 'ol/source';
import { Options as SourceOptions } from 'ol/source/ImageArcGISRest';
-import { Options as ImageOptions } from 'ol/layer/BaseImage';
import BaseLayer from 'ol/layer/Base';
import { Image as ImageLayer } from 'ol/layer';
import { Coordinate } from 'ol/coordinate';
@@ -287,32 +286,7 @@ export class EsriDynamic extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as ImageLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const imageLayerOptions: ImageOptions = {
- source,
- properties: { layerConfig },
- };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.className !== undefined) imageLayerOptions.className = layerConfig.initialSettings.className;
- if (layerConfig.initialSettings?.extent !== undefined) imageLayerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) imageLayerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) imageLayerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined)
- imageLayerOptions.opacity = layerConfig.initialSettings.states.opacity;
- // If a layer on the map has an initialSettings.visible set to false, its status will never reach the status 'loaded' because
- // nothing is drawn on the map. We must wait until the 'loaded' status is reached to set the visibility to false. The call
- // will be done in the layerConfig.loadedFunction() which is called right after the 'loaded' signal.
-
- // Create the OpenLayer layer
- olLayer = new ImageLayer(imageLayerOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'image');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-image.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-image.ts
index e022499e394..28d35c362ee 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-image.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/esri-image.ts
@@ -1,7 +1,6 @@
import { ImageArcGISRest } from 'ol/source';
import { Options as SourceOptions } from 'ol/source/ImageArcGISRest';
import BaseLayer from 'ol/layer/Base';
-import { Options as ImageOptions } from 'ol/layer/BaseImage';
import { Image as ImageLayer } from 'ol/layer';
import { Extent } from 'ol/extent';
@@ -336,32 +335,7 @@ export class EsriImage extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as ImageLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const imageLayerOptions: ImageOptions = {
- source,
- properties: { layerConfig },
- };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.className !== undefined) imageLayerOptions.className = layerConfig.initialSettings.className;
- if (layerConfig.initialSettings?.extent !== undefined) imageLayerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) imageLayerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) imageLayerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined)
- imageLayerOptions.opacity = layerConfig.initialSettings.states.opacity;
- // If a layer on the map has an initialSettings.visible set to false, its status will never reach the status 'loaded' because
- // nothing is drawn on the map. We must wait until the 'loaded' status is reached to set the visibility to false. The call
- // will be done in the layerConfig.loadedFunction() which is called right after the 'loaded' signal.
-
- // Create the OpenLayer layer
- olLayer = new ImageLayer(imageLayerOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'image');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/image-static.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/image-static.ts
index 2c66ce5871b..becfd9836da 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/image-static.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/image-static.ts
@@ -2,7 +2,6 @@ import axios from 'axios';
import Static, { Options as SourceOptions } from 'ol/source/ImageStatic';
import BaseLayer from 'ol/layer/Base';
-import { Options as ImageOptions } from 'ol/layer/BaseImage';
import ImageLayer from 'ol/layer/Image';
import { Extent } from 'ol/extent';
@@ -274,27 +273,7 @@ export class ImageStatic extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as ImageLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const staticImageOptions: ImageOptions = { source };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.extent !== undefined) staticImageOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) staticImageOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) staticImageOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined)
- staticImageOptions.opacity = layerConfig.initialSettings.states.opacity;
- // GV IMPORTANT: The initialSettings.visible flag must be set in the layerConfig.loadedFunction otherwise the layer will stall
- // GV in the 'loading' state if the flag value is false.
-
- // Create the OpenLayer layer
- olLayer = new ImageLayer(staticImageOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'image');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/vector-tiles.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/vector-tiles.ts
index b79fabd7ef7..85602f5ae49 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/vector-tiles.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/vector-tiles.ts
@@ -1,7 +1,6 @@
import BaseLayer from 'ol/layer/Base';
import TileLayer from 'ol/layer/Tile';
import VectorTileLayer from 'ol/layer/VectorTile';
-import { Options as TileOptions } from 'ol/layer/BaseTile';
import VectorTileSource, { Options as SourceOptions } from 'ol/source/VectorTile';
import TileGrid, { Options as TileGridOptions } from 'ol/tilegrid/TileGrid';
import { Extent } from 'ol/extent';
@@ -213,30 +212,7 @@ export class VectorTiles extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as VectorTileLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const tileLayerOptions: TileOptions = { source };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.className !== undefined) tileLayerOptions.className = layerConfig.initialSettings.className;
- if (layerConfig.initialSettings?.extent !== undefined) tileLayerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) tileLayerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) tileLayerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined) tileLayerOptions.opacity = layerConfig.initialSettings.states.opacity;
- // GV IMPORTANT: The initialSettings.visible flag must be set in the layerConfig.loadedFunction otherwise the layer will stall
- // GV in the 'loading' state if the flag value is false.
-
- // TODO remove after demoing again
- const declutter = this.mapId !== 'LYR2';
-
- // Create the OpenLayer layer
- olLayer = new VectorTileLayer({ ...tileLayerOptions, declutter });
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'tile');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/wms.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/wms.ts
index 00cb4f736d1..65a6ed7fec3 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/wms.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/wms.ts
@@ -6,7 +6,6 @@ import ImageLayer from 'ol/layer/Image';
import { Coordinate } from 'ol/coordinate';
import { Pixel } from 'ol/pixel';
import BaseLayer from 'ol/layer/Base';
-import { Options as ImageOptions } from 'ol/layer/BaseImage';
import { ImageWMS } from 'ol/source';
import { Options as SourceOptions } from 'ol/source/ImageWMS';
import WMSCapabilities from 'ol/format/WMSCapabilities';
@@ -552,31 +551,7 @@ export class WMS extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as ImageLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const imageLayerOptions: ImageOptions = {
- source,
- properties: { layerCapabilities, layerConfig },
- };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.className !== undefined) imageLayerOptions.className = layerConfig.initialSettings.className;
- if (layerConfig.initialSettings?.extent !== undefined) imageLayerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) imageLayerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) imageLayerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined)
- imageLayerOptions.opacity = layerConfig.initialSettings.states.opacity;
- // GV IMPORTANT: The initialSettings.visible flag must be set in the layerConfig.loadedFunction otherwise the layer will stall
- // GV in the 'loading' state if the flag value is false.
-
- // Create the OpenLayer layer
- olLayer = new ImageLayer(imageLayerOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'image');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/raster/xyz-tiles.ts b/packages/geoview-core/src/geo/layer/geoview-layers/raster/xyz-tiles.ts
index c7776b9b9e3..46fbac200ea 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/raster/xyz-tiles.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/raster/xyz-tiles.ts
@@ -1,6 +1,5 @@
import BaseLayer from 'ol/layer/Base';
import TileLayer from 'ol/layer/Tile';
-import { Options as TileOptions } from 'ol/layer/BaseTile';
import XYZ, { Options as SourceOptions } from 'ol/source/XYZ';
import TileGrid, { Options as TileGridOptions } from 'ol/tilegrid/TileGrid';
import { Extent } from 'ol/extent';
@@ -213,27 +212,7 @@ export class XYZTiles extends AbstractGeoViewRaster {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as TileLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- const tileLayerOptions: TileOptions = { source };
- // layerConfig.initialSettings cannot be undefined because config-validation set it to {} if it is undefined.
- if (layerConfig.initialSettings?.className !== undefined) tileLayerOptions.className = layerConfig.initialSettings.className;
- if (layerConfig.initialSettings?.extent !== undefined) tileLayerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) tileLayerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) tileLayerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined) tileLayerOptions.opacity = layerConfig.initialSettings.states.opacity;
- // GV IMPORTANT: The initialSettings.visible flag must be set in the layerConfig.loadedFunction otherwise the layer will stall
- // GV in the 'loading' state if the flag value is false.
-
- // Create the OpenLayer layer
- olLayer = new TileLayer(tileLayerOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'tile');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/vector/abstract-geoview-vector.ts b/packages/geoview-core/src/geo/layer/geoview-layers/vector/abstract-geoview-vector.ts
index 9b74f5d1d2e..53e2fa2f71c 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/vector/abstract-geoview-vector.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/vector/abstract-geoview-vector.ts
@@ -4,7 +4,6 @@ import Feature from 'ol/Feature';
import { Vector as VectorSource } from 'ol/source';
import { Options as SourceOptions } from 'ol/source/Vector';
import { VectorImage as VectorLayer } from 'ol/layer';
-import { Options as VectorLayerOptions } from 'ol/layer/VectorImage';
import { GeoJSON as FormatGeoJSON } from 'ol/format';
import { all, bbox } from 'ol/loadingstrategy';
import { ReadOptions } from 'ol/format/Feature';
@@ -34,7 +33,6 @@ import { logger } from '@/core/utils/logger';
import { VectorLayerEntryConfig } from '@/core/utils/config/validation-classes/vector-layer-entry-config';
import { AbstractBaseLayerEntryConfig } from '@/core/utils/config/validation-classes/abstract-base-layer-entry-config';
import { analyzeLayerFilter } from '@/geo/utils/renderer/geoview-renderer';
-import { AbstractGVVector } from '../../gv-layers/vector/abstract-gv-vector';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';
import { Projection } from '@/geo/utils/projection';
import { getMinOrMaxExtents } from '@/geo/utils/utilities';
@@ -335,9 +333,6 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
*/
// GV Layers Refactoring - Obsolete (this is bridging between config and layers, okay)
protected createVectorLayer(layerConfig: VectorLayerEntryConfig, vectorSource: VectorSource): VectorLayer {
- // Get the style label
- const label = layerConfig.layerName || layerConfig.layerId;
-
// GV Time to request an OpenLayers layer!
const requestResult = this.emitLayerRequesting({ config: layerConfig, source: vectorSource });
@@ -346,38 +341,7 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
if (requestResult.length > 0) {
// Get the OpenLayer that was created
olLayer = requestResult[0] as VectorLayer;
- }
-
- // If no olLayer was obtained
- if (!olLayer) {
- // We're working in old LAYERS_HYBRID_MODE (in the new mode the code below is handled in the new classes)
- // Create the vector layer options.
- const layerOptions: VectorLayerOptions = {
- properties: { layerConfig },
- source: vectorSource,
- style: (feature) => {
- return AbstractGVVector.calculateStyleForFeature(
- this,
- feature,
- label,
- layerConfig.layerPath,
- layerConfig.filterEquation,
- layerConfig.legendFilterIsOff
- );
- },
- };
-
- if (layerConfig.initialSettings?.extent !== undefined) layerOptions.extent = layerConfig.initialSettings.extent;
- if (layerConfig.initialSettings?.maxZoom !== undefined) layerOptions.maxZoom = layerConfig.initialSettings.maxZoom;
- if (layerConfig.initialSettings?.minZoom !== undefined) layerOptions.minZoom = layerConfig.initialSettings.minZoom;
- if (layerConfig.initialSettings?.states?.opacity !== undefined) layerOptions.opacity = layerConfig.initialSettings.states.opacity;
-
- // Create the OpenLayer layer
- olLayer = new VectorLayer(layerOptions);
-
- // Hook the loaded event
- this.setLayerAndLoadEndListeners(layerConfig, olLayer, 'features');
- }
+ } else throw new Error('Error on layerRequesting event');
// GV Time to emit about the layer creation!
this.emitLayerCreation({ config: layerConfig, layer: olLayer });
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..bb08dde1bcb 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
@@ -307,10 +307,7 @@ export class GVEsriDynamic extends AbstractGVRaster {
static #countFieldOfTheSameValue(styleSettings: TypeLayerStyleSettings): TypeFieldOfTheSameValue[][] {
return styleSettings.info.reduce(
(counter, styleEntry): TypeFieldOfTheSameValue[][] => {
- if (
- (styleEntry.visible === false && styleSettings.info[styleSettings.info.length - 1].visible !== false) ||
- (styleEntry.visible !== false && styleSettings.info[styleSettings.info.length - 1].visible === false)
- ) {
+ if (styleEntry.visible !== false) {
styleEntry.values.forEach((styleValue, i) => {
const valueExist = counter[i].find((counterEntry) => counterEntry.value === styleValue);
if (valueExist) valueExist.nbOccurence++;
@@ -545,10 +542,7 @@ export class GVEsriDynamic extends AbstractGVRaster {
): TypeQueryTree {
const queryTree: TypeQueryTree = [];
styleSettings.info.forEach((styleEntry) => {
- if (
- (styleEntry.visible === false && styleSettings.info[styleSettings.info.length - 1].visible !== false) ||
- (styleEntry.visible !== false && styleSettings.info[styleSettings.info.length - 1].visible === false)
- ) {
+ if (styleEntry.visible !== false) {
let levelToSearch = queryTree;
for (let i = 0; i < fieldOrder.length; i++) {
if (fieldOfTheSameValue[fieldOrder[i]].find((field) => field.value === styleEntry.values[fieldOrder[i]])) {
diff --git a/packages/geoview-core/src/geo/layer/gv-layers/vector/gv-vector-tiles.ts b/packages/geoview-core/src/geo/layer/gv-layers/vector/gv-vector-tiles.ts
index fb418da78a1..7a039e89fa3 100644
--- a/packages/geoview-core/src/geo/layer/gv-layers/vector/gv-vector-tiles.ts
+++ b/packages/geoview-core/src/geo/layer/gv-layers/vector/gv-vector-tiles.ts
@@ -30,7 +30,8 @@ export class GVVectorTiles extends AbstractGVVectorTile {
AbstractGVVectorTile.initOptionsWithInitialSettings(tileLayerOptions, layerConfig);
// Create and set the OpenLayer layer
- this.olLayer = new VectorTileLayer({ ...tileLayerOptions });
+ const declutter = true;
+ this.olLayer = new VectorTileLayer({ ...tileLayerOptions, declutter });
}
/**
diff --git a/packages/geoview-core/src/geo/layer/layer-sets/abstract-layer-set.ts b/packages/geoview-core/src/geo/layer/layer-sets/abstract-layer-set.ts
index 0b9e30c1237..e8bea36988f 100644
--- a/packages/geoview-core/src/geo/layer/layer-sets/abstract-layer-set.ts
+++ b/packages/geoview-core/src/geo/layer/layer-sets/abstract-layer-set.ts
@@ -138,7 +138,7 @@ export abstract class AbstractLayerSet {
}
// Get the layer
- const layer = this.layerApi.getGeoviewLayerHybrid(layerConfig.layerPath);
+ const layer = this.layerApi.getGeoviewLayer(layerConfig.layerPath);
// If the layer could be found
if (layer) {
@@ -228,7 +228,7 @@ export abstract class AbstractLayerSet {
// TODO: Refactor - Layers refactoring. Remove the layerPath parameter once hybrid work is done
// Override this function to perform registration condition logic in the inherited classes
// By default, a layer-set always registers layers except when they are group layers
- if (this.layerApi.getGeoviewLayerHybrid(layerPath)?.getLayerConfig(layerPath)?.entryType === 'group') {
+ if (this.layerApi.getGeoviewLayer(layerPath)?.getLayerConfig()?.entryType === 'group') {
// Skip groups
return false;
}
@@ -277,7 +277,7 @@ export abstract class AbstractLayerSet {
this.onUnregisterLayerConfig(this.layerApi.getLayerEntryConfig(layerPath));
// Call the unregistration function for the layer-set. This method is different for each child.
- this.onUnregisterLayer(this.layerApi.getGeoviewLayerHybrid(layerPath));
+ this.onUnregisterLayer(this.layerApi.getGeoviewLayer(layerPath));
// Delete from the store
this.onDeleteFromStore(layerPath);
diff --git a/packages/geoview-core/src/geo/layer/layer-sets/all-feature-info-layer-set.ts b/packages/geoview-core/src/geo/layer/layer-sets/all-feature-info-layer-set.ts
index e2d539d7e43..1c2099afb9d 100644
--- a/packages/geoview-core/src/geo/layer/layer-sets/all-feature-info-layer-set.ts
+++ b/packages/geoview-core/src/geo/layer/layer-sets/all-feature-info-layer-set.ts
@@ -107,7 +107,7 @@ export class AllFeatureInfoLayerSet extends AbstractLayerSet {
if (!this.resultSet[layerPath].eventListenerEnabled) return Promise.resolve();
// Get the layer config and layer associated with the layer path
- const layer = this.layerApi.getGeoviewLayerHybrid(layerPath);
+ const layer = this.layerApi.getGeoviewLayer(layerPath);
// If layer was found
if (layer && (layer instanceof AbstractGeoViewLayer || layer instanceof AbstractGVLayer)) {
diff --git a/packages/geoview-core/src/geo/layer/layer-sets/feature-info-layer-set.ts b/packages/geoview-core/src/geo/layer/layer-sets/feature-info-layer-set.ts
index 7fccf9eb363..e764919fd22 100644
--- a/packages/geoview-core/src/geo/layer/layer-sets/feature-info-layer-set.ts
+++ b/packages/geoview-core/src/geo/layer/layer-sets/feature-info-layer-set.ts
@@ -131,7 +131,7 @@ export class FeatureInfoLayerSet extends AbstractLayerSet {
if (!this.resultSet[layerPath].eventListenerEnabled) return;
// Get the layer config and layer associated with the layer path
- const layer = this.layerApi.getGeoviewLayerHybrid(layerPath);
+ const layer = this.layerApi.getGeoviewLayer(layerPath);
// If layer was found
if (layer && (layer instanceof AbstractGeoViewLayer || layer instanceof AbstractGVLayer)) {
diff --git a/packages/geoview-core/src/geo/layer/layer-sets/hover-feature-info-layer-set.ts b/packages/geoview-core/src/geo/layer/layer-sets/hover-feature-info-layer-set.ts
index 676f50fbead..7ef4716b420 100644
--- a/packages/geoview-core/src/geo/layer/layer-sets/hover-feature-info-layer-set.ts
+++ b/packages/geoview-core/src/geo/layer/layer-sets/hover-feature-info-layer-set.ts
@@ -106,7 +106,7 @@ export class HoverFeatureInfoLayerSet extends AbstractLayerSet {
if (!this.resultSet[layerPath].eventListenerEnabled) return;
// Get the layer config and layer associated with the layer path
- const layer = this.layerApi.getGeoviewLayerHybrid(layerPath);
+ const layer = this.layerApi.getGeoviewLayer(layerPath);
// If layer was found
if (layer && (layer instanceof AbstractGeoViewLayer || layer instanceof AbstractGVLayer)) {
diff --git a/packages/geoview-core/src/geo/layer/layer-sets/legends-layer-set.ts b/packages/geoview-core/src/geo/layer/layer-sets/legends-layer-set.ts
index 8fcef23a855..c7d9aadd369 100644
--- a/packages/geoview-core/src/geo/layer/layer-sets/legends-layer-set.ts
+++ b/packages/geoview-core/src/geo/layer/layer-sets/legends-layer-set.ts
@@ -135,8 +135,8 @@ export class LegendsLayerSet extends AbstractLayerSet {
*/
#checkQueryLegend(layerPath: string, forced: boolean): void {
// Get the layer
- const layer = this.layerApi.getGeoviewLayerHybrid(layerPath);
- const layerConfig = layer?.getLayerConfig(layerPath);
+ const layer = this.layerApi.getGeoviewLayer(layerPath);
+ const layerConfig = layer?.getLayerConfig();
// If the layer legend should be queried (and not already querying).
// GV Gotta make sure that we're not already querying, because EsriImage layers, for example, adjust the
diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts
index 358071f6c3b..93f87f7b654 100644
--- a/packages/geoview-core/src/geo/layer/layer.ts
+++ b/packages/geoview-core/src/geo/layer/layer.ts
@@ -164,11 +164,6 @@ export class LayerApi {
// Maximum time duration to wait when registering a layer for the time slider
static #MAX_WAIT_TIME_SLIDER_REGISTRATION = 20000;
- // ************************************************************
- // INDICATES IF USING HYBRID MODE WITH THE NEW GVLAYERS CLASSES
- // ************************************************************
- static LAYERS_HYBRID_MODE = false;
-
/**
* Initializes layer types and listen to add/remove layer events from outside
* @param {MapViewer} mapViewer - A reference to the map viewer
@@ -195,101 +190,31 @@ export class LayerApi {
/**
* Gets the GeoView Layer Ids.
- * Note: those are different than the layer paths.
- * @returns {string[]} The GeoView Layer Ids
+ * @returns The ids of the new Geoview Layers
*/
getGeoviewLayerIds(): string[] {
- return Object.keys(this.#geoviewLayers);
+ return Object.keys(this.#gvLayers);
}
/**
* Gets all GeoView Layers
- * @returns {AbstractGeoViewLayer[]} The GeoView Layers
+ * @returns The list of new Geoview Layers
*/
- getGeoviewLayers(): AbstractGeoViewLayer[] {
- return Object.values(this.#geoviewLayers);
+ getGeoviewLayers(): AbstractBaseLayer[] {
+ return Object.values(this.#gvLayers);
}
/**
* Returns the GeoView instance associated to the layer path.
* The first element of the layerPath is the geoviewLayerId and this function will
* work with either the geoViewLayerId or the layerPath.
- * @param {string} layerPath - The layer path (or in this case the geoviewLayerId) of the layer's configuration.
- * @returns {AbstractGeoViewLayer} Returns the geoview instance associated to the layer path.
- */
- getGeoviewLayer(layerPath: string): AbstractGeoViewLayer | undefined {
- // TODO: Refactor - This function will be replaced to return the new layer classes model
- // The first element of the layerPath is the geoviewLayerId
- return this.#geoviewLayers[layerPath.split('/')[0]];
- }
-
- /**
- * Temporary new function for migration purposes, replacing getGeoviewLayerIds
- * @returns The ids of the new Geoview Layers
- */
- getGeoviewLayerIdsNew(): string[] {
- return Object.keys(this.#gvLayers);
- }
-
- /**
- * Temporary new function for migration purposes, replacing getGeoviewLayers
- * @returns The list of new Geoview Layers
- */
- getGeoviewLayersNew(): AbstractBaseLayer[] {
- return Object.values(this.#gvLayers);
- }
-
- /**
- * New function for migration purposes, replacing getGeoviewLayer
* @param {string} layerPath - The layer path
* @returns The new Geoview Layer
*/
- getGeoviewLayerNew(layerPath: string): AbstractBaseLayer | undefined {
+ getGeoviewLayer(layerPath: string): AbstractBaseLayer | undefined {
return this.#gvLayers[layerPath];
}
- /**
- * Hybrid function for migration purposes, bridging the gap between getGeoviewLayer and getGeoviewLayerNew
- * @param {string} layerPath - The layer path
- * @returns The new Geoview Layer
- */
- getGeoviewLayerIdsHybrid(): string[] {
- // TODO: Refactor - This function will be replaced to jump to the new layer classes model
- // If new mode
- if (LayerApi.LAYERS_HYBRID_MODE) return this.getGeoviewLayerIdsNew();
-
- // Old mode
- return this.getGeoviewLayerIds();
- }
-
- /**
- * Hybrid function for migration purposes, bridging the gap between getGeoviewLayer and getGeoviewLayerNew
- * @param {string} layerPath - The layer path
- * @returns The new Geoview Layer
- */
- getGeoviewLayersHybrid(): AbstractGeoViewLayer[] | AbstractBaseLayer[] {
- // TODO: Refactor - This function will be replaced to jump to the new layer classes model
- // If new mode
- if (LayerApi.LAYERS_HYBRID_MODE) return this.getGeoviewLayersNew();
-
- // Old mode
- return this.getGeoviewLayers();
- }
-
- /**
- * Hybrid function for migration purposes, bridging the gap between getGeoviewLayer and getGeoviewLayerNew
- * @param {string} layerPath - The layer path
- * @returns The new Geoview Layer or the old Geoview Layer
- */
- getGeoviewLayerHybrid(layerPath: string): AbstractGeoViewLayer | AbstractBaseLayer | undefined {
- // TODO: Refactor - This function will be replaced to jump to the new layer classes model
- // If new mode
- if (LayerApi.LAYERS_HYBRID_MODE) return this.getGeoviewLayerNew(layerPath);
-
- // Old mode
- return this.getGeoviewLayer(layerPath);
- }
-
/**
* Verifies if a layer is registered. Returns true if registered.
* @param {string} layerPath - The layer path to check.
@@ -348,11 +273,8 @@ export class LayerApi {
* @returns {BaseLayer} Returns the geoview instance associated to the layer path.
*/
getOLLayer(layerPath: string): BaseLayer | undefined {
- // If new mode, get the OpenLayer layer as part of the new GVLayer design
- if (LayerApi.LAYERS_HYBRID_MODE) return this.getGeoviewLayerNew(layerPath)?.getOLLayer();
-
- // Old mode, get the OpenLayer layer stored in the dictionary
- return this.#olLayers[layerPath];
+ // Get the OpenLayer layer as part of the new GVLayer design
+ return this.getGeoviewLayer(layerPath)?.getOLLayer();
}
/**
@@ -679,14 +601,12 @@ export class LayerApi {
// Log
logger.logDebug(`Requesting layer for ${event.config.layerPath} on map ${this.getMapId()}`, event.config);
- // If new layers mode, create the corresponding GVLayer
- if (LayerApi.LAYERS_HYBRID_MODE) {
- const gvLayer = this.#createGVLayer(this.getMapId(), geoviewLayer, event.source, event.config, event.extraConfig);
- if (gvLayer) return gvLayer.getOLLayer();
+ // Create the corresponding GVLayer
+ const gvLayer = this.#createGVLayer(this.getMapId(), geoviewLayer, event.source, event.config, event.extraConfig);
+ if (gvLayer) {
+ return gvLayer.getOLLayer();
}
-
- // Don't provide any layer, working in old mode
- return undefined;
+ throw new Error('Error, no corresponding GV layer');
});
// Register hook when an OpenLayer layer has been created
@@ -698,13 +618,10 @@ export class LayerApi {
// This is tempting to put in the onLayerRequesting handler, but this one here also traps the LayerGroups
this.#olLayers[event.config.layerPath] = event.layer;
- // If new layers mode, create the corresponding GVLayer
- if (LayerApi.LAYERS_HYBRID_MODE) {
- // If group layer was created
- if (event.layer instanceof LayerGroup && event.config instanceof GroupLayerEntryConfig) {
- // Create the GV Group Layer
- this.#createGVGroupLayer(this.getMapId(), event.layer, event.config);
- }
+ // Create the corresponding GVLayer. If group layer was created
+ if (event.layer instanceof LayerGroup && event.config instanceof GroupLayerEntryConfig) {
+ // Create the GV Group Layer
+ this.#createGVGroupLayer(this.getMapId(), event.layer, event.config);
}
});
@@ -821,63 +738,57 @@ export class LayerApi {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
extraConfig?: any
): AbstractGVLayer | undefined {
- // If new mode
- let metadata;
- let layerMetadata;
- let timeDimension;
- let style;
- if (LayerApi.LAYERS_HYBRID_MODE) {
- // Get the metadata and the time dimension information as processed
- metadata = geoviewLayer.metadata;
- layerMetadata = geoviewLayer.getLayerMetadata(layerConfig.layerPath);
- timeDimension = geoviewLayer.getTemporalDimension(layerConfig.layerPath);
- style = geoviewLayer.getStyle(layerConfig.layerPath);
-
- // HACK: INJECT CONFIGURATION STUFF PRETENDNG THEY WERE PROCESSED
- // GV Keep this code commented in the source base for now
- // if (layerConfig.layerPath === 'esriFeatureLYR5/0') {
- // metadata = LayerMockup.configTop100Metadata();
- // } else if (layerConfig.layerPath === 'nonmetalmines/5') {
- // metadata = LayerMockup.configNonMetalMetadata();
- // } else if (layerConfig.layerPath === 'airborne_radioactivity/1') {
- // metadata = LayerMockup.configAirborneMetadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/polygons.json') {
- // metadata = LayerMockup.configPolygonsMetadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/lines.json') {
- // metadata = LayerMockup.configLinesMetadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/icon_points.json') {
- // metadata = LayerMockup.configIconPointsMetadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points.json') {
- // metadata = LayerMockup.configPointsMetadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_1.json') {
- // metadata = LayerMockup.configPoints1Metadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_2.json') {
- // metadata = LayerMockup.configPoints2Metadata();
- // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_3.json') {
- // metadata = LayerMockup.configPoints3Metadata();
- // } else if (layerConfig.layerPath === 'historical-flood/0') {
- // metadata = LayerMockup.configHistoricalFloodMetadata();
- // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
- // } else if (layerConfig.layerPath === 'uniqueValueId/1') {
- // metadata = LayerMockup.configCESIMetadata();
- // // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
- // } else if (layerConfig.layerPath === 'esriFeatureLYR1/0') {
- // metadata = LayerMockup.configTemporalTestBedMetadata();
- // // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
- // } else if (layerConfig.layerPath === 'wmsLYR1-spatiotemporel/RADAR_1KM_RSNO') {
- // metadata = LayerMockup.configRadarMetadata();
- // timeDimension = LayerMockup.configRadarTemporalDimension();
- // } else if (layerConfig.layerPath === 'MSI/msi-94-or-more') {
- // metadata = LayerMockup.configMSIMetadata();
- // timeDimension = LayerMockup.configMSITemporalDimension();
- // }
-
- // If good config
- if (layerConfig instanceof AbstractBaseLayerEntryConfig) {
- // If any metadata
- if (metadata) layerConfig.setServiceMetadata(metadata);
- if (layerMetadata) layerConfig.setLayerMetadata(layerMetadata);
- }
+ // Get the metadata and the time dimension information as processed
+ // GV: We use the old abstractGeoviewLayer format as the GV layer is not created yet
+ const { metadata } = geoviewLayer;
+ const layerMetadata = geoviewLayer.getLayerMetadata(layerConfig.layerPath);
+ const timeDimension = geoviewLayer.getTemporalDimension(layerConfig.layerPath);
+ const style = geoviewLayer.getStyle(layerConfig.layerPath);
+
+ // HACK: INJECT CONFIGURATION STUFF PRETENDNG THEY WERE PROCESSED
+ // GV Keep this code commented in the source base for now
+ // if (layerConfig.layerPath === 'esriFeatureLYR5/0') {
+ // metadata = LayerMockup.configTop100Metadata();
+ // } else if (layerConfig.layerPath === 'nonmetalmines/5') {
+ // metadata = LayerMockup.configNonMetalMetadata();
+ // } else if (layerConfig.layerPath === 'airborne_radioactivity/1') {
+ // metadata = LayerMockup.configAirborneMetadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/polygons.json') {
+ // metadata = LayerMockup.configPolygonsMetadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/lines.json') {
+ // metadata = LayerMockup.configLinesMetadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/icon_points.json') {
+ // metadata = LayerMockup.configIconPointsMetadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points.json') {
+ // metadata = LayerMockup.configPointsMetadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_1.json') {
+ // metadata = LayerMockup.configPoints1Metadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_2.json') {
+ // metadata = LayerMockup.configPoints2Metadata();
+ // } else if (layerConfig.layerPath === 'geojsonLYR1/geojsonLYR1/point-feature-group/points_3.json') {
+ // metadata = LayerMockup.configPoints3Metadata();
+ // } else if (layerConfig.layerPath === 'historical-flood/0') {
+ // metadata = LayerMockup.configHistoricalFloodMetadata();
+ // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
+ // } else if (layerConfig.layerPath === 'uniqueValueId/1') {
+ // metadata = LayerMockup.configCESIMetadata();
+ // // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
+ // } else if (layerConfig.layerPath === 'esriFeatureLYR1/0') {
+ // metadata = LayerMockup.configTemporalTestBedMetadata();
+ // // timeDimension = LayerMockup.configHistoricalFloodTemporalDimension();
+ // } else if (layerConfig.layerPath === 'wmsLYR1-spatiotemporel/RADAR_1KM_RSNO') {
+ // metadata = LayerMockup.configRadarMetadata();
+ // timeDimension = LayerMockup.configRadarTemporalDimension();
+ // } else if (layerConfig.layerPath === 'MSI/msi-94-or-more') {
+ // metadata = LayerMockup.configMSIMetadata();
+ // timeDimension = LayerMockup.configMSITemporalDimension();
+ // }
+
+ // If good config
+ if (layerConfig instanceof AbstractBaseLayerEntryConfig) {
+ // If any metadata
+ if (metadata) layerConfig.setServiceMetadata(metadata);
+ if (layerMetadata) layerConfig.setLayerMetadata(layerMetadata);
}
// Create the right GV Layer based on the OLLayer and config type
@@ -1040,7 +951,7 @@ export class LayerApi {
try {
// Wait until the layer is loaded (or processed?)
await whenThisThen(() => layerConfig.isGreaterThanOrEqualTo('processed'), LayerApi.#MAX_WAIT_TIME_SLIDER_REGISTRATION);
- const geoviewLayer = this.getGeoviewLayerHybrid(layerConfig.layerPath);
+ const geoviewLayer = this.getGeoviewLayer(layerConfig.layerPath);
// If the layer is loaded AND flag is true to use time dimension, continue
if ((geoviewLayer instanceof AbstractGeoViewLayer || geoviewLayer instanceof AbstractGVLayer) && geoviewLayer.getIsTimeAware()) {
@@ -1126,14 +1037,14 @@ export class LayerApi {
checkLayerStatus(
status: TypeLayerStatus,
layerEntriesToCheck: MapConfigLayerEntry[] | undefined,
- callbackNotGood?: (geoviewLayer: AbstractGeoViewLayer) => void
+ callbackNotGood?: (geoviewLayer: AbstractBaseLayer) => void
): [boolean, number] {
// If no layer entries at all or there are layer entries and there are geoview layers to check
let allGood = layerEntriesToCheck?.length === 0 || Object.keys(this.#geoviewLayers).length > 0;
// For each registered layer entry
this.getGeoviewLayers().forEach((geoviewLayer) => {
- const layerIsGood = geoviewLayer.allLayerStatusAreGreaterThanOrEqualTo(status);
+ const layerIsGood = ConfigBaseClass.allLayerStatusAreGreaterThanOrEqualTo(status, [geoviewLayer.getLayerConfig()]);
if (!layerIsGood) {
// Callback about it
callbackNotGood?.(geoviewLayer);
@@ -1178,7 +1089,7 @@ export class LayerApi {
// FIX.MECONT: Therefore, this can't remove the layers that failed due to for example bad metadataUrl.
// FIX.MECONT: To effectively remove all layers in the UI boxes, this removal process should be using the 'LayerConfigs' (and the layer paths). Not the 'Layer' classes.
// For each Geoview layers
- this.getGeoviewLayersHybrid().forEach((geoviewLayer) => {
+ this.getGeoviewLayers().forEach((geoviewLayer) => {
// Remove it
this.removeLayerUsingPath(geoviewLayer.getGeoviewLayerId());
});
@@ -1271,27 +1182,27 @@ export class LayerApi {
*/
highlightLayer(layerPath: string): void {
this.removeHighlightLayer();
- const theLayerMain = this.getGeoviewLayerHybrid(layerPath);
+ const theLayerMain = this.getGeoviewLayer(layerPath);
- this.#highlightedLayer = { layerPath, originalOpacity: theLayerMain?.getOpacity(layerPath) };
- theLayerMain?.setOpacity(1, layerPath);
+ this.#highlightedLayer = { layerPath, originalOpacity: theLayerMain?.getOpacity() };
+ theLayerMain?.setOpacity(1);
// If it is a group layer, highlight sublayers
if (layerEntryIsGroupLayer(this.#layerEntryConfigs[layerPath])) {
Object.keys(this.#layerEntryConfigs).forEach((registeredLayerPath) => {
- const theLayer = this.getGeoviewLayerHybrid(registeredLayerPath)!;
+ const theLayer = this.getGeoviewLayer(registeredLayerPath)!;
if (!registeredLayerPath.startsWith(layerPath) && !layerEntryIsGroupLayer(this.#layerEntryConfigs[registeredLayerPath])) {
- const otherOpacity = theLayer.getOpacity(registeredLayerPath);
- theLayer.setOpacity((otherOpacity || 1) * 0.25, registeredLayerPath);
+ const otherOpacity = theLayer.getOpacity();
+ theLayer.setOpacity((otherOpacity || 1) * 0.25);
} else this.getOLLayer(registeredLayerPath)!.setZIndex(999);
});
} else {
Object.keys(this.#layerEntryConfigs).forEach((registeredLayerPath) => {
- const theLayer = this.getGeoviewLayerHybrid(registeredLayerPath)!;
+ const theLayer = this.getGeoviewLayer(registeredLayerPath)!;
// check for otherOlLayer is undefined. It would be undefined if a layer status is error
if (registeredLayerPath !== layerPath && !layerEntryIsGroupLayer(this.#layerEntryConfigs[registeredLayerPath])) {
- const otherOpacity = theLayer.getOpacity(registeredLayerPath);
- theLayer.setOpacity((otherOpacity || 1) * 0.25, registeredLayerPath);
+ const otherOpacity = theLayer.getOpacity();
+ theLayer.setOpacity((otherOpacity || 1) * 0.25);
}
});
this.getOLLayer(layerPath)!.setZIndex(999);
@@ -1307,20 +1218,20 @@ export class LayerApi {
const { layerPath, originalOpacity } = this.#highlightedLayer;
if (layerEntryIsGroupLayer(this.#layerEntryConfigs[layerPath])) {
Object.keys(this.#layerEntryConfigs).forEach((registeredLayerPath) => {
- const theLayer = this.getGeoviewLayerHybrid(registeredLayerPath)!;
+ const theLayer = this.getGeoviewLayer(registeredLayerPath)!;
if (!registeredLayerPath.startsWith(layerPath) && !layerEntryIsGroupLayer(this.#layerEntryConfigs[registeredLayerPath])) {
- const otherOpacity = theLayer.getOpacity(registeredLayerPath);
- theLayer.setOpacity(otherOpacity ? otherOpacity * 4 : 1, registeredLayerPath);
- } else theLayer.setOpacity(originalOpacity || 1, registeredLayerPath);
+ const otherOpacity = theLayer.getOpacity();
+ theLayer.setOpacity(otherOpacity ? otherOpacity * 4 : 1);
+ } else theLayer.setOpacity(originalOpacity || 1);
});
} else {
Object.keys(this.#layerEntryConfigs).forEach((registeredLayerPath) => {
// check for otherOlLayer is undefined. It would be undefined if a layer status is error
- const theLayer = this.getGeoviewLayerHybrid(registeredLayerPath)!;
+ const theLayer = this.getGeoviewLayer(registeredLayerPath)!;
if (registeredLayerPath !== layerPath && !layerEntryIsGroupLayer(this.#layerEntryConfigs[registeredLayerPath])) {
- const otherOpacity = theLayer.getOpacity(registeredLayerPath);
- theLayer.setOpacity(otherOpacity ? otherOpacity * 4 : 1, registeredLayerPath);
- } else theLayer.setOpacity(originalOpacity || 1, registeredLayerPath);
+ const otherOpacity = theLayer.getOpacity();
+ theLayer.setOpacity(otherOpacity ? otherOpacity * 4 : 1);
+ } else theLayer.setOpacity(originalOpacity || 1);
});
}
MapEventProcessor.setLayerZIndices(this.getMapId());
@@ -1365,7 +1276,7 @@ export class LayerApi {
refreshLayers(): void {
// For each geoview layer
this.getGeoviewLayers().forEach((geoviewLayer) => {
- if (geoviewLayer.olRootLayer) this.refreshBaseLayer(geoviewLayer.olRootLayer);
+ if (geoviewLayer) this.refreshBaseLayer(geoviewLayer.getOLLayer());
});
}
@@ -1397,7 +1308,7 @@ export class LayerApi {
*/
setItemVisibility(layerPath: string, item: TypeLegendItem, visibility: boolean, updateLegendLayers: boolean = true): void {
// Get registered layer config
- const layer = this.getGeoviewLayerHybrid(layerPath);
+ const layer = this.getGeoviewLayer(layerPath);
if (visibility && !MapEventProcessor.getMapVisibilityFromOrderedLayerInfo(this.getMapId(), layerPath)) {
MapEventProcessor.setOrToggleMapLayerVisibility(this.getMapId(), layerPath, true);
@@ -1454,7 +1365,7 @@ export class LayerApi {
// Go for it
// eslint-disable-next-line no-param-reassign
layerInfo.visible = newVisibility;
- this.getGeoviewLayerHybrid(layerInfo.layerPath)?.setVisible(layerInfo.visible, layerInfo.layerPath);
+ this.getGeoviewLayer(layerInfo.layerPath)?.setVisible(layerInfo.visible);
// Emit event
this.#emitLayerVisibilityToggled({ layerPath: layerInfo.layerPath, visibility: layerInfo.visible });
}
@@ -1471,7 +1382,7 @@ export class LayerApi {
if ((!layerVisibility || newValue) && parentLayerVisibility === false) {
if (parentLayerInfo) {
parentLayerInfo.visible = true;
- this.getGeoviewLayerHybrid(parentLayerPath)?.setVisible(true, parentLayerPath);
+ this.getGeoviewLayer(parentLayerPath)?.setVisible(true);
// Emit event
this.#emitLayerVisibilityToggled({ layerPath: parentLayerPath, visibility: true });
@@ -1507,7 +1418,7 @@ export class LayerApi {
*/
setLayerName(layerPath: string, name: string): void {
// Get the layer
- const layer = this.getGeoviewLayerHybrid(layerPath);
+ const layer = this.getGeoviewLayer(layerPath);
// If found
if (layer) {
@@ -1584,7 +1495,7 @@ export class LayerApi {
// If a leaf
if (!layerEntryIsGroupLayer(layerConfig)) {
// Get the layer
- const layer = this.getGeoviewLayerHybrid(layerConfig.layerPath) as AbstractGeoViewLayer | AbstractGVLayer;
+ const layer = this.getGeoviewLayer(layerConfig.layerPath) as AbstractGeoViewLayer | AbstractGVLayer;
// Get the bounds of the layer
const calculatedBounds = layer.getBounds(layerConfig.layerPath);
diff --git a/packages/geoview-core/src/geo/map/map-schema-types.ts b/packages/geoview-core/src/geo/map/map-schema-types.ts
index 435b1c2fa4c..7de93eb05c9 100644
--- a/packages/geoview-core/src/geo/map/map-schema-types.ts
+++ b/packages/geoview-core/src/geo/map/map-schema-types.ts
@@ -265,7 +265,7 @@ export type TypeFeatureInfoEntryPartial = Pick {
- logger.logTraceDetailed('checkMapReady - 1 - waiting on layer registration...', geoviewLayer.geoviewLayerId);
+ logger.logTraceDetailed(
+ 'checkMapReady - 1 - waiting on layer registration...',
+ geoviewLayer.getLayerConfig().geoviewLayerConfig.geoviewLayerId
+ );
}
);
@@ -679,7 +682,10 @@ export class MapViewer {
'processed',
this.mapFeaturesConfig.map.listOfGeoviewLayerConfig,
(geoviewLayer) => {
- logger.logTraceDetailed('checkMapReady - 2 - waiting on layer processed...', geoviewLayer.geoviewLayerId);
+ logger.logTraceDetailed(
+ 'checkMapReady - 2 - waiting on layer processed...',
+ geoviewLayer.getLayerConfig().geoviewLayerConfig.geoviewLayerId
+ );
}
);
@@ -716,7 +722,10 @@ export class MapViewer {
'loaded',
this.mapFeaturesConfig.map.listOfGeoviewLayerConfig,
(geoviewLayer) => {
- logger.logTraceDetailed('checkMapReady - 3 - waiting on layer loaded/error status...', geoviewLayer.geoviewLayerId);
+ logger.logTraceDetailed(
+ 'checkMapReady - 3 - waiting on layer loaded/error status...',
+ geoviewLayer.getLayerConfig().geoviewLayerConfig.geoviewLayerId
+ );
}
);
diff --git a/packages/geoview-time-slider/src/index.tsx b/packages/geoview-time-slider/src/index.tsx
index 33d35a576f0..9ace5a36e02 100644
--- a/packages/geoview-time-slider/src/index.tsx
+++ b/packages/geoview-time-slider/src/index.tsx
@@ -139,18 +139,18 @@ class TimeSliderPlugin extends FooterPlugin {
// TO.DOCONT: the later will override the plugin settings (can be tested by adding fake delays).
// TO.DOCONT: If this Plugin has temporal dimension settings, for various layers, those should be set in synch with the layers
// TO.DOCONT: using event listeners, not at Plugin creation.
- this.mapViewer().layer.getGeoviewLayerHybrid(obj.layerPaths[0])?.setTemporalDimension(obj.layerPaths[0], timeDimension);
+ this.mapViewer().layer.getGeoviewLayer(obj.layerPaths[0])?.setTemporalDimension(timeDimension);
}
// Set override default value under time dimension if applicable
if (obj.defaultValue) {
const layerPath = obj.layerPaths[0];
- const timeDimension = this.mapViewer().layer.getGeoviewLayerHybrid(layerPath)?.getTemporalDimension(layerPath);
+ const timeDimension = this.mapViewer().layer.getGeoviewLayer(layerPath)?.getTemporalDimension();
if (timeDimension) {
this.mapViewer()
.layer.getGeoviewLayerHybrid(layerPath)
- ?.setTemporalDimension(layerPath, {
+ ?.setTemporalDimension({
...timeDimension,
default: obj.defaultValue,
});
@@ -216,7 +216,7 @@ class TimeSliderPlugin extends FooterPlugin {
#filterTimeSliderLayers(layerPaths: string[]): string[] {
const filteredLayerPaths = layerPaths.filter((layerPath) => {
// Return the temporal dimension for the layer if any
- return this.mapViewer().layer.getGeoviewLayerHybrid(layerPath)?.getTemporalDimension(layerPath);
+ return this.mapViewer().layer.getGeoviewLayer(layerPath)?.getTemporalDimension();
});
return filteredLayerPaths;
}