From 9d87db86f4c96060c850a9e93bfd8b9b291880fe Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 11 Dec 2024 09:36:07 -0500 Subject: [PATCH 01/15] Issue #2608 - GeoCore Initial Settings --- packages/geoview-core/src/geo/layer/layer.ts | 5 +++- .../src/geo/layer/other/geocore.ts | 23 +++++++++++++++---- .../src/geo/map/map-schema-types.ts | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts index 403649deb85..1db09858a60 100644 --- a/packages/geoview-core/src/geo/layer/layer.ts +++ b/packages/geoview-core/src/geo/layer/layer.ts @@ -24,6 +24,7 @@ import { mapConfigLayerEntryIsGeoCore, layerEntryIsGroupLayer, TypeLayerStatus, + GeoCoreLayerConfig, } from '@/geo/map/map-schema-types'; import { GeoJSON, layerConfigIsGeoJSON } from '@/geo/layer/geoview-layers/vector/geojson'; import { GeoPackage, layerConfigIsGeoPackage } from '@/geo/layer/geoview-layers/vector/geopackage'; @@ -371,7 +372,9 @@ export class LayerApi { const geoCore = new GeoCore(this.getMapId(), this.mapViewer.getDisplayLanguage()); // Create the layers from the UUID - promisesOfGeoCoreGeoviewLayers.push(geoCore.createLayersFromUUID(geoviewLayerConfig.geoviewLayerId)); + promisesOfGeoCoreGeoviewLayers.push( + geoCore.createLayersFromUUID(geoviewLayerConfig.geoviewLayerId, geoviewLayerConfig as GeoCoreLayerConfig) + ); } else { // Add a resolved promise for a regular Geoview Layer Config promisesOfGeoCoreGeoviewLayers.push(Promise.resolve([geoviewLayerConfig as TypeGeoviewLayerConfig])); diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index b7f74d0d3af..948fe265e28 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -6,7 +6,7 @@ import { GeochartEventProcessor } from '@/api/event-processors/event-processor-c import { logger } from '@/core/utils/logger'; import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor'; -import { TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types'; +import { GeoCoreLayerConfig, TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types'; import { TypeJsonValue } from '@/core/types/global-types'; import { api } from '@/app'; @@ -32,11 +32,11 @@ export class GeoCore { /** * Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations. - * - * @param {GeoCoreLayerEntryConfig} geocoreLayerConfig the layer configuration + * @param {string} uuid the UUID of the layer + * @param {GeoCoreLayerConfig} geoCoreLayerConfig the layer configuration * @returns {Promise} list of layer configurations to add to the map */ - async createLayersFromUUID(uuid: string): Promise { + async createLayersFromUUID(uuid: string, layerEntryConfig?: GeoCoreLayerConfig): Promise { // Get the map config const mapConfig = MapEventProcessor.getGeoViewMapConfig(this.#mapId); @@ -50,6 +50,21 @@ export class GeoCore { // Validate the generated Geoview Layer Config ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); + // Set the initialSettings parameter if present + if (layerEntryConfig?.initialSettings) { + for (let i = 0; i < response.layers.length; i++) { + response.layers[i].initialSettings = { ...response.layers[i].initialSettings, ...layerEntryConfig.initialSettings }; + // Need to set the initial settings of the LayerEntryConfigs. Only applies to top layers. + // Visibility is passed down to children, but other values may not. + for (let j = 0; j < response.layers[i].listOfLayerEntryConfig.length; j++) { + response.layers[i].listOfLayerEntryConfig[j].initialSettings = { + ...response.layers[i].listOfLayerEntryConfig[j].initialSettings, + ...layerEntryConfig.initialSettings, + }; + } + } + } + // For each found geochart associated with the Geocore UUIDs response.geocharts?.forEach((geochartConfig) => { // Add a GeoChart 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 7de93eb05c9..7d87b6ded4a 100644 --- a/packages/geoview-core/src/geo/map/map-schema-types.ts +++ b/packages/geoview-core/src/geo/map/map-schema-types.ts @@ -404,6 +404,9 @@ export type GeoCoreLayerConfig = { // TO.DOCONT: For this we will need a little trick because when we create the config the setting are set at the root level and in our config it will take it from the layerID. // TO.DOCONT: There is refactor to do to make this work for all layer type. Global setting should be cascade to child of the root layer. geoviewLayerName: string; + + /** Initial settings to apply to the GeoCore layer at creation time. */ + initialSettings?: TypeLayerInitialSettings; }; /** From 2ee6ff29ea7affd42ce2ff887623ca851da67251 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 11 Dec 2024 10:02:28 -0500 Subject: [PATCH 02/15] rename/match config parameter --- packages/geoview-core/src/geo/layer/other/geocore.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index 948fe265e28..c6d19448e16 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -33,10 +33,10 @@ export class GeoCore { /** * Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations. * @param {string} uuid the UUID of the layer - * @param {GeoCoreLayerConfig} geoCoreLayerConfig the layer configuration + * @param {GeoCoreLayerConfig} layerConfig the layer configuration * @returns {Promise} list of layer configurations to add to the map */ - async createLayersFromUUID(uuid: string, layerEntryConfig?: GeoCoreLayerConfig): Promise { + async createLayersFromUUID(uuid: string, layerConfig?: GeoCoreLayerConfig): Promise { // Get the map config const mapConfig = MapEventProcessor.getGeoViewMapConfig(this.#mapId); @@ -51,15 +51,15 @@ export class GeoCore { ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); // Set the initialSettings parameter if present - if (layerEntryConfig?.initialSettings) { + if (layerConfig?.initialSettings) { for (let i = 0; i < response.layers.length; i++) { - response.layers[i].initialSettings = { ...response.layers[i].initialSettings, ...layerEntryConfig.initialSettings }; - // Need to set the initial settings of the LayerEntryConfigs. Only applies to top layers. + response.layers[i].initialSettings = { ...response.layers[i].initialSettings, ...layerConfig.initialSettings }; + // Need to set the initial settings of the LayerConfigs. Only applies to top layers. // Visibility is passed down to children, but other values may not. for (let j = 0; j < response.layers[i].listOfLayerEntryConfig.length; j++) { response.layers[i].listOfLayerEntryConfig[j].initialSettings = { ...response.layers[i].listOfLayerEntryConfig[j].initialSettings, - ...layerEntryConfig.initialSettings, + ...layerConfig.initialSettings, }; } } From f7c46b207ab5c768c94a37e0a687948a97c28c35 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 11 Dec 2024 11:46:06 -0500 Subject: [PATCH 03/15] Set initial geocore layer name 793 --- .../left-panel/add-new-layer/add-new-layer.tsx | 13 ++++++++++--- .../geoview-core/src/geo/layer/other/geocore.ts | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx index 10389f713cd..20f0616a8ff 100644 --- a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx +++ b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx @@ -429,7 +429,7 @@ export function AddNewLayer(): JSX.Element { const geoCoreGeoviewLayerInstance = new GeoCore(mapId, api.maps[mapId].getDisplayLanguage()); const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL); - if (layers.length === 1) { + if (layers.length >= 1) { if (layers.length === 1) { setLayerName(layers[0].geoviewLayerName!); setLayerEntries(layers); @@ -883,8 +883,15 @@ export function AddNewLayer(): JSX.Element { }); } else if (layerEntries.length > 0) { (layerEntries as TypeGeoviewLayerConfig[]).forEach((geoviewLayerConfig) => { - const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig); - if (addedLayer) addedLayers.push(addedLayer); + if (layerName !== geoviewLayerConfig.geoviewLayerName) { + const tempConfig = geoviewLayerConfig; + tempConfig.listOfLayerEntryConfig[0].layerName = layerName; + const addedLayer = api.maps[mapId].layer.addGeoviewLayer(tempConfig); + if (addedLayer) addedLayers.push(addedLayer); + } else { + const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig); + if (addedLayer) addedLayers.push(addedLayer); + } }); } diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index c6d19448e16..83fa53f9e32 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -50,6 +50,9 @@ export class GeoCore { // Validate the generated Geoview Layer Config ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); + // Set the Layer Name for the main layer + if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; + // Set the initialSettings parameter if present if (layerConfig?.initialSettings) { for (let i = 0; i < response.layers.length; i++) { From a110e70e35fbb485316901a26015a70e94f815fc Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 18 Dec 2024 09:42:50 -0500 Subject: [PATCH 04/15] Better initial settings --- .../configs/navigator/27-geocore-custom.json | 207 +++++++++++++++--- .../src/geo/layer/other/geocore.ts | 114 ++++++++-- .../src/geo/map/map-schema-types.ts | 3 + 3 files changed, 278 insertions(+), 46 deletions(-) diff --git a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json index 887d86ed35c..d98a4ca85fd 100644 --- a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json +++ b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json @@ -1,41 +1,190 @@ { "map": { - "interaction": "dynamic", - "viewSettings": { - "projection": 3978 - }, - "basemapOptions": { - "basemapId": "transport", - "shaded": true, - "labeled": false - }, - "listOfGeoviewLayerConfig": [ - { - "geoviewLayerType": "geoCore", - "geoviewLayerId": "ea4c0bdb-a63f-49a4-b14a-09c1560aad0b" + "interaction": "dynamic", + "viewSettings": { + "projection": 3978 }, - { - "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", - "geoviewLayerType": "geoCore" - } + "basemapOptions": { + "basemapId": "transport", + "shaded": true, + "labeled": false + }, + "listOfGeoviewLayerConfig": [ + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", + "listOfLayerEntryConfig": [ + { + "layerId": 0, + "layerName": "Airborne Radioactivity - Main Group", + "listOfLayerEntryConfig": [ + { + "layerId": 1, + "layerName":"Airborne Radioactivity - Feature Layer", + "initialSettings": { + "states": { + "visible": false + } + } + } + ] + } + ] + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "ccc75c12-5acc-4a6a-959f-ef6f621147b9", + "listOfLayerEntryConfig": [ + { + "layerId": 0, + "layerStyle": { + "Point": { + "type": "uniqueValue", + "hasDefault": false, + "fields": [ + "SYMBOL_EN" + ], + "info": [ + { + "label": "Confederation to 1914", + "visible": true, + "values": [ + "Confederation to 1914" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAahJREFUKJGd0ksoRFEcBvDvjMvci3E9GkxMxttYIIQo8igWHkmsRikLoSxlbSVZjKasyIIFmhQa5JmFZOGxMHYjeSQLxsw05ozhHgtcMWYWvjqbU7/zP9/pcPhnuN8blDqiGSONBCQHYG8gOPV62ZooijQgpB5XtySxsZvLu+j72weEcApoUzVQJ8TeejyuHkFQWfwgpc6BpwfH+PToCs4Xrn/com6oIKm1q26ZUmc7z0ctypBSZ7qX+sZMg3O42nn067M1cgoffVUYBpomKXXs8rxo5wCAMfQc7VtD/0Jf2TOeoaq5OEabmmgAYOIAgABlZ4e2wE/4GZv1ClqdpkyGAAl/dtGg6KPSCwAWLndkgE2bpS6y4joojE+KAwi5kCEBzKXVeR3rw8cBkSqbhz4/DYzBLEMlH2lOTtHsd07UVsz0bfuhsIQQ9BvbwAv8vCCoDr4nEsJe3O62yoaSVY0lvnB36QjWzUsoxVAU1megpqUU6sTYDUlSdH8dJn+AsIiIe8bs5Zm5ut5Mvc6AIegBvAE4AcGUUhk5SwiR/ODH5BgvAOPnCpp3ofqRTtNnzMYAAAAASUVORK5CYII=", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + }, + { + "label": "First World War", + "visible": false, + "values": [ + "First World War" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0ssvA1EUBvDvjqmZelUH7UwkbZQFQSKqImw8dtLEomFlZ9HY+EssiC07G1IWBInEYyMWgiZeG7owI6lE23REemdavRZqhCqJLzmbm/zuOefm8vhn+O8HlKZrGSNBAtIKsFcQRA2D7TgcDloS0szzFMuz2Xg8XvuUSILjOCiyDElyPmQyz2G7vXqrCFKqz+hpfX5jcweapn2Zoqurs3FkeGiDUn1cFGvWLUip3mwY2dmV1TUkEsmifaLRC+SyOS4YHF2kNH0gio4UDwCMIXx9fWP7CX3k8uoG/p5up6K4JwEs8ABAgL6721jpJyzk/l6FIst9FgRIhWGaf0LTNAGwCmtHBty5XPV+VdV+hXV1EkBIzIIEiHR0tE+cnkZLIkEQ4PM1gTFELCiIVRFFlo9GhgcH9vYPi5DNxiMUGoMgiCt2e/XxZ0dCmPnyEgoE/Nsud0P3yckZVFUDz5ehpcWH3t4AJMm5m89zUx+XWR+gvLLykbFUv9frmfZ6PJMA2gC8AjgHwZIgVC0TQvJF8L2z0wAwV6hf8waIeZGd6U5WcwAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + }, + { + "label": "Second World War", + "visible": true, + "values": [ + "Second World War" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0EsoRFEYB/D/GZe511zzyhhiMTMiQxI2YsPKMylRSkqKlFhpSspGSRSSjcdOpAalPGJhpUkWrFiI2RiSzDTX454rc48FrhiP8q9TX6d+fQ8O/wz39YPSsJkxUkNAsgAWAcGRorBNk8lEf4RUvmtjqjoa8vvN94FL6LgYmF0uiHZ7QJbvOgQhYT0KUip1y7fBicOhEUgzC5+mSBnuT81pbVmjVGrgeeOKBimV0p+pMnrQ68Hj8nbUPleeQahU0eX3dM1SGt7leVOIAwDG0HGx54v9Dr3nemAEwdpqi9XlaAYwyQEAAYpufPs/n/AtweMTWJ3OIg0CJP5ZCv8JI7IMgMVrOzLgTMzKLPyLGtJSAULONUgAb1pZaWPgF8QV5iApLxeMwatBPS96LQ7nXsbidMlpU3sUinHYkDc1hljBsCQICb6PjoSwp4eH+vTK8g2jb6vAv7oGaWMHxGpEYlUFXHW1EJPt26qqa9MmeC/iDIZrxkLFtmx3p83tbkafxw0gAuAQBHN6vThPCFGj4GtniwJg/O39mhf/K5CfkLtGyAAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + }, + { + "label": "Korean War", + "visible": false, + "values": [ + "Korean War" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAYtJREFUKJGdz79rU2EUxvHvSa+5N2libixtwEpTEYkZjKBLsItQapfiInYKXTIEQd0U/AdcTKG2a91cxCCoVEEonSTiYkEIVKiIYCQdDEkoeW+09zioVzTGgg+8cHjhc35Y/GesPz+MabmqMifICdA9hE3P02eJRMIMhKbbKeL7Zdl572qzDkNDMHoU20197HY7pUgkvtYHjWlfo/P5jr++CI0Hv6+RuT4uUwuPjWlfcpyDDwNoTPsYPa/sr92E1kbfPbp1G756IZm+smpMa8NxEk0LQJUSb6sH/oYCvL0MJ+eSkkoXgBULQCCvH14NREHqNRibzAcQJKq99v7wiwE0GtyosC0jx89oYx/oHgaRdwEUqGjm3Dy1W4ORnYF0DlUqAbSdWMUbnXxBfmVKX17tR9YhZKYM4ej9SCRe/TVRRHu7uxf93OxTRh6d1jdP4NM6WHFk4jycugBu6rnvh4pBr59FeHi4odo86x3JXpbxbAFuZIE94DXCXduO3RMRvw9+n5z0gKUf75/5BuXZh6Fohy1dAAAAAElFTkSuQmCC", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + }, + { + "label": "Peacekeeping", + "visible": true, + "values": [ + "Peacekeeping" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAatJREFUKJGd0jFoE1Ecx/HvP7kmd03iJSElwaLYq4OpRSQKFgUFt0IpFNGpkx2Ki1hcHNxdCio6OOjmoBAiiFZwEYTSrRYpioNBtLYErUlzxHuJ5p6D7YnGVPAH/+XB5/3//8cz+M8Yfx4otZHUWsYE2Qe6jbDUbOontm2rrlB57pTv69l3lVpyZb1BOCwMZm1yqfhHz3OnLSvxuAMqVT+/Xv96/crcMjfX3N+muDqc7T97Iv9Qqfpp09xRCqBS9UHVas9eLC1xr+p17DOzXKH5zQ9dGD1wW6mNZ6ZpVw0ArZmef73a8ze0lUtvPjFeqKWcnD0J3DAABEYWyp+7P+FmXn34gpNNjgQQpLfW+v5P6LXagO4NdtTwNp+JH2LV3Rb2p2MgUg6gQPHk/p1neLnWFR2JGBx0+tCaYgCjZrw4kGX+wXHn2MTzcgfaGw5xa3wYK9Jz37ISC786iuhWo3FqtDAwt9iXKJQW3/NoxSVtCGNOmonDe8ilYk99PzS1dVnwASKxWEXr6tGh3ZlzQ7syk5chD7SBFwh3otH4XRHxO+DPzqkmcG2zts0PBFWRZ33W55YAAAAASUVORK5CYII=", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + }, + { + "label": "Afghanistan", + "visible": false, + "values": [ + "Afghanistan" + ], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAadJREFUKJGd0ksoRFEYB/D/MZe5dzzGlccUxjOZsRksyLBRkkghVlZmISWRzSzsWShkFhQ7CzKNyCsbG1KTmBSJvMpzYYaZpjl35B4L44oxlH99m1O/833f6XD4Z7jvB5Q+JzJGGghIIcBeQeCSJLam1WppREgDPossy8OXD1eJ1+57qFQq5KVmQyem3AQCvk5BiF8Jg5R6ex59nrHB9UnY7pxfphgpak7vqGpbotTbyvMJDgVS6s2jweBw/+IQZt2nYfv0HTogvUhRvbWWKUqfN3le6+EAgDF0bh87o39CH7GerKDRVCPm6jLbAYxzAECA8p0LV+QnDOXo5gS5afpyBQJE8/Ti/xMGghQA0yg7MuDMkJxVilvnrzBd1AGEnCuQAPZqg7kNB/MRUZlahCnHCMZgV6Caj7PnpOq3Fyq7zU1btjCUz/GYqLdCiNHMCUL8zmdHQljQ72+pK65e3UvOKHG4NrB8u4skjkdDthlNJbXQiSkbshxl+bhM+QAxsbEPjHkqjPqCLmNmQfsAYADwCmAfBNNqddwMIUQOg++dRQnAaKh+zRtAE5CN4Z5HEQAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [ + 0, + 0 + ] + } + } + ] + } + } + } + ] + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "0fca08b5-e9d0-414b-a3c4-092ff9c5e326" + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "03ccfb5c-a06e-43e3-80fd-09d4f8f69703" + } ] - }, + }, "components": [ - "overview-map" + "overview-map" ], "overviewMap": { - "hideOnZoom": 7 + "hideOnZoom": 7 }, "footerBar": { - "tabs": { - "core": [ - "legend", - "layers", - "details", - "geochart", - "data-table" - ] - } + "tabs": { + "core": [ + "legend", + "layers", + "details", + "geochart", + "data-table" + ] + } }, "corePackages": [], "theme": "geo.ca" diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index 83fa53f9e32..9eba8c6d5da 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -1,4 +1,4 @@ -import { TypeDisplayLanguage } from '@config/types/map-schema-types'; +import { GroupLayerEntryConfig, TypeDisplayLanguage } from '@config/types/map-schema-types'; import { UUIDmapConfigReader } from '@/core/utils/config/reader/uuid-config-reader'; import { ConfigValidation } from '@/core/utils/config/config-validation'; @@ -6,7 +6,7 @@ import { GeochartEventProcessor } from '@/api/event-processors/event-processor-c import { logger } from '@/core/utils/logger'; import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor'; -import { GeoCoreLayerConfig, TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types'; +import { GeoCoreLayerConfig, TypeGeoviewLayerConfig, TypeLayerEntryConfig } from '@/geo/map/map-schema-types'; import { TypeJsonValue } from '@/core/types/global-types'; import { api } from '@/app'; @@ -30,6 +30,93 @@ export class GeoCore { this.#displayLanguage = displayLanguage; } + /** + * Merges two listOfLayerEntryConfigs together. + * Properties from the second will overwrite the first + * @param {TypeGeoviewLayerConfig} geocoreLayerEntryConfig the geocore layer entry config + * @param {GeoCoreLayerConfig} newLayerEntryConfig the new layer entry config + * @returns {TypeGeoviewLayerConfig} the merged layer entry config + */ + static mergeLayerEntryConfigs( + geocoreLayerEntryConfig: TypeGeoviewLayerConfig, + newLayerEntryConfig: GeoCoreLayerConfig + ): TypeGeoviewLayerConfig { + // Guard against empty listOflayerEntryConfig + if (!newLayerEntryConfig.listOfLayerEntryConfig || newLayerEntryConfig.listOfLayerEntryConfig.length === 0) + return geocoreLayerEntryConfig; + + // Get a map of the configs for the new LayerEntryConfigs based on the Layer IDs + const mergedLayerEntryConfig = { ...geocoreLayerEntryConfig }; + const newConfigMap = new Map(); + + function addToConfigMap(entryConfigs: TypeLayerEntryConfig[]): void { + entryConfigs.forEach((entryConfig) => { + if (entryConfig.listOfLayerEntryConfig) { + newConfigMap.set(entryConfig.layerId, entryConfig); + addToConfigMap(entryConfig.listOfLayerEntryConfig); + } else { + newConfigMap.set(entryConfig.layerId, entryConfig); + } + }); + } + addToConfigMap(newLayerEntryConfig.listOfLayerEntryConfig); + + // Remove Layer Configs that aren't in the listOfLayerEntryConfig. + // If a parent layer is removed, but the children are still in the list to remain, then they are + // brought up to the parent's array instead + function removeLayerConfigs(layerEntryConfigs: TypeLayerEntryConfig[]): TypeLayerEntryConfig[] { + const adjustedLayerEntryConfigs: TypeLayerEntryConfig[] = [...layerEntryConfigs]; + // Go through all layers and group layers backwards and remove layers as necessary. + // Use backwards so that the indexing isn't messed up when moving children up to the parent level + for (let i = adjustedLayerEntryConfigs.length - 1; i >= 0; i--) { + if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { + adjustedLayerEntryConfigs[i].listOfLayerEntryConfig = removeLayerConfigs( + adjustedLayerEntryConfigs[i].listOfLayerEntryConfig as TypeLayerEntryConfig[] + ); + } + + if (newConfigMap.get(adjustedLayerEntryConfigs[i].layerId)) { + if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { + const numEntries = adjustedLayerEntryConfigs[i].listOfLayerEntryConfig.length; + for (let j = numEntries - 1; j >= 0; j--) { + adjustedLayerEntryConfigs[i].listOfLayerEntryConfig[j].parentLayerConfig = undefined; + adjustedLayerEntryConfigs.splice(i + 1, 0, adjustedLayerEntryConfigs[i].listOfLayerEntryConfig[j]); + } + } + adjustedLayerEntryConfigs.splice(i, 1); + } + } + return adjustedLayerEntryConfigs; + } + mergedLayerEntryConfig.listOfLayerEntryConfig = removeLayerConfigs( + mergedLayerEntryConfig.listOfLayerEntryConfig as TypeLayerEntryConfig[] + ); + + // TODO! May be an issue. Currently ignoring the listOfLayerEntryConfig order and just keeping layers based on ID ... + // Need to make sure the initialSettings are updated properly and not over-written entirely + function mergeLayerEntryConfigs( + layerEntryConfigs: TypeLayerEntryConfig[], + configMap: Map + ): TypeLayerEntryConfig[] { + const newLayerEntryConfigs = [...layerEntryConfigs]; + newLayerEntryConfigs.forEach((layerEntryConfig) => { + const newConfig = configMap.get(layerEntryConfig.layerId); + if (!newConfig) return; + const mergedConfig = { ...layerEntryConfig, ...newConfig }; + if (newConfig.initialSettings) { + mergedConfig.initialSettings = { ...layerEntryConfig.initialSettings, ...newConfig.initialSettings }; + mergedConfig.initialSettings.states = { ...layerEntryConfig.initialSettings.states, ...newConfig.initialSettings.states }; + } + if (layerEntryConfig.listOfLayerEntryConfig) { + mergedConfig.listOfLayerEntryConfig = mergeLayerEntryConfigs(layerEntryConfig.listOfLayerEntryConfig, configMap); + } + }); + return newLayerEntryConfigs; + } + mergedLayerEntryConfig.listOfLayerEntryConfig = mergeLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig, newConfigMap); + return mergedLayerEntryConfig; + } + /** * Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations. * @param {string} uuid the UUID of the layer @@ -51,23 +138,16 @@ export class GeoCore { ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); // Set the Layer Name for the main layer - if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; - - // Set the initialSettings parameter if present - if (layerConfig?.initialSettings) { - for (let i = 0; i < response.layers.length; i++) { - response.layers[i].initialSettings = { ...response.layers[i].initialSettings, ...layerConfig.initialSettings }; - // Need to set the initial settings of the LayerConfigs. Only applies to top layers. - // Visibility is passed down to children, but other values may not. - for (let j = 0; j < response.layers[i].listOfLayerEntryConfig.length; j++) { - response.layers[i].listOfLayerEntryConfig[j].initialSettings = { - ...response.layers[i].listOfLayerEntryConfig[j].initialSettings, - ...layerConfig.initialSettings, - }; - } - } + if (!layerConfig?.listOfLayerEntryConfig) { + if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; } + // if (layerConfig?.listOfLayerEntryConfig) { + // response.layers = response.layers.map((responseLayer) => { + // return GeoCore.mergeLayerEntryConfigs(responseLayer, layerConfig); + // }); + // } + // For each found geochart associated with the Geocore UUIDs response.geocharts?.forEach((geochartConfig) => { // Add a GeoChart 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 7d87b6ded4a..300954bde52 100644 --- a/packages/geoview-core/src/geo/map/map-schema-types.ts +++ b/packages/geoview-core/src/geo/map/map-schema-types.ts @@ -407,6 +407,9 @@ export type GeoCoreLayerConfig = { /** Initial settings to apply to the GeoCore layer at creation time. */ initialSettings?: TypeLayerInitialSettings; + + /** The layer entries to use from the GeoCore layer. */ + listOfLayerEntryConfig?: TypeLayerEntryConfig[]; }; /** From 96c374279a068ffa93f6a03d61a7d8764000f129 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Mon, 13 Jan 2025 14:22:09 -0500 Subject: [PATCH 05/15] Partial - GeoCore config testing --- .../geoview-layers/abstract-geoview-layers.ts | 7 + .../src/geo/layer/other/geocore.ts | 201 +++++++++++++++--- 2 files changed, 176 insertions(+), 32 deletions(-) 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 dea141af4bf..333aba4f37a 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 @@ -333,6 +333,13 @@ export abstract class AbstractGeoViewLayer { }, 0); } + /** + * Method for pre-emptively getting the full config for applying entry configs + */ + async preflightGetAllLayerEntryConfigs(): Promise { + await this.getAdditionalServiceDefinition(); + } + /** *************************************************************************************************************************** * This method is used to create the layers specified in the listOfLayerEntryConfig attribute inherited from its parent. * Normally, it is the second method called in the life cycle of a GeoView layer, the first one being the constructor. diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index 9eba8c6d5da..794c8879619 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -1,14 +1,27 @@ -import { GroupLayerEntryConfig, TypeDisplayLanguage } from '@config/types/map-schema-types'; +import { GroupLayerEntryConfig, TypeDisplayLanguage, TypeGeoviewLayerType } from '@config/types/map-schema-types'; import { UUIDmapConfigReader } from '@/core/utils/config/reader/uuid-config-reader'; +// import { UUIDmapConfigReader } from '@/api/config/uuid-config-reader'; import { ConfigValidation } from '@/core/utils/config/config-validation'; import { GeochartEventProcessor } from '@/api/event-processors/event-processor-children/geochart-event-processor'; import { logger } from '@/core/utils/logger'; import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor'; import { GeoCoreLayerConfig, TypeGeoviewLayerConfig, TypeLayerEntryConfig } from '@/geo/map/map-schema-types'; +import { GeoJSON, layerConfigIsGeoJSON } from '@/geo/layer/geoview-layers/vector/geojson'; +import { GeoPackage, layerConfigIsGeoPackage } from '@/geo/layer/geoview-layers/vector/geopackage'; +import { layerConfigIsWMS, WMS } from '@/geo/layer/geoview-layers/raster/wms'; +import { EsriDynamic, layerConfigIsEsriDynamic } from '@/geo/layer/geoview-layers/raster/esri-dynamic'; +import { EsriFeature, layerConfigIsEsriFeature } from '@/geo/layer/geoview-layers/vector/esri-feature'; +import { EsriImage, layerConfigIsEsriImage } from '@/geo/layer/geoview-layers/raster/esri-image'; +import { ImageStatic, layerConfigIsImageStatic } from '@/geo/layer/geoview-layers/raster/image-static'; +import { layerConfigIsWFS, WFS } from '@/geo/layer/geoview-layers/vector/wfs'; +import { layerConfigIsOgcFeature, OgcFeature } from '@/geo/layer/geoview-layers/vector/ogc-feature'; +import { layerConfigIsXYZTiles, XYZTiles } from '@/geo/layer/geoview-layers/raster/xyz-tiles'; +import { layerConfigIsVectorTiles, VectorTiles } from '@/geo/layer/geoview-layers/raster/vector-tiles'; +import { CSV, layerConfigIsCSV } from '@/geo/layer/geoview-layers/vector/csv'; import { TypeJsonValue } from '@/core/types/global-types'; -import { api } from '@/app'; +import { AbstractGeoViewLayer, api } from '@/app'; /** * Class used to add geoCore layer to the map @@ -30,6 +43,111 @@ export class GeoCore { this.#displayLanguage = displayLanguage; } + /** + * Get full configuration of layer + * @param {TypeGeoviewLayerConfig} layerConfig The layer config from the geocore response + * @returns {TypeGeoviewLayerConfig} The complete layerConfig + */ + async getFullConfig(layerConfig: TypeGeoviewLayerConfig): Promise { + let layerBeingAdded: AbstractGeoViewLayer; + let layerType: TypeGeoviewLayerType; + if (layerConfigIsGeoJSON(layerConfig)) { + layerType = 'GeoJSON'; + layerBeingAdded = new GeoJSON(this.#mapId, layerConfig); + } else if (layerConfigIsGeoPackage(layerConfig)) { + layerType = 'GeoPackage'; + layerBeingAdded = new GeoPackage(this.#mapId, layerConfig); + } else if (layerConfigIsCSV(layerConfig)) { + layerType = 'CSV'; + layerBeingAdded = new CSV(this.#mapId, layerConfig); + } else if (layerConfigIsWMS(layerConfig)) { + layerType = 'ogcWms'; + layerBeingAdded = new WMS(this.#mapId, layerConfig); + } else if (layerConfigIsEsriDynamic(layerConfig)) { + layerType = 'esriDynamic'; + layerBeingAdded = new EsriDynamic(this.#mapId, layerConfig); + } else if (layerConfigIsEsriFeature(layerConfig)) { + layerType = 'esriFeature'; + layerBeingAdded = new EsriFeature(this.#mapId, layerConfig); + } else if (layerConfigIsEsriImage(layerConfig)) { + layerType = 'esriImage'; + layerBeingAdded = new EsriImage(this.#mapId, layerConfig); + } else if (layerConfigIsImageStatic(layerConfig)) { + layerType = 'imageStatic'; + layerBeingAdded = new ImageStatic(this.#mapId, layerConfig); + } else if (layerConfigIsWFS(layerConfig)) { + layerType = 'ogcWfs'; + layerBeingAdded = new WFS(this.#mapId, layerConfig); + } else if (layerConfigIsOgcFeature(layerConfig)) { + layerType = 'ogcFeature'; + layerBeingAdded = new OgcFeature(this.#mapId, layerConfig); + } else if (layerConfigIsXYZTiles(layerConfig)) { + layerType = 'xyzTiles'; + layerBeingAdded = new XYZTiles(this.#mapId, layerConfig); + } else if (layerConfigIsVectorTiles(layerConfig)) { + layerType = 'vectorTiles'; + layerBeingAdded = new VectorTiles(this.#mapId, layerConfig); + } else { + // TODO: Refactor - Throw an Error when falling in this else and change return type to AbstractGeoViewLayer without undefined + throw new Error(`Layer type ${layerConfig.geoviewLayerType} not supported`); + } + await layerBeingAdded?.preflightGetAllLayerEntryConfigs(); + const newConfig: TypeGeoviewLayerConfig = { + ...layerBeingAdded, + geoviewLayerType: layerType, + }; + + return newConfig; + } + + static cloneLayerEntryConfigs(entries: TypeLayerEntryConfig[]): TypeLayerEntryConfig[] { + return entries.map((entry) => { + // Create new object with preserved getters/setters + const clonedEntry = Object.create(Object.getPrototypeOf(entry), Object.getOwnPropertyDescriptors(entry)); + + // If this entry has its own listOfLayerEntryConfig + if (clonedEntry.listOfLayerEntryConfig) { + clonedEntry.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(clonedEntry.listOfLayerEntryConfig); + } + + return clonedEntry; + }); + } + + static subMergeLayerEntryConfigs( + layerEntryConfigs: TypeLayerEntryConfig[], + configMap: Map + ): TypeLayerEntryConfig[] { + return layerEntryConfigs.map((layerEntryConfig) => { + const newConfig = configMap.get(layerEntryConfig.layerId); + if (!newConfig) { + // If no new config to merge, just clone the existing one + return Object.create(Object.getPrototypeOf(layerEntryConfig), Object.getOwnPropertyDescriptors(layerEntryConfig)); + } + + // Create base merged config preserving getters/setters + const mergedConfig = Object.create(Object.getPrototypeOf(layerEntryConfig), Object.getOwnPropertyDescriptors(layerEntryConfig)); + + if (mergedConfig.listOfLayerEntryConfig) { + mergedConfig.listOfLayerEntryConfig = GeoCore.subMergeLayerEntryConfigs(mergedConfig.listOfLayerEntryConfig, configMap); + } + + // Merge initial Settings + if (newConfig.initialSettings) { + mergedConfig.initialSettings = { + ...layerEntryConfig.initialSettings, + ...newConfig.initialSettings, + // Special handling for states + states: { + ...layerEntryConfig.initialSettings?.states, + ...newConfig.initialSettings?.states, + }, + }; + } + return mergedConfig; + }); + } + /** * Merges two listOfLayerEntryConfigs together. * Properties from the second will overwrite the first @@ -47,15 +165,18 @@ export class GeoCore { // Get a map of the configs for the new LayerEntryConfigs based on the Layer IDs const mergedLayerEntryConfig = { ...geocoreLayerEntryConfig }; + mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig); const newConfigMap = new Map(); function addToConfigMap(entryConfigs: TypeLayerEntryConfig[]): void { entryConfigs.forEach((entryConfig) => { + // Forces the keyId to be string, can change to integer otherwise + const keyId = `${entryConfig.layerId}`; if (entryConfig.listOfLayerEntryConfig) { - newConfigMap.set(entryConfig.layerId, entryConfig); + newConfigMap.set(keyId, entryConfig); addToConfigMap(entryConfig.listOfLayerEntryConfig); } else { - newConfigMap.set(entryConfig.layerId, entryConfig); + newConfigMap.set(keyId, entryConfig); } }); } @@ -69,13 +190,18 @@ export class GeoCore { // Go through all layers and group layers backwards and remove layers as necessary. // Use backwards so that the indexing isn't messed up when moving children up to the parent level for (let i = adjustedLayerEntryConfigs.length - 1; i >= 0; i--) { + // remove problomatic properties + adjustedLayerEntryConfigs[i].layerStatus = 'newInstance'; + if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { adjustedLayerEntryConfigs[i].listOfLayerEntryConfig = removeLayerConfigs( adjustedLayerEntryConfigs[i].listOfLayerEntryConfig as TypeLayerEntryConfig[] ); } - if (newConfigMap.get(adjustedLayerEntryConfigs[i].layerId)) { + // if the layer is NOT in the configMap + if (!newConfigMap.get(adjustedLayerEntryConfigs[i].layerId)) { + // Move children up before removing the parent if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { const numEntries = adjustedLayerEntryConfigs[i].listOfLayerEntryConfig.length; for (let j = numEntries - 1; j >= 0; j--) { @@ -92,28 +218,11 @@ export class GeoCore { mergedLayerEntryConfig.listOfLayerEntryConfig as TypeLayerEntryConfig[] ); - // TODO! May be an issue. Currently ignoring the listOfLayerEntryConfig order and just keeping layers based on ID ... - // Need to make sure the initialSettings are updated properly and not over-written entirely - function mergeLayerEntryConfigs( - layerEntryConfigs: TypeLayerEntryConfig[], - configMap: Map - ): TypeLayerEntryConfig[] { - const newLayerEntryConfigs = [...layerEntryConfigs]; - newLayerEntryConfigs.forEach((layerEntryConfig) => { - const newConfig = configMap.get(layerEntryConfig.layerId); - if (!newConfig) return; - const mergedConfig = { ...layerEntryConfig, ...newConfig }; - if (newConfig.initialSettings) { - mergedConfig.initialSettings = { ...layerEntryConfig.initialSettings, ...newConfig.initialSettings }; - mergedConfig.initialSettings.states = { ...layerEntryConfig.initialSettings.states, ...newConfig.initialSettings.states }; - } - if (layerEntryConfig.listOfLayerEntryConfig) { - mergedConfig.listOfLayerEntryConfig = mergeLayerEntryConfigs(layerEntryConfig.listOfLayerEntryConfig, configMap); - } - }); - return newLayerEntryConfigs; - } - mergedLayerEntryConfig.listOfLayerEntryConfig = mergeLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig, newConfigMap); + mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.subMergeLayerEntryConfigs( + mergedLayerEntryConfig.listOfLayerEntryConfig, + newConfigMap + ); + mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig); return mergedLayerEntryConfig; } @@ -142,11 +251,34 @@ export class GeoCore { if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; } - // if (layerConfig?.listOfLayerEntryConfig) { - // response.layers = response.layers.map((responseLayer) => { - // return GeoCore.mergeLayerEntryConfigs(responseLayer, layerConfig); - // }); - // } + if (layerConfig?.initialSettings) { + response.layers[0].initialSettings = { + ...response.layers[0].initialSettings, + ...layerConfig.initialSettings, + // Special handling for states + states: { + ...response.layers[0].initialSettings?.states, + ...layerConfig.initialSettings?.states, + }, + }; + } + + if (layerConfig?.listOfLayerEntryConfig) { + // const newLayers: Promise[] = response.layers.map(async (lyr) => { + // const fullConfig = await this.getFullConfig(lyr); + // if (!fullConfig) return Promise.resolve(undefined); + // return GeoCore.mergeLayerEntryConfigs(fullConfig, layerConfig); + // }); + + // // Set the response layers to the merged config values + // const resolvedLayers = await Promise.all(newLayers); + // resolvedLayers.forEach((lyr, i) => { + // if (lyr) { + // response.layers[i] = lyr; + // } + // }); + response.layers[0].listOfLayerEntryConfig = layerConfig.listOfLayerEntryConfig; + } // For each found geochart associated with the Geocore UUIDs response.geocharts?.forEach((geochartConfig) => { @@ -154,6 +286,11 @@ export class GeoCore { GeochartEventProcessor.addGeochartChart(this.#mapId, geochartConfig.layers[0].layerId as string, geochartConfig); }); + // Testing only + // response.layers[0].listOfLayerEntryConfig[0].layerId = '1'; + // response.layers[0].listOfLayerEntryConfig[0].layerName = 'Name Set from Config'; + // response.layers[0].listOfLayerEntryConfig[0].initialSettings.states.visible = false; + return response.layers; } catch (error) { // Log From f969a94a7b658269b6098cd2b53724db5cfcf46d Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Tue, 14 Jan 2025 09:18:36 -0500 Subject: [PATCH 06/15] Activate code for creating config --- .../src/geo/layer/other/geocore.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index 794c8879619..eea45bb97aa 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -264,20 +264,20 @@ export class GeoCore { } if (layerConfig?.listOfLayerEntryConfig) { - // const newLayers: Promise[] = response.layers.map(async (lyr) => { - // const fullConfig = await this.getFullConfig(lyr); - // if (!fullConfig) return Promise.resolve(undefined); - // return GeoCore.mergeLayerEntryConfigs(fullConfig, layerConfig); - // }); - - // // Set the response layers to the merged config values - // const resolvedLayers = await Promise.all(newLayers); - // resolvedLayers.forEach((lyr, i) => { - // if (lyr) { - // response.layers[i] = lyr; - // } - // }); - response.layers[0].listOfLayerEntryConfig = layerConfig.listOfLayerEntryConfig; + const newLayers: Promise[] = response.layers.map(async (lyr) => { + const fullConfig = await this.getFullConfig(lyr); + if (!fullConfig) return Promise.resolve(undefined); + return GeoCore.mergeLayerEntryConfigs(fullConfig, layerConfig); + }); + + // Set the response layers to the merged config values + const resolvedLayers = await Promise.all(newLayers); + resolvedLayers.forEach((lyr, i) => { + if (lyr) { + response.layers[i] = lyr; + } + }); + // response.layers[0].listOfLayerEntryConfig = layerConfig.listOfLayerEntryConfig; } // For each found geochart associated with the Geocore UUIDs From 2fe333c26f37b91ef9276caac60599adef7dbc30 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Tue, 14 Jan 2025 17:19:14 -0500 Subject: [PATCH 07/15] Use Config Utils to get valid LayerConfig --- .../src/core/utils/config/config.ts | 1 + .../geoview-layers/abstract-geoview-layers.ts | 7 - .../src/geo/layer/other/geocore.ts | 250 +----------------- 3 files changed, 15 insertions(+), 243 deletions(-) diff --git a/packages/geoview-core/src/core/utils/config/config.ts b/packages/geoview-core/src/core/utils/config/config.ts index becde9386e6..fa26a4a7634 100644 --- a/packages/geoview-core/src/core/utils/config/config.ts +++ b/packages/geoview-core/src/core/utils/config/config.ts @@ -55,6 +55,7 @@ export class Config { listOfGeoviewLayerConfig.forEach((geoviewLayerEntry) => { if (mapConfigLayerEntryIsGeoCore(geoviewLayerEntry)) { // Skip it, because we don't validate the GeoCore configuration anymore. Not the same way as typical GeoView Layer Types at least. + // ? Why not do GeoCore request here? Then could easily replace listOfLayerEntries and validate / process along with other layers? } else if (Object.values(CONST_LAYER_TYPES).includes((geoviewLayerEntry as TypeGeoviewLayerConfig).geoviewLayerType)) { const geoViewLayerEntryCasted = geoviewLayerEntry as TypeGeoviewLayerConfig; this.#setLayerEntryType(geoViewLayerEntryCasted.listOfLayerEntryConfig!, geoViewLayerEntryCasted.geoviewLayerType); 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 333aba4f37a..dea141af4bf 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 @@ -333,13 +333,6 @@ export abstract class AbstractGeoViewLayer { }, 0); } - /** - * Method for pre-emptively getting the full config for applying entry configs - */ - async preflightGetAllLayerEntryConfigs(): Promise { - await this.getAdditionalServiceDefinition(); - } - /** *************************************************************************************************************************** * This method is used to create the layers specified in the listOfLayerEntryConfig attribute inherited from its parent. * Normally, it is the second method called in the life cycle of a GeoView layer, the first one being the constructor. diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index eea45bb97aa..b9970521807 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -1,27 +1,16 @@ -import { GroupLayerEntryConfig, TypeDisplayLanguage, TypeGeoviewLayerType } from '@config/types/map-schema-types'; +import { TypeDisplayLanguage } from '@config/types/map-schema-types'; import { UUIDmapConfigReader } from '@/core/utils/config/reader/uuid-config-reader'; // import { UUIDmapConfigReader } from '@/api/config/uuid-config-reader'; +import { Config } from '@/core/utils/config/config'; import { ConfigValidation } from '@/core/utils/config/config-validation'; import { GeochartEventProcessor } from '@/api/event-processors/event-processor-children/geochart-event-processor'; import { logger } from '@/core/utils/logger'; import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor'; -import { GeoCoreLayerConfig, TypeGeoviewLayerConfig, TypeLayerEntryConfig } from '@/geo/map/map-schema-types'; -import { GeoJSON, layerConfigIsGeoJSON } from '@/geo/layer/geoview-layers/vector/geojson'; -import { GeoPackage, layerConfigIsGeoPackage } from '@/geo/layer/geoview-layers/vector/geopackage'; -import { layerConfigIsWMS, WMS } from '@/geo/layer/geoview-layers/raster/wms'; -import { EsriDynamic, layerConfigIsEsriDynamic } from '@/geo/layer/geoview-layers/raster/esri-dynamic'; -import { EsriFeature, layerConfigIsEsriFeature } from '@/geo/layer/geoview-layers/vector/esri-feature'; -import { EsriImage, layerConfigIsEsriImage } from '@/geo/layer/geoview-layers/raster/esri-image'; -import { ImageStatic, layerConfigIsImageStatic } from '@/geo/layer/geoview-layers/raster/image-static'; -import { layerConfigIsWFS, WFS } from '@/geo/layer/geoview-layers/vector/wfs'; -import { layerConfigIsOgcFeature, OgcFeature } from '@/geo/layer/geoview-layers/vector/ogc-feature'; -import { layerConfigIsXYZTiles, XYZTiles } from '@/geo/layer/geoview-layers/raster/xyz-tiles'; -import { layerConfigIsVectorTiles, VectorTiles } from '@/geo/layer/geoview-layers/raster/vector-tiles'; -import { CSV, layerConfigIsCSV } from '@/geo/layer/geoview-layers/vector/csv'; +import { GeoCoreLayerConfig, TypeGeoviewLayerConfig } from '@/geo/map/map-schema-types'; import { TypeJsonValue } from '@/core/types/global-types'; -import { AbstractGeoViewLayer, api } from '@/app'; +import { api } from '@/app'; /** * Class used to add geoCore layer to the map @@ -43,189 +32,6 @@ export class GeoCore { this.#displayLanguage = displayLanguage; } - /** - * Get full configuration of layer - * @param {TypeGeoviewLayerConfig} layerConfig The layer config from the geocore response - * @returns {TypeGeoviewLayerConfig} The complete layerConfig - */ - async getFullConfig(layerConfig: TypeGeoviewLayerConfig): Promise { - let layerBeingAdded: AbstractGeoViewLayer; - let layerType: TypeGeoviewLayerType; - if (layerConfigIsGeoJSON(layerConfig)) { - layerType = 'GeoJSON'; - layerBeingAdded = new GeoJSON(this.#mapId, layerConfig); - } else if (layerConfigIsGeoPackage(layerConfig)) { - layerType = 'GeoPackage'; - layerBeingAdded = new GeoPackage(this.#mapId, layerConfig); - } else if (layerConfigIsCSV(layerConfig)) { - layerType = 'CSV'; - layerBeingAdded = new CSV(this.#mapId, layerConfig); - } else if (layerConfigIsWMS(layerConfig)) { - layerType = 'ogcWms'; - layerBeingAdded = new WMS(this.#mapId, layerConfig); - } else if (layerConfigIsEsriDynamic(layerConfig)) { - layerType = 'esriDynamic'; - layerBeingAdded = new EsriDynamic(this.#mapId, layerConfig); - } else if (layerConfigIsEsriFeature(layerConfig)) { - layerType = 'esriFeature'; - layerBeingAdded = new EsriFeature(this.#mapId, layerConfig); - } else if (layerConfigIsEsriImage(layerConfig)) { - layerType = 'esriImage'; - layerBeingAdded = new EsriImage(this.#mapId, layerConfig); - } else if (layerConfigIsImageStatic(layerConfig)) { - layerType = 'imageStatic'; - layerBeingAdded = new ImageStatic(this.#mapId, layerConfig); - } else if (layerConfigIsWFS(layerConfig)) { - layerType = 'ogcWfs'; - layerBeingAdded = new WFS(this.#mapId, layerConfig); - } else if (layerConfigIsOgcFeature(layerConfig)) { - layerType = 'ogcFeature'; - layerBeingAdded = new OgcFeature(this.#mapId, layerConfig); - } else if (layerConfigIsXYZTiles(layerConfig)) { - layerType = 'xyzTiles'; - layerBeingAdded = new XYZTiles(this.#mapId, layerConfig); - } else if (layerConfigIsVectorTiles(layerConfig)) { - layerType = 'vectorTiles'; - layerBeingAdded = new VectorTiles(this.#mapId, layerConfig); - } else { - // TODO: Refactor - Throw an Error when falling in this else and change return type to AbstractGeoViewLayer without undefined - throw new Error(`Layer type ${layerConfig.geoviewLayerType} not supported`); - } - await layerBeingAdded?.preflightGetAllLayerEntryConfigs(); - const newConfig: TypeGeoviewLayerConfig = { - ...layerBeingAdded, - geoviewLayerType: layerType, - }; - - return newConfig; - } - - static cloneLayerEntryConfigs(entries: TypeLayerEntryConfig[]): TypeLayerEntryConfig[] { - return entries.map((entry) => { - // Create new object with preserved getters/setters - const clonedEntry = Object.create(Object.getPrototypeOf(entry), Object.getOwnPropertyDescriptors(entry)); - - // If this entry has its own listOfLayerEntryConfig - if (clonedEntry.listOfLayerEntryConfig) { - clonedEntry.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(clonedEntry.listOfLayerEntryConfig); - } - - return clonedEntry; - }); - } - - static subMergeLayerEntryConfigs( - layerEntryConfigs: TypeLayerEntryConfig[], - configMap: Map - ): TypeLayerEntryConfig[] { - return layerEntryConfigs.map((layerEntryConfig) => { - const newConfig = configMap.get(layerEntryConfig.layerId); - if (!newConfig) { - // If no new config to merge, just clone the existing one - return Object.create(Object.getPrototypeOf(layerEntryConfig), Object.getOwnPropertyDescriptors(layerEntryConfig)); - } - - // Create base merged config preserving getters/setters - const mergedConfig = Object.create(Object.getPrototypeOf(layerEntryConfig), Object.getOwnPropertyDescriptors(layerEntryConfig)); - - if (mergedConfig.listOfLayerEntryConfig) { - mergedConfig.listOfLayerEntryConfig = GeoCore.subMergeLayerEntryConfigs(mergedConfig.listOfLayerEntryConfig, configMap); - } - - // Merge initial Settings - if (newConfig.initialSettings) { - mergedConfig.initialSettings = { - ...layerEntryConfig.initialSettings, - ...newConfig.initialSettings, - // Special handling for states - states: { - ...layerEntryConfig.initialSettings?.states, - ...newConfig.initialSettings?.states, - }, - }; - } - return mergedConfig; - }); - } - - /** - * Merges two listOfLayerEntryConfigs together. - * Properties from the second will overwrite the first - * @param {TypeGeoviewLayerConfig} geocoreLayerEntryConfig the geocore layer entry config - * @param {GeoCoreLayerConfig} newLayerEntryConfig the new layer entry config - * @returns {TypeGeoviewLayerConfig} the merged layer entry config - */ - static mergeLayerEntryConfigs( - geocoreLayerEntryConfig: TypeGeoviewLayerConfig, - newLayerEntryConfig: GeoCoreLayerConfig - ): TypeGeoviewLayerConfig { - // Guard against empty listOflayerEntryConfig - if (!newLayerEntryConfig.listOfLayerEntryConfig || newLayerEntryConfig.listOfLayerEntryConfig.length === 0) - return geocoreLayerEntryConfig; - - // Get a map of the configs for the new LayerEntryConfigs based on the Layer IDs - const mergedLayerEntryConfig = { ...geocoreLayerEntryConfig }; - mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig); - const newConfigMap = new Map(); - - function addToConfigMap(entryConfigs: TypeLayerEntryConfig[]): void { - entryConfigs.forEach((entryConfig) => { - // Forces the keyId to be string, can change to integer otherwise - const keyId = `${entryConfig.layerId}`; - if (entryConfig.listOfLayerEntryConfig) { - newConfigMap.set(keyId, entryConfig); - addToConfigMap(entryConfig.listOfLayerEntryConfig); - } else { - newConfigMap.set(keyId, entryConfig); - } - }); - } - addToConfigMap(newLayerEntryConfig.listOfLayerEntryConfig); - - // Remove Layer Configs that aren't in the listOfLayerEntryConfig. - // If a parent layer is removed, but the children are still in the list to remain, then they are - // brought up to the parent's array instead - function removeLayerConfigs(layerEntryConfigs: TypeLayerEntryConfig[]): TypeLayerEntryConfig[] { - const adjustedLayerEntryConfigs: TypeLayerEntryConfig[] = [...layerEntryConfigs]; - // Go through all layers and group layers backwards and remove layers as necessary. - // Use backwards so that the indexing isn't messed up when moving children up to the parent level - for (let i = adjustedLayerEntryConfigs.length - 1; i >= 0; i--) { - // remove problomatic properties - adjustedLayerEntryConfigs[i].layerStatus = 'newInstance'; - - if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { - adjustedLayerEntryConfigs[i].listOfLayerEntryConfig = removeLayerConfigs( - adjustedLayerEntryConfigs[i].listOfLayerEntryConfig as TypeLayerEntryConfig[] - ); - } - - // if the layer is NOT in the configMap - if (!newConfigMap.get(adjustedLayerEntryConfigs[i].layerId)) { - // Move children up before removing the parent - if (adjustedLayerEntryConfigs[i].listOfLayerEntryConfig) { - const numEntries = adjustedLayerEntryConfigs[i].listOfLayerEntryConfig.length; - for (let j = numEntries - 1; j >= 0; j--) { - adjustedLayerEntryConfigs[i].listOfLayerEntryConfig[j].parentLayerConfig = undefined; - adjustedLayerEntryConfigs.splice(i + 1, 0, adjustedLayerEntryConfigs[i].listOfLayerEntryConfig[j]); - } - } - adjustedLayerEntryConfigs.splice(i, 1); - } - } - return adjustedLayerEntryConfigs; - } - mergedLayerEntryConfig.listOfLayerEntryConfig = removeLayerConfigs( - mergedLayerEntryConfig.listOfLayerEntryConfig as TypeLayerEntryConfig[] - ); - - mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.subMergeLayerEntryConfigs( - mergedLayerEntryConfig.listOfLayerEntryConfig, - newConfigMap - ); - mergedLayerEntryConfig.listOfLayerEntryConfig = GeoCore.cloneLayerEntryConfigs(mergedLayerEntryConfig.listOfLayerEntryConfig); - return mergedLayerEntryConfig; - } - /** * Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations. * @param {string} uuid the UUID of the layer @@ -243,54 +49,26 @@ export class GeoCore { // Get the GV config from UUID and await const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, this.#displayLanguage, [uuid]); - // Validate the generated Geoview Layer Config - ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); - - // Set the Layer Name for the main layer - if (!layerConfig?.listOfLayerEntryConfig) { - if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; - } - - if (layerConfig?.initialSettings) { - response.layers[0].initialSettings = { - ...response.layers[0].initialSettings, - ...layerConfig.initialSettings, - // Special handling for states - states: { - ...response.layers[0].initialSettings?.states, - ...layerConfig.initialSettings?.states, - }, - }; - } - + // Use user supplied listOfLayerEntryConfig if provided if (layerConfig?.listOfLayerEntryConfig) { - const newLayers: Promise[] = response.layers.map(async (lyr) => { - const fullConfig = await this.getFullConfig(lyr); - if (!fullConfig) return Promise.resolve(undefined); - return GeoCore.mergeLayerEntryConfigs(fullConfig, layerConfig); - }); + const tempLayerConfig = { ...layerConfig } as unknown as TypeGeoviewLayerConfig; + tempLayerConfig.metadataAccessPath = response.layers[0].metadataAccessPath; + tempLayerConfig.geoviewLayerType = response.layers[0].geoviewLayerType; - // Set the response layers to the merged config values - const resolvedLayers = await Promise.all(newLayers); - resolvedLayers.forEach((lyr, i) => { - if (lyr) { - response.layers[i] = lyr; - } - }); - // response.layers[0].listOfLayerEntryConfig = layerConfig.listOfLayerEntryConfig; + const config = new Config(this.#displayLanguage); + const newLayerConfig = config.getValidMapConfig([tempLayerConfig]); + return newLayerConfig as TypeGeoviewLayerConfig[]; } + // Validate the generated Geoview Layer Config + ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); + // For each found geochart associated with the Geocore UUIDs response.geocharts?.forEach((geochartConfig) => { // Add a GeoChart GeochartEventProcessor.addGeochartChart(this.#mapId, geochartConfig.layers[0].layerId as string, geochartConfig); }); - // Testing only - // response.layers[0].listOfLayerEntryConfig[0].layerId = '1'; - // response.layers[0].listOfLayerEntryConfig[0].layerName = 'Name Set from Config'; - // response.layers[0].listOfLayerEntryConfig[0].initialSettings.states.visible = false; - return response.layers; } catch (error) { // Log From cc27bd9deb4e2fafa5273d5d3d0deb9974017d06 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Tue, 14 Jan 2025 18:18:54 -0500 Subject: [PATCH 08/15] Slight adjustment to config on 27-geocore-custom --- .../geoview-core/public/configs/navigator/27-geocore-custom.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json index d98a4ca85fd..95808236d76 100644 --- a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json +++ b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json @@ -16,6 +16,7 @@ "listOfLayerEntryConfig": [ { "layerId": 0, + "entryType": "group", "layerName": "Airborne Radioactivity - Main Group", "listOfLayerEntryConfig": [ { From 78ef02cdf793410842a9a1048e9e38ee46a85369 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 09:11:59 -0500 Subject: [PATCH 09/15] Add Demo Page --- .../configs/navigator/27-geocore-custom.json | 208 +++--------------- .../28-geocore-custom-inline-config.json | 188 ++++++++++++++++ .../public/templates/demos-navigator.html | 1 + .../src/geo/layer/other/geocore.ts | 6 +- 4 files changed, 222 insertions(+), 181 deletions(-) create mode 100644 packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json diff --git a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json index 95808236d76..887d86ed35c 100644 --- a/packages/geoview-core/public/configs/navigator/27-geocore-custom.json +++ b/packages/geoview-core/public/configs/navigator/27-geocore-custom.json @@ -1,191 +1,41 @@ { "map": { - "interaction": "dynamic", - "viewSettings": { - "projection": 3978 - }, - "basemapOptions": { - "basemapId": "transport", - "shaded": true, - "labeled": false + "interaction": "dynamic", + "viewSettings": { + "projection": 3978 + }, + "basemapOptions": { + "basemapId": "transport", + "shaded": true, + "labeled": false + }, + "listOfGeoviewLayerConfig": [ + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "ea4c0bdb-a63f-49a4-b14a-09c1560aad0b" }, - "listOfGeoviewLayerConfig": [ - { - "geoviewLayerType": "geoCore", - "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", - "listOfLayerEntryConfig": [ - { - "layerId": 0, - "entryType": "group", - "layerName": "Airborne Radioactivity - Main Group", - "listOfLayerEntryConfig": [ - { - "layerId": 1, - "layerName":"Airborne Radioactivity - Feature Layer", - "initialSettings": { - "states": { - "visible": false - } - } - } - ] - } - ] - }, - { - "geoviewLayerType": "geoCore", - "geoviewLayerId": "ccc75c12-5acc-4a6a-959f-ef6f621147b9", - "listOfLayerEntryConfig": [ - { - "layerId": 0, - "layerStyle": { - "Point": { - "type": "uniqueValue", - "hasDefault": false, - "fields": [ - "SYMBOL_EN" - ], - "info": [ - { - "label": "Confederation to 1914", - "visible": true, - "values": [ - "Confederation to 1914" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAahJREFUKJGd0ksoRFEcBvDvjMvci3E9GkxMxttYIIQo8igWHkmsRikLoSxlbSVZjKasyIIFmhQa5JmFZOGxMHYjeSQLxsw05ozhHgtcMWYWvjqbU7/zP9/pcPhnuN8blDqiGSONBCQHYG8gOPV62ZooijQgpB5XtySxsZvLu+j72weEcApoUzVQJ8TeejyuHkFQWfwgpc6BpwfH+PToCs4Xrn/com6oIKm1q26ZUmc7z0ctypBSZ7qX+sZMg3O42nn067M1cgoffVUYBpomKXXs8rxo5wCAMfQc7VtD/0Jf2TOeoaq5OEabmmgAYOIAgABlZ4e2wE/4GZv1ClqdpkyGAAl/dtGg6KPSCwAWLndkgE2bpS6y4joojE+KAwi5kCEBzKXVeR3rw8cBkSqbhz4/DYzBLEMlH2lOTtHsd07UVsz0bfuhsIQQ9BvbwAv8vCCoDr4nEsJe3O62yoaSVY0lvnB36QjWzUsoxVAU1megpqUU6sTYDUlSdH8dJn+AsIiIe8bs5Zm5ut5Mvc6AIegBvAE4AcGUUhk5SwiR/ODH5BgvAOPnCpp3ofqRTtNnzMYAAAAASUVORK5CYII=", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - }, - { - "label": "First World War", - "visible": false, - "values": [ - "First World War" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0ssvA1EUBvDvjqmZelUH7UwkbZQFQSKqImw8dtLEomFlZ9HY+EssiC07G1IWBInEYyMWgiZeG7owI6lE23REemdavRZqhCqJLzmbm/zuOefm8vhn+O8HlKZrGSNBAtIKsFcQRA2D7TgcDloS0szzFMuz2Xg8XvuUSILjOCiyDElyPmQyz2G7vXqrCFKqz+hpfX5jcweapn2Zoqurs3FkeGiDUn1cFGvWLUip3mwY2dmV1TUkEsmifaLRC+SyOS4YHF2kNH0gio4UDwCMIXx9fWP7CX3k8uoG/p5up6K4JwEs8ABAgL6721jpJyzk/l6FIst9FgRIhWGaf0LTNAGwCmtHBty5XPV+VdV+hXV1EkBIzIIEiHR0tE+cnkZLIkEQ4PM1gTFELCiIVRFFlo9GhgcH9vYPi5DNxiMUGoMgiCt2e/XxZ0dCmPnyEgoE/Nsud0P3yckZVFUDz5ehpcWH3t4AJMm5m89zUx+XWR+gvLLykbFUv9frmfZ6PJMA2gC8AjgHwZIgVC0TQvJF8L2z0wAwV6hf8waIeZGd6U5WcwAAAABJRU5ErkJggg==", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - }, - { - "label": "Second World War", - "visible": true, - "values": [ - "Second World War" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0EsoRFEYB/D/GZe511zzyhhiMTMiQxI2YsPKMylRSkqKlFhpSspGSRSSjcdOpAalPGJhpUkWrFiI2RiSzDTX454rc48FrhiP8q9TX6d+fQ8O/wz39YPSsJkxUkNAsgAWAcGRorBNk8lEf4RUvmtjqjoa8vvN94FL6LgYmF0uiHZ7QJbvOgQhYT0KUip1y7fBicOhEUgzC5+mSBnuT81pbVmjVGrgeeOKBimV0p+pMnrQ68Hj8nbUPleeQahU0eX3dM1SGt7leVOIAwDG0HGx54v9Dr3nemAEwdpqi9XlaAYwyQEAAYpufPs/n/AtweMTWJ3OIg0CJP5ZCv8JI7IMgMVrOzLgTMzKLPyLGtJSAULONUgAb1pZaWPgF8QV5iApLxeMwatBPS96LQ7nXsbidMlpU3sUinHYkDc1hljBsCQICb6PjoSwp4eH+vTK8g2jb6vAv7oGaWMHxGpEYlUFXHW1EJPt26qqa9MmeC/iDIZrxkLFtmx3p83tbkafxw0gAuAQBHN6vThPCFGj4GtniwJg/O39mhf/K5CfkLtGyAAAAABJRU5ErkJggg==", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - }, - { - "label": "Korean War", - "visible": false, - "values": [ - "Korean War" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAYtJREFUKJGdz79rU2EUxvHvSa+5N2libixtwEpTEYkZjKBLsItQapfiInYKXTIEQd0U/AdcTKG2a91cxCCoVEEonSTiYkEIVKiIYCQdDEkoeW+09zioVzTGgg+8cHjhc35Y/GesPz+MabmqMifICdA9hE3P02eJRMIMhKbbKeL7Zdl572qzDkNDMHoU20197HY7pUgkvtYHjWlfo/P5jr++CI0Hv6+RuT4uUwuPjWlfcpyDDwNoTPsYPa/sr92E1kbfPbp1G756IZm+smpMa8NxEk0LQJUSb6sH/oYCvL0MJ+eSkkoXgBULQCCvH14NREHqNRibzAcQJKq99v7wiwE0GtyosC0jx89oYx/oHgaRdwEUqGjm3Dy1W4ORnYF0DlUqAbSdWMUbnXxBfmVKX17tR9YhZKYM4ej9SCRe/TVRRHu7uxf93OxTRh6d1jdP4NM6WHFk4jycugBu6rnvh4pBr59FeHi4odo86x3JXpbxbAFuZIE94DXCXduO3RMRvw9+n5z0gKUf75/5BuXZh6Fohy1dAAAAAElFTkSuQmCC", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - }, - { - "label": "Peacekeeping", - "visible": true, - "values": [ - "Peacekeeping" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAatJREFUKJGd0jFoE1Ecx/HvP7kmd03iJSElwaLYq4OpRSQKFgUFt0IpFNGpkx2Ki1hcHNxdCio6OOjmoBAiiFZwEYTSrRYpioNBtLYErUlzxHuJ5p6D7YnGVPAH/+XB5/3//8cz+M8Yfx4otZHUWsYE2Qe6jbDUbOontm2rrlB57pTv69l3lVpyZb1BOCwMZm1yqfhHz3OnLSvxuAMqVT+/Xv96/crcMjfX3N+muDqc7T97Iv9Qqfpp09xRCqBS9UHVas9eLC1xr+p17DOzXKH5zQ9dGD1wW6mNZ6ZpVw0ArZmef73a8ze0lUtvPjFeqKWcnD0J3DAABEYWyp+7P+FmXn34gpNNjgQQpLfW+v5P6LXagO4NdtTwNp+JH2LV3Rb2p2MgUg6gQPHk/p1neLnWFR2JGBx0+tCaYgCjZrw4kGX+wXHn2MTzcgfaGw5xa3wYK9Jz37ISC786iuhWo3FqtDAwt9iXKJQW3/NoxSVtCGNOmonDe8ilYk99PzS1dVnwASKxWEXr6tGh3ZlzQ7syk5chD7SBFwh3otH4XRHxO+DPzqkmcG2zts0PBFWRZ33W55YAAAAASUVORK5CYII=", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - }, - { - "label": "Afghanistan", - "visible": false, - "values": [ - "Afghanistan" - ], - "settings": { - "type": "iconSymbol", - "mimeType": "image/png", - "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAadJREFUKJGd0ksoRFEYB/D/MZe5dzzGlccUxjOZsRksyLBRkkghVlZmISWRzSzsWShkFhQ7CzKNyCsbG1KTmBSJvMpzYYaZpjl35B4L44oxlH99m1O/833f6XD4Z7jvB5Q+JzJGGghIIcBeQeCSJLam1WppREgDPossy8OXD1eJ1+57qFQq5KVmQyem3AQCvk5BiF8Jg5R6ex59nrHB9UnY7pxfphgpak7vqGpbotTbyvMJDgVS6s2jweBw/+IQZt2nYfv0HTogvUhRvbWWKUqfN3le6+EAgDF0bh87o39CH7GerKDRVCPm6jLbAYxzAECA8p0LV+QnDOXo5gS5afpyBQJE8/Ti/xMGghQA0yg7MuDMkJxVilvnrzBd1AGEnCuQAPZqg7kNB/MRUZlahCnHCMZgV6Caj7PnpOq3Fyq7zU1btjCUz/GYqLdCiNHMCUL8zmdHQljQ72+pK65e3UvOKHG4NrB8u4skjkdDthlNJbXQiSkbshxl+bhM+QAxsbEPjHkqjPqCLmNmQfsAYADwCmAfBNNqddwMIUQOg++dRQnAaKh+zRtAE5CN4Z5HEQAAAABJRU5ErkJggg==", - "rotation": 0, - "opacity": 1, - "offset": [ - 0, - 0 - ] - } - } - ] - } - } - } - ] - }, - { - "geoviewLayerType": "geoCore", - "geoviewLayerId": "0fca08b5-e9d0-414b-a3c4-092ff9c5e326" - }, - { - "geoviewLayerType": "geoCore", - "geoviewLayerId": "03ccfb5c-a06e-43e3-80fd-09d4f8f69703" - } + { + "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", + "geoviewLayerType": "geoCore" + } ] - }, + }, "components": [ - "overview-map" + "overview-map" ], "overviewMap": { - "hideOnZoom": 7 + "hideOnZoom": 7 }, "footerBar": { - "tabs": { - "core": [ - "legend", - "layers", - "details", - "geochart", - "data-table" - ] - } + "tabs": { + "core": [ + "legend", + "layers", + "details", + "geochart", + "data-table" + ] + } }, "corePackages": [], "theme": "geo.ca" diff --git a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json new file mode 100644 index 00000000000..185839aafc5 --- /dev/null +++ b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json @@ -0,0 +1,188 @@ +{ + "map": { + "interaction": "dynamic", + "viewSettings": { + "projection": 3978 + }, + "basemapOptions": { + "basemapId": "transport", + "shaded": true, + "labeled": false + }, + "listOfGeoviewLayerConfig": [ + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", + "listOfLayerEntryConfig": [ + { + "layerId": 0, + "entryType": "group", + "layerName": "Airborne Radioactivity - Main Group", + "listOfLayerEntryConfig": [ + { + "layerId": 1, + "layerName": "Airborne Radioactivity - Feature Layer", + "initialSettings": { + "states": { + "visible": false + } + } + } + ] + } + ] + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "0fca08b5-e9d0-414b-a3c4-092ff9c5e326", + "listOfLayerEntryConfig": [ + { + "layerId": "6", + "layerName": "NS Marine Water Quality Data", + "initialSettings": { + "states": { + "hoverable": true, + "legendCollpased": false, + "opacity": 0.7, + "queryable": true, + "visible": true + } + } + } + ] + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "03ccfb5c-a06e-43e3-80fd-09d4f8f69703", + "listOfLayerEntryConfig": [ + { + "layerId": "regina", + "layerName": "Temporal Series of the National Air Photo Library (NAPL) - Regina, Saskatchewan (1947-1967) / Série temporelle de la photothèque nationale de l'air (PNA) - Regina, Saskatchewan (1947-1967)", + "initialSettings": { + "states": { + "opacity": 0.5 + }, + "controls": { + "highlight": false, + "hover": false, + "opacity": true, + "query": false, + "remove": true, + "table": false, + "visibility": true, + "zoom": true + } + } + } + ] + }, + { + "geoviewLayerType": "geoCore", + "geoviewLayerId": "ccc75c12-5acc-4a6a-959f-ef6f621147b9", + "listOfLayerEntryConfig": [ + { + "layerId": 0, + "layerStyle": { + "Point": { + "type": "uniqueValue", + "hasDefault": false, + "fields": ["SYMBOL_EN"], + "info": [ + { + "label": "Confederation to 1914", + "visible": true, + "values": ["Confederation to 1914"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAahJREFUKJGd0ksoRFEcBvDvjMvci3E9GkxMxttYIIQo8igWHkmsRikLoSxlbSVZjKasyIIFmhQa5JmFZOGxMHYjeSQLxsw05ozhHgtcMWYWvjqbU7/zP9/pcPhnuN8blDqiGSONBCQHYG8gOPV62ZooijQgpB5XtySxsZvLu+j72weEcApoUzVQJ8TeejyuHkFQWfwgpc6BpwfH+PToCs4Xrn/com6oIKm1q26ZUmc7z0ctypBSZ7qX+sZMg3O42nn067M1cgoffVUYBpomKXXs8rxo5wCAMfQc7VtD/0Jf2TOeoaq5OEabmmgAYOIAgABlZ4e2wE/4GZv1ClqdpkyGAAl/dtGg6KPSCwAWLndkgE2bpS6y4joojE+KAwi5kCEBzKXVeR3rw8cBkSqbhz4/DYzBLEMlH2lOTtHsd07UVsz0bfuhsIQQ9BvbwAv8vCCoDr4nEsJe3O62yoaSVY0lvnB36QjWzUsoxVAU1megpqUU6sTYDUlSdH8dJn+AsIiIe8bs5Zm5ut5Mvc6AIegBvAE4AcGUUhk5SwiR/ODH5BgvAOPnCpp3ofqRTtNnzMYAAAAASUVORK5CYII=", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + }, + { + "label": "First World War", + "visible": false, + "values": ["First World War"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0ssvA1EUBvDvjqmZelUH7UwkbZQFQSKqImw8dtLEomFlZ9HY+EssiC07G1IWBInEYyMWgiZeG7owI6lE23REemdavRZqhCqJLzmbm/zuOefm8vhn+O8HlKZrGSNBAtIKsFcQRA2D7TgcDloS0szzFMuz2Xg8XvuUSILjOCiyDElyPmQyz2G7vXqrCFKqz+hpfX5jcweapn2Zoqurs3FkeGiDUn1cFGvWLUip3mwY2dmV1TUkEsmifaLRC+SyOS4YHF2kNH0gio4UDwCMIXx9fWP7CX3k8uoG/p5up6K4JwEs8ABAgL6721jpJyzk/l6FIst9FgRIhWGaf0LTNAGwCmtHBty5XPV+VdV+hXV1EkBIzIIEiHR0tE+cnkZLIkEQ4PM1gTFELCiIVRFFlo9GhgcH9vYPi5DNxiMUGoMgiCt2e/XxZ0dCmPnyEgoE/Nsud0P3yckZVFUDz5ehpcWH3t4AJMm5m89zUx+XWR+gvLLykbFUv9frmfZ6PJMA2gC8AjgHwZIgVC0TQvJF8L2z0wAwV6hf8waIeZGd6U5WcwAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + }, + { + "label": "Second World War", + "visible": true, + "values": ["Second World War"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAZ5JREFUKJGd0EsoRFEYB/D/GZe511zzyhhiMTMiQxI2YsPKMylRSkqKlFhpSspGSRSSjcdOpAalPGJhpUkWrFiI2RiSzDTX454rc48FrhiP8q9TX6d+fQ8O/wz39YPSsJkxUkNAsgAWAcGRorBNk8lEf4RUvmtjqjoa8vvN94FL6LgYmF0uiHZ7QJbvOgQhYT0KUip1y7fBicOhEUgzC5+mSBnuT81pbVmjVGrgeeOKBimV0p+pMnrQ68Hj8nbUPleeQahU0eX3dM1SGt7leVOIAwDG0HGx54v9Dr3nemAEwdpqi9XlaAYwyQEAAYpufPs/n/AtweMTWJ3OIg0CJP5ZCv8JI7IMgMVrOzLgTMzKLPyLGtJSAULONUgAb1pZaWPgF8QV5iApLxeMwatBPS96LQ7nXsbidMlpU3sUinHYkDc1hljBsCQICb6PjoSwp4eH+vTK8g2jb6vAv7oGaWMHxGpEYlUFXHW1EJPt26qqa9MmeC/iDIZrxkLFtmx3p83tbkafxw0gAuAQBHN6vThPCFGj4GtniwJg/O39mhf/K5CfkLtGyAAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + }, + { + "label": "Korean War", + "visible": false, + "values": ["Korean War"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAYtJREFUKJGdz79rU2EUxvHvSa+5N2libixtwEpTEYkZjKBLsItQapfiInYKXTIEQd0U/AdcTKG2a91cxCCoVEEonSTiYkEIVKiIYCQdDEkoeW+09zioVzTGgg+8cHjhc35Y/GesPz+MabmqMifICdA9hE3P02eJRMIMhKbbKeL7Zdl572qzDkNDMHoU20197HY7pUgkvtYHjWlfo/P5jr++CI0Hv6+RuT4uUwuPjWlfcpyDDwNoTPsYPa/sr92E1kbfPbp1G756IZm+smpMa8NxEk0LQJUSb6sH/oYCvL0MJ+eSkkoXgBULQCCvH14NREHqNRibzAcQJKq99v7wiwE0GtyosC0jx89oYx/oHgaRdwEUqGjm3Dy1W4ORnYF0DlUqAbSdWMUbnXxBfmVKX17tR9YhZKYM4ej9SCRe/TVRRHu7uxf93OxTRh6d1jdP4NM6WHFk4jycugBu6rnvh4pBr59FeHi4odo86x3JXpbxbAFuZIE94DXCXduO3RMRvw9+n5z0gKUf75/5BuXZh6Fohy1dAAAAAElFTkSuQmCC", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + }, + { + "label": "Peacekeeping", + "visible": true, + "values": ["Peacekeeping"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAatJREFUKJGd0jFoE1Ecx/HvP7kmd03iJSElwaLYq4OpRSQKFgUFt0IpFNGpkx2Ki1hcHNxdCio6OOjmoBAiiFZwEYTSrRYpioNBtLYErUlzxHuJ5p6D7YnGVPAH/+XB5/3//8cz+M8Yfx4otZHUWsYE2Qe6jbDUbOontm2rrlB57pTv69l3lVpyZb1BOCwMZm1yqfhHz3OnLSvxuAMqVT+/Xv96/crcMjfX3N+muDqc7T97Iv9Qqfpp09xRCqBS9UHVas9eLC1xr+p17DOzXKH5zQ9dGD1wW6mNZ6ZpVw0ArZmef73a8ze0lUtvPjFeqKWcnD0J3DAABEYWyp+7P+FmXn34gpNNjgQQpLfW+v5P6LXagO4NdtTwNp+JH2LV3Rb2p2MgUg6gQPHk/p1neLnWFR2JGBx0+tCaYgCjZrw4kGX+wXHn2MTzcgfaGw5xa3wYK9Jz37ISC786iuhWo3FqtDAwt9iXKJQW3/NoxSVtCGNOmonDe8ilYk99PzS1dVnwASKxWEXr6tGh3ZlzQ7syk5chD7SBFwh3otH4XRHxO+DPzqkmcG2zts0PBFWRZ33W55YAAAAASUVORK5CYII=", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + }, + { + "label": "Afghanistan", + "visible": false, + "values": ["Afghanistan"], + "settings": { + "type": "iconSymbol", + "mimeType": "image/png", + "src": "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IB2cksfwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAadJREFUKJGd0ksoRFEYB/D/MZe5dzzGlccUxjOZsRksyLBRkkghVlZmISWRzSzsWShkFhQ7CzKNyCsbG1KTmBSJvMpzYYaZpjl35B4L44oxlH99m1O/833f6XD4Z7jvB5Q+JzJGGghIIcBeQeCSJLam1WppREgDPossy8OXD1eJ1+57qFQq5KVmQyem3AQCvk5BiF8Jg5R6ex59nrHB9UnY7pxfphgpak7vqGpbotTbyvMJDgVS6s2jweBw/+IQZt2nYfv0HTogvUhRvbWWKUqfN3le6+EAgDF0bh87o39CH7GerKDRVCPm6jLbAYxzAECA8p0LV+QnDOXo5gS5afpyBQJE8/Ti/xMGghQA0yg7MuDMkJxVilvnrzBd1AGEnCuQAPZqg7kNB/MRUZlahCnHCMZgV6Caj7PnpOq3Fyq7zU1btjCUz/GYqLdCiNHMCUL8zmdHQljQ72+pK65e3UvOKHG4NrB8u4skjkdDthlNJbXQiSkbshxl+bhM+QAxsbEPjHkqjPqCLmNmQfsAYADwCmAfBNNqddwMIUQOg++dRQnAaKh+zRtAE5CN4Z5HEQAAAABJRU5ErkJggg==", + "rotation": 0, + "opacity": 1, + "offset": [0, 0] + } + } + ] + } + } + } + ] + } + ] + }, + "components": ["overview-map"], + "overviewMap": { + "hideOnZoom": 7 + }, + "footerBar": { + "tabs": { + "core": ["legend", "layers", "details", "geochart", "data-table"] + } + }, + "corePackages": [], + "theme": "geo.ca" +} diff --git a/packages/geoview-core/public/templates/demos-navigator.html b/packages/geoview-core/public/templates/demos-navigator.html index d90fe683a05..928c4fa6052 100644 --- a/packages/geoview-core/public/templates/demos-navigator.html +++ b/packages/geoview-core/public/templates/demos-navigator.html @@ -148,6 +148,7 @@

Configurations Navigator

+ diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index b9970521807..e2eff295ca9 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -52,8 +52,10 @@ export class GeoCore { // Use user supplied listOfLayerEntryConfig if provided if (layerConfig?.listOfLayerEntryConfig) { const tempLayerConfig = { ...layerConfig } as unknown as TypeGeoviewLayerConfig; - tempLayerConfig.metadataAccessPath = response.layers[0].metadataAccessPath; - tempLayerConfig.geoviewLayerType = response.layers[0].geoviewLayerType; + for (let i = 0; i < layerConfig.listOfLayerEntryConfig.length; i++) { + tempLayerConfig.metadataAccessPath = response.layers[i].metadataAccessPath; + tempLayerConfig.geoviewLayerType = response.layers[i].geoviewLayerType; + } const config = new Config(this.#displayLanguage); const newLayerConfig = config.getValidMapConfig([tempLayerConfig]); From 4797512d4dea37b6ec8379b27f9e38da3e6dc060 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 09:33:00 -0500 Subject: [PATCH 10/15] Slight correction to config --- .../configs/navigator/28-geocore-custom-inline-config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json index 185839aafc5..be35b0a3108 100644 --- a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json +++ b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json @@ -15,12 +15,12 @@ "geoviewLayerId": "21b821cf-0f1c-40ee-8925-eab12d357668", "listOfLayerEntryConfig": [ { - "layerId": 0, + "layerId": "0", "entryType": "group", "layerName": "Airborne Radioactivity - Main Group", "listOfLayerEntryConfig": [ { - "layerId": 1, + "layerId": "1", "layerName": "Airborne Radioactivity - Feature Layer", "initialSettings": { "states": { From ffef81706060155723581a2f97d1d313ac950115 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 10:04:01 -0500 Subject: [PATCH 11/15] Configuration corrections and Initial Settings handled --- .../navigator/28-geocore-custom-inline-config.json | 9 +++++++-- .../layers/left-panel/add-new-layer/add-new-layer.tsx | 2 +- packages/geoview-core/src/geo/layer/other/geocore.ts | 8 +++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json index be35b0a3108..9366d598e93 100644 --- a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json +++ b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json @@ -42,7 +42,7 @@ "initialSettings": { "states": { "hoverable": true, - "legendCollpased": false, + "legendCollapsed": false, "opacity": 0.7, "queryable": true, "visible": true @@ -54,6 +54,11 @@ { "geoviewLayerType": "geoCore", "geoviewLayerId": "03ccfb5c-a06e-43e3-80fd-09d4f8f69703", + "initialSettings": { + "controls": { + "highlight": true + } + }, "listOfLayerEntryConfig": [ { "layerId": "regina", @@ -81,7 +86,7 @@ "geoviewLayerId": "ccc75c12-5acc-4a6a-959f-ef6f621147b9", "listOfLayerEntryConfig": [ { - "layerId": 0, + "layerId": "0", "layerStyle": { "Point": { "type": "uniqueValue", diff --git a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx index 20f0616a8ff..f6a38d24534 100644 --- a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx +++ b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx @@ -429,7 +429,7 @@ export function AddNewLayer(): JSX.Element { const geoCoreGeoviewLayerInstance = new GeoCore(mapId, api.maps[mapId].getDisplayLanguage()); const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL); - if (layers.length >= 1) { + if (layers.length === 1) { if (layers.length === 1) { setLayerName(layers[0].geoviewLayerName!); setLayerEntries(layers); diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index e2eff295ca9..d6eefbdb401 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -50,12 +50,10 @@ export class GeoCore { const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, this.#displayLanguage, [uuid]); // Use user supplied listOfLayerEntryConfig if provided - if (layerConfig?.listOfLayerEntryConfig) { + if (layerConfig?.listOfLayerEntryConfig || layerConfig?.initialSettings) { const tempLayerConfig = { ...layerConfig } as unknown as TypeGeoviewLayerConfig; - for (let i = 0; i < layerConfig.listOfLayerEntryConfig.length; i++) { - tempLayerConfig.metadataAccessPath = response.layers[i].metadataAccessPath; - tempLayerConfig.geoviewLayerType = response.layers[i].geoviewLayerType; - } + tempLayerConfig.metadataAccessPath = response.layers[0].metadataAccessPath; + tempLayerConfig.geoviewLayerType = response.layers[0].geoviewLayerType; const config = new Config(this.#displayLanguage); const newLayerConfig = config.getValidMapConfig([tempLayerConfig]); From 503ae5a80b00e74f9c4c9a01afee18fd366298b0 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 12:53:20 -0500 Subject: [PATCH 12/15] Small cleanup --- packages/geoview-core/src/core/utils/config/config.ts | 2 +- packages/geoview-core/src/geo/layer/other/geocore.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/geoview-core/src/core/utils/config/config.ts b/packages/geoview-core/src/core/utils/config/config.ts index fa26a4a7634..ea7f6c62968 100644 --- a/packages/geoview-core/src/core/utils/config/config.ts +++ b/packages/geoview-core/src/core/utils/config/config.ts @@ -55,7 +55,7 @@ export class Config { listOfGeoviewLayerConfig.forEach((geoviewLayerEntry) => { if (mapConfigLayerEntryIsGeoCore(geoviewLayerEntry)) { // Skip it, because we don't validate the GeoCore configuration anymore. Not the same way as typical GeoView Layer Types at least. - // ? Why not do GeoCore request here? Then could easily replace listOfLayerEntries and validate / process along with other layers? + // TODO Why not do GeoCore request here? Then could easily replace listOfLayerEntries and validate / process along with other layers } else if (Object.values(CONST_LAYER_TYPES).includes((geoviewLayerEntry as TypeGeoviewLayerConfig).geoviewLayerType)) { const geoViewLayerEntryCasted = geoviewLayerEntry as TypeGeoviewLayerConfig; this.#setLayerEntryType(geoViewLayerEntryCasted.listOfLayerEntryConfig!, geoViewLayerEntryCasted.geoviewLayerType); diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index d6eefbdb401..7b9e950ee6b 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -1,7 +1,6 @@ import { TypeDisplayLanguage } from '@config/types/map-schema-types'; import { UUIDmapConfigReader } from '@/core/utils/config/reader/uuid-config-reader'; -// import { UUIDmapConfigReader } from '@/api/config/uuid-config-reader'; import { Config } from '@/core/utils/config/config'; import { ConfigValidation } from '@/core/utils/config/config-validation'; import { GeochartEventProcessor } from '@/api/event-processors/event-processor-children/geochart-event-processor'; From afe69e035bfadb9565b928ee25a4976b2a393a47 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 13:13:36 -0500 Subject: [PATCH 13/15] Correctly name added layers --- .../layers/left-panel/add-new-layer/add-new-layer.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx index f6a38d24534..67315f432bc 100644 --- a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx +++ b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx @@ -885,7 +885,11 @@ export function AddNewLayer(): JSX.Element { (layerEntries as TypeGeoviewLayerConfig[]).forEach((geoviewLayerConfig) => { if (layerName !== geoviewLayerConfig.geoviewLayerName) { const tempConfig = geoviewLayerConfig; - tempConfig.listOfLayerEntryConfig[0].layerName = layerName; + if (tempConfig.listOfLayerEntryConfig.length > 1) { + tempConfig.geoviewLayerName = layerName; + } else { + tempConfig.listOfLayerEntryConfig[0].layerName = layerName; + } const addedLayer = api.maps[mapId].layer.addGeoviewLayer(tempConfig); if (addedLayer) addedLayers.push(addedLayer); } else { From d9e2d32bb0b4f951479298e0a4d99b9583105914 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 13:20:04 -0500 Subject: [PATCH 14/15] Change Opacity value --- .../configs/navigator/28-geocore-custom-inline-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json index 9366d598e93..8b57098cb88 100644 --- a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json +++ b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json @@ -43,7 +43,7 @@ "states": { "hoverable": true, "legendCollapsed": false, - "opacity": 0.7, + "opacity": 0.3, "queryable": true, "visible": true } From 754189c38e65ae076c120e55b24a8428b787c55f Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 15 Jan 2025 13:35:20 -0500 Subject: [PATCH 15/15] Remove incorrect part from config --- .../configs/navigator/28-geocore-custom-inline-config.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json index 8b57098cb88..b949e34f01f 100644 --- a/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json +++ b/packages/geoview-core/public/configs/navigator/28-geocore-custom-inline-config.json @@ -54,11 +54,6 @@ { "geoviewLayerType": "geoCore", "geoviewLayerId": "03ccfb5c-a06e-43e3-80fd-09d4f8f69703", - "initialSettings": { - "controls": { - "highlight": true - } - }, "listOfLayerEntryConfig": [ { "layerId": "regina",