From 9859c4fd4bd6220b904ab43dc5e47221e826a755 Mon Sep 17 00:00:00 2001 From: Damon Ulmi <63123585+DamonU2@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:00:23 -0800 Subject: [PATCH] fix(config): fixed bug with config validation Closes #2632 --- packages/geoview-core/schema.json | 429 ++++++++++++++---- .../types/classes/map-feature-config.ts | 17 +- .../types/config-validation-schema.json | 395 +++++++++++++--- .../src/api/config/types/map-schema-types.ts | 3 +- .../map-event-processor.ts | 6 +- .../geoview-core/src/geo/map/map-viewer.ts | 10 +- 6 files changed, 700 insertions(+), 160 deletions(-) diff --git a/packages/geoview-core/schema.json b/packages/geoview-core/schema.json index 64239747632..28bea530eb8 100644 --- a/packages/geoview-core/schema.json +++ b/packages/geoview-core/schema.json @@ -27,7 +27,9 @@ } } }, - "required": ["queryable"] + "required": [ + "queryable" + ] }, "TypeOutfields": { "type": "object", @@ -56,12 +58,22 @@ ] } }, - "required": ["name", "alias", "type", "domain"] + "required": [ + "name", + "alias", + "type", + "domain" + ] }, "TypeOutfieldsType": { "description": "The types supported by the outfields object.", "additionalProperties": false, - "enum": ["string", "number", "date", "url"] + "enum": [ + "string", + "number", + "date", + "url" + ] }, "TypeFeatureInfoNotQueryable": { "additionalProperties": false, @@ -73,7 +85,9 @@ "description": "Do not allow querying." } }, - "required": ["queryable"] + "required": [ + "queryable" + ] }, "TypeBaseVectorGeometryConfig": { "description": "Base type for the vector geometry types.", @@ -87,7 +101,12 @@ }, "TypeBaseVectorType": { "description": "Valid values for the type property of the base vector settings.", - "enum": ["lineString", "filledPolygon", "simpleSymbol", "iconSymbol"] + "enum": [ + "lineString", + "filledPolygon", + "simpleSymbol", + "iconSymbol" + ] }, "TypeStrokeSymbolConfig": { "minProperties": 1, @@ -133,7 +152,9 @@ "type": "object", "properties": { "type": { - "enum": ["lineString"] + "enum": [ + "lineString" + ] }, "stroke": { "$ref": "#/definitions/TypeStrokeSymbolConfig" @@ -152,7 +173,9 @@ "type": "object", "properties": { "type": { - "enum": ["filledPolygon"] + "enum": [ + "filledPolygon" + ] }, "color": { "type": "string" @@ -181,7 +204,16 @@ }, "TypeFillStyle": { "description": "Valid values to specify fill styles.", - "enum": ["null", "solid", "backwardDiagonal", "cross", "diagonalCross", "forwardDiagonal", "horizontal", "vertical"] + "enum": [ + "null", + "solid", + "backwardDiagonal", + "cross", + "diagonalCross", + "forwardDiagonal", + "horizontal", + "vertical" + ] }, "TypeSimpleSymbolVectorConfig": { "description": " Definition of the simple symbol vector settings type.", @@ -194,7 +226,9 @@ "type": "object", "properties": { "type": { - "enum": ["simpleSymbol"] + "enum": [ + "simpleSymbol" + ] }, "rotation": { "description": "Symbol rotation in radians.", @@ -226,7 +260,15 @@ }, "TypeSymbol": { "description": "Valid values to specify symbol shapes.", - "enum": ["circle", "+", "diamond", "square", "triangle", "X", "star"] + "enum": [ + "circle", + "+", + "diamond", + "square", + "triangle", + "X", + "star" + ] }, "TypeIconSymbolVectorConfig": { "type": "object", @@ -238,7 +280,9 @@ "type": "object", "properties": { "type": { - "enum": ["iconSymbol"] + "enum": [ + "iconSymbol" + ] }, "mimeType": { "type": "string" @@ -350,7 +394,11 @@ }, "TypeLayerStyleConfigType": { "description": "Valid keys for the type property of style configurations.", - "enum": ["simple", "uniqueValue", "classBreaks"] + "enum": [ + "simple", + "uniqueValue", + "classBreaks" + ] }, "TypeLayerStyleConfigInfo": { "type": "object", @@ -501,7 +549,15 @@ } }, "TypeVectorSourceFormats": { - "enum": ["GeoJSON", "EsriJSON", "KML", "WFS", "featureAPI", "GeoPackage", "CSV"], + "enum": [ + "GeoJSON", + "EsriJSON", + "KML", + "WFS", + "featureAPI", + "GeoPackage", + "CSV" + ], "description": "The feature format used by the XHR feature loader when access path is set." }, "TypeVectorSourceInitialConfig": { @@ -534,7 +590,10 @@ "$ref": "#/definitions/TypeFeatureInfoLayerConfig" }, "strategy": { - "enum": ["all", "bbox"], + "enum": [ + "all", + "bbox" + ], "default": "all", "description": "The loading strategy to use. By default an all strategy is used, a one-off strategy which loads all features at once." }, @@ -585,7 +644,11 @@ } }, "TypeOfServer": { - "enum": ["mapserver", "geoserver", "qgis"], + "enum": [ + "mapserver", + "geoserver", + "qgis" + ], "description": "The type of the remote WMS server. The default value is mapserver." }, "TypeSourceImageStaticInitialConfig": { @@ -648,7 +711,12 @@ } }, "TypeEsriFormatParameter": { - "enum": ["png", "jpg", "gif", "svg"], + "enum": [ + "png", + "jpg", + "gif", + "svg" + ], "default": "png", "description": "The format of the exported image. The default format is png." }, @@ -714,21 +782,36 @@ "items": { "type": "number" }, - "default": [256, 256], + "default": [ + 256, + 256 + ], "description": "The tile grid origin, i.e. where the x and y axes meet ([z, 0, 0]). Tile coordinates increase left to right and downwards. If not specified, extent must be provided." } }, - "required": ["origin", "resolutions"] + "required": [ + "origin", + "resolutions" + ] }, "TypeVectorLayerEntryConfig": { "additionalProperties": false, "type": "object", "properties": { "schemaTag": { - "enum": ["CSV", "GeoJSON", "esriFeature", "ogcWfs", "ogcFeature", "GeoPackage"] + "enum": [ + "CSV", + "GeoJSON", + "esriFeature", + "ogcWfs", + "ogcFeature", + "GeoPackage" + ] }, "entryType": { - "enum": ["vector"] + "enum": [ + "vector" + ] }, "layerPathEnding": { "type": "string", @@ -763,7 +846,11 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeVectorTileLayerEntryConfig": { "additionalProperties": false, @@ -771,10 +858,14 @@ "description": "Layer sources providing vector data divided into a tile grid.", "properties": { "schemaTag": { - "enum": ["not used yet"] + "enum": [ + "not used yet" + ] }, "entryType": { - "enum": ["vector-tile"] + "enum": [ + "vector-tile" + ] }, "layerPathEnding": { "type": "string", @@ -810,7 +901,11 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeVectorTileSourceInitialConfig": { "additionalProperties": false, @@ -822,7 +917,14 @@ "description": "The path to reach the data to display. If not specified, metadatAccessPath will be assigned to it." }, "format": { - "enum": ["GeoJSON", "EsriJSON", "KML", "WFS", "MVT", "featureAPI"], + "enum": [ + "GeoJSON", + "EsriJSON", + "KML", + "WFS", + "MVT", + "featureAPI" + ], "description": "The feature format used by the XHR feature loader when access path is set." }, "dataProjection": { @@ -842,10 +944,14 @@ "type": "object", "properties": { "schemaTag": { - "enum": ["ogcWms"] + "enum": [ + "ogcWms" + ] }, "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "layerId": { "type": "string", @@ -880,17 +986,25 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeEsriDynamicLayerEntryConfig": { "additionalProperties": false, "type": "object", "properties": { "schemaTag": { - "enum": ["esriDynamic"] + "enum": [ + "esriDynamic" + ] }, "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "layerId": { "type": "string", @@ -925,17 +1039,25 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeEsriImageLayerEntryConfig": { "additionalProperties": false, "type": "object", "properties": { "schemaTag": { - "enum": ["esriImage"] + "enum": [ + "esriImage" + ] }, "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "layerId": { "type": "string", @@ -970,17 +1092,25 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeImageStaticLayerEntryConfig": { "additionalProperties": false, "type": "object", "properties": { "schemaTag": { - "enum": ["imageStatic"] + "enum": [ + "imageStatic" + ] }, "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "layerId": { "type": "string", @@ -1008,17 +1138,27 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeTileLayerEntryConfig": { "additionalProperties": false, "type": "object", "properties": { "schemaTag": { - "enum": ["ogcWms", "xyzTiles", "vectorTiles"] + "enum": [ + "ogcWms", + "xyzTiles", + "vectorTiles" + ] }, "entryType": { - "enum": ["raster-tile"] + "enum": [ + "raster-tile" + ] }, "layerPathEnding": { "type": "string", @@ -1046,10 +1186,20 @@ } } }, - "required": ["schemaTag", "entryType", "layerId"] + "required": [ + "schemaTag", + "entryType", + "layerId" + ] }, "TypeLayerEntryType": { - "enum": ["vector", "vector-tile", "raster-tile", "raster-image", "geoCore"], + "enum": [ + "vector", + "vector-tile", + "raster-tile", + "raster-image", + "geoCore" + ], "description": "Layer entry data type." }, "TypeLayerGroupEntryConfig": { @@ -1058,7 +1208,9 @@ "description": "Entry used to define a layer Group.", "properties": { "entryType": { - "enum": ["group"] + "enum": [ + "group" + ] }, "layerId": { "type": "string", @@ -1083,7 +1235,11 @@ "description": "The list of layer entry configurations to use from the GeoView layer group." } }, - "required": ["entryType", "layerId", "listOfLayerEntryConfig"] + "required": [ + "entryType", + "layerId", + "listOfLayerEntryConfig" + ] }, "TypeLayerEntryConfig": { "oneOf": [ @@ -1317,7 +1473,11 @@ "description": "Additional options used for OpenLayers map options" } }, - "required": ["basemapOptions", "interaction", "viewSettings"] + "required": [ + "basemapOptions", + "interaction", + "viewSettings" + ] }, "TypeBasemapOptions": { "additionalProperties": false, @@ -1337,20 +1497,39 @@ "description": "Enable or disable basemap labels" } }, - "required": ["basemapId", "shaded", "labeled"] + "required": [ + "basemapId", + "shaded", + "labeled" + ] }, "TypeBasemapId": { - "enum": ["transport", "osm", "simple", "nogeom", "shaded", "imagery"], + "enum": [ + "transport", + "osm", + "simple", + "nogeom", + "shaded", + "imagery" + ], "default": "transport", "description": "Id of the basemap to use." }, "TypeInteraction": { - "enum": ["static", "dynamic"], + "enum": [ + "static", + "dynamic" + ], "default": "dynamic", "description": "If map is dynamic (pan/zoom) or static to act as a thumbnail (no nav bar)." }, "TypeHighlightColors": { - "enum": ["black", "white", "red", "green"], + "enum": [ + "black", + "white", + "red", + "green" + ], "default": "black", "description": "Color to use for feature highlights." }, @@ -1406,7 +1585,10 @@ "description": "The projection code of the coordinates. Default value is 4326." } }, - "required": ["id", "coordinate"] + "required": [ + "id", + "coordinate" + ] }, "TypeListOfGeoviewLayerConfig": { "description": "List of GeoView Layers in the order which they should be added to the map.", @@ -1464,7 +1646,10 @@ "description": "The layer entries to use from the GeoView layer." } }, - "required": ["geoviewLayerType", "listOfLayerEntryConfig"] + "required": [ + "geoviewLayerType", + "listOfLayerEntryConfig" + ] }, "TypeGeoCoreLayerConfig": { "additionalProperties": false, @@ -1487,7 +1672,10 @@ "description": "Initial settings to apply to the GeoView layer at creation time." } }, - "required": ["geoviewLayerId", "geoviewLayerType"] + "required": [ + "geoviewLayerId", + "geoviewLayerType" + ] }, "TypeGeoviewLayerType": { "type": "string", @@ -1512,7 +1700,9 @@ "TypeGeoCoreLayerType": { "type": "string", "items": { - "enum": ["geoCore"] + "enum": [ + "geoCore" + ] }, "description": "Type of GeoCore layer." }, @@ -1536,7 +1726,12 @@ "items": { "type": "number" }, - "default": [-125, 30, -60, 89], + "default": [ + -125, + 30, + -60, + 89 + ], "description": "The extent that constrains the view. Called with [minX, minY, maxX, maxY] extent coordinates." }, "minZoom": { @@ -1619,7 +1814,10 @@ "description": "Initial zoom and center coordinates to set map view." }, "TypeValidMapProjectionCodes": { - "enum": [3978, 3857], + "enum": [ + 3978, + 3857 + ], "default": 3978, "description": "Spatial Reference EPSG code supported (https://epsg.io/). We support Web Mercator and Lambert Conical Conform Canada." }, @@ -1627,9 +1825,18 @@ "type": "array", "uniqueItems": true, "items": { - "enum": ["zoom", "fullscreen", "home", "location"] + "enum": [ + "zoom", + "fullscreen", + "home", + "location" + ] }, - "default": ["zoom", "fullscreen", "home"], + "default": [ + "zoom", + "fullscreen", + "home" + ], "description": "Controls available on the navigation bar.", "minItems": 0 }, @@ -1645,10 +1852,22 @@ "type": "array", "items": { "type": "string", - "enum": ["legend", "layers", "details", "data-table", "time-slider", "geochart"] + "enum": [ + "legend", + "layers", + "details", + "data-table", + "time-slider", + "geochart" + ] }, "minItems": 1, - "default": ["legend", "layers", "details", "data-table"], + "default": [ + "legend", + "layers", + "details", + "data-table" + ], "uniqueItems": true, "description": "Default core tabs of footer bar to use. NOTE: config from packages for time-slider and geochart are in the same loaction as core config (<>-<>.json)." }, @@ -1683,11 +1902,21 @@ }, "selectedTab": { "type": "string", - "enum": ["legend", "layers", "details", "data-table", "time-slider", "geochart"], + "enum": [ + "legend", + "layers", + "details", + "data-table", + "time-slider", + "geochart", + "" + ], "description": "Footer tab to be selected at map load" } }, - "required": ["tabs"] + "required": [ + "tabs" + ] }, "TypeAppBarProps": { "type": "object", @@ -1701,10 +1930,20 @@ "type": "array", "items": { "type": "string", - "enum": ["geolocator", "export", "basemap-panel", "geochart", "details", "legend", "guide"] + "enum": [ + "geolocator", + "export", + "basemap-panel", + "geochart", + "details", + "legend", + "guide" + ] }, "minItems": 0, - "default": ["geolocator"], + "default": [ + "geolocator" + ], "uniqueItems": true, "description": "Default core tabs of app-bar to use. NOTE: config from packages like geochart are in the same loaction as core config (<>-<>.json)." } @@ -1718,11 +1957,20 @@ }, "selectedTab": { "type": "string", - "enum": ["geolocator", "basemap-panel", "geochart", "details", "legend", "guide"], + "enum": [ + "geolocator", + "basemap-panel", + "geochart", + "details", + "legend", + "guide" + ], "description": "App bar tab to be selected at map load" } }, - "required": ["tabs"] + "required": [ + "tabs" + ] }, "TypeOverviewMapProps": { "type": "object", @@ -1741,9 +1989,15 @@ "type": "array", "uniqueItems": true, "items": { - "enum": ["overview-map", "north-arrow"] + "enum": [ + "overview-map", + "north-arrow" + ] }, - "default": ["overview-map", "north-arrow"], + "default": [ + "overview-map", + "north-arrow" + ], "description": "Core components to initialize on viewer load. The schema for those are inside this file.", "minItems": 0 }, @@ -1751,7 +2005,9 @@ "type": "array", "uniqueItems": true, "items": { - "enum": ["swiper"] + "enum": [ + "swiper" + ] }, "default": [], "description": "Core map packages to initialize on viewer load. The schema for those are on their own package. NOTE: config from packages are in the same loaction as core config (<>-<>.json).", @@ -1772,7 +2028,9 @@ "description": "The url to the external package configuration setting. The core package will read the configuration and pass it inside the package." } }, - "required": ["name"] + "required": [ + "name" + ] }, "default": [], "description": "List of external packages to initialize on viewer load.", @@ -1797,14 +2055,22 @@ "description": "Service end point to access geo location of searched value." } }, - "required": ["geocoreUrl"] + "required": [ + "geocoreUrl" + ] }, "TypeDisplayLanguage": { - "enum": ["en", "fr"], + "enum": [ + "en", + "fr" + ], "description": "Display languages supported." }, "TypeLocalizedLanguages": { - "enum": ["en", "fr"], + "enum": [ + "en", + "fr" + ], "description": "ISO 639-1 code indicating the languages supported by the configuration file." }, "TypeListOfLocalizedLanguages": { @@ -1813,12 +2079,17 @@ "items": { "$ref": "#/definitions/TypeLocalizedLanguages" }, - "default": ["en", "fr"], + "default": [ + "en", + "fr" + ], "description": "ISO 639-1 code indicating the languages supported by the configuration file. It will use value(s) provided here to access bilangual configuration nodes. For value(s) provided here, each bilingual configuration node MUST provide a value.", "minItems": 1 }, "TypeValidVersions": { - "enum": ["1.0"], + "enum": [ + "1.0" + ], "description": "The schema version that can be used to validate the configuration file. The schema should enumerate the list of versions accepted by this version of the viewer." }, "TypeGlobalSettings": { @@ -1844,7 +2115,11 @@ "$ref": "#/definitions/TypeMapConfig" }, "theme": { - "enum": ["dark", "light", "geo.ca"], + "enum": [ + "dark", + "light", + "geo.ca" + ], "default": "dark", "description": "Theme style the viewer." }, @@ -1879,7 +2154,9 @@ "$ref": "#/definitions/TypeGlobalSettings" } }, - "required": ["map"] + "required": [ + "map" + ] } } -} +} \ No newline at end of file diff --git a/packages/geoview-core/src/api/config/types/classes/map-feature-config.ts b/packages/geoview-core/src/api/config/types/classes/map-feature-config.ts index efd11d41750..b5793088747 100644 --- a/packages/geoview-core/src/api/config/types/classes/map-feature-config.ts +++ b/packages/geoview-core/src/api/config/types/classes/map-feature-config.ts @@ -213,12 +213,15 @@ export class MapFeatureConfig { ? this.map.viewSettings.projection : CV_DEFAULT_MAP_FEATURE_CONFIG.map.viewSettings.projection; - this.#validateCenter(); - - // zoom cannot be undefined because undefined values were set with default values. - const zoom = this.map.viewSettings.initialView!.zoomAndCenter![0]; - this.map.viewSettings.initialView!.zoomAndCenter![0] = - !Number.isNaN(zoom) && zoom >= 0 && zoom <= 28 ? zoom : CV_DEFAULT_MAP_FEATURE_CONFIG.map.viewSettings.initialView!.zoomAndCenter![0]; + // TODO: add validation for extent and layerIds + if (this.map.viewSettings.initialView!.zoomAndCenter) { + this.#validateCenter(); + const zoom = this.map.viewSettings.initialView!.zoomAndCenter![0]; + this.map.viewSettings.initialView!.zoomAndCenter![0] = + !Number.isNaN(zoom) && zoom >= 0 && zoom <= 28 + ? zoom + : CV_DEFAULT_MAP_FEATURE_CONFIG.map.viewSettings.initialView!.zoomAndCenter![0]; + } this.#validateBasemap(); @@ -233,7 +236,7 @@ export class MapFeatureConfig { this.map.viewSettings.maxZoom = !Number.isNaN(maxZoom) && maxZoom >= 0 && maxZoom <= 50 ? maxZoom : CV_DEFAULT_MAP_FEATURE_CONFIG.map.viewSettings.maxZoom; - this.#validateMaxExtent(); + if (this.map.viewSettings.initialView!.zoomAndCenter) this.#validateMaxExtent(); this.#logModifs(providedMapConfig); } diff --git a/packages/geoview-core/src/api/config/types/config-validation-schema.json b/packages/geoview-core/src/api/config/types/config-validation-schema.json index 04391f35627..39a79ae5c1f 100644 --- a/packages/geoview-core/src/api/config/types/config-validation-schema.json +++ b/packages/geoview-core/src/api/config/types/config-validation-schema.json @@ -50,7 +50,9 @@ "$ref": "#/definitions/TypeGlobalSettings" } }, - "required": ["map"] + "required": [ + "map" + ] }, "TypeMapConfig": { "additionalProperties": false, @@ -81,7 +83,11 @@ "type": "object" } }, - "required": ["basemapOptions", "interaction", "viewSettings"] + "required": [ + "basemapOptions", + "interaction", + "viewSettings" + ] }, "TypeListOfAbstractGeoviewLayerConfig": { "description": "The list of geoview layer configurations. The map config validation ends here. The only thing we need to verify for the moment is it must be an array.", @@ -90,13 +96,23 @@ "TypeDisplayTheme": { "description": "Valid values for the theme property.", "additionalProperties": false, - "enum": ["dark", "light", "geo.ca"], + "enum": [ + "dark", + "light", + "geo.ca" + ], "default": "geo.ca" }, "TypeValidNavBarProps": { "description": "Valid values for the navBar array.", "additionalProperties": false, - "enum": ["zoom", "fullscreen", "home", "location", "basemap-select"] + "enum": [ + "zoom", + "fullscreen", + "home", + "location", + "basemap-select" + ] }, "TypeNavBarProps": { "description": "Controls available on the navigation bar.", @@ -106,13 +122,25 @@ "items": { "$ref": "#/definitions/TypeValidNavBarProps" }, - "default": ["zoom", "fullscreen", "home", "basemap-select"], + "default": [ + "zoom", + "fullscreen", + "home", + "basemap-select" + ], "minItems": 0 }, "TypeValidFooterBarTabsCoreProps": { "description": "Valid values for the footerBar tabs core array.", "additionalProperties": false, - "enum": ["legend", "layers", "details", "data-table", "time-slider", "geochart"] + "enum": [ + "legend", + "layers", + "details", + "data-table", + "time-slider", + "geochart" + ] }, "TypeFooterBarTabsCustomProps": { "description": "Footer bar tabs custom definition.", @@ -145,7 +173,12 @@ "$ref": "#/definitions/TypeValidFooterBarTabsCoreProps" }, "minItems": 1, - "default": ["legend", "layers", "details", "data-table"], + "default": [ + "legend", + "layers", + "details", + "data-table" + ], "uniqueItems": true }, "custom": { @@ -168,16 +201,36 @@ }, "selectedTab": { "type": "string", - "enum": ["legend", "layers", "details", "data-table", "time-slider", "geochart"], + "enum": [ + "legend", + "layers", + "details", + "data-table", + "time-slider", + "geochart" + ], "description": "Footer tab to be selected at map load" } }, - "required": ["tabs"] + "required": [ + "tabs" + ] }, "TypeValidAppBarCoreProps": { "description": "Valid values for the app bar tabs core array.", "additionalProperties": false, - "enum": ["geolocator", "export", "basemap-panel", "geochart", "details", "legend", "guide", "data-table", "layers", "aoi-panel"] + "enum": [ + "geolocator", + "export", + "basemap-panel", + "geochart", + "details", + "legend", + "guide", + "data-table", + "layers", + "aoi-panel" + ] }, "TypeAppBarProps": { "type": "object", @@ -195,7 +248,9 @@ "$ref": "#/definitions/TypeValidAppBarCoreProps" }, "minItems": 0, - "default": ["geolocator"], + "default": [ + "geolocator" + ], "uniqueItems": true } } @@ -207,11 +262,24 @@ }, "selectedTab": { "type": "string", - "enum": ["geolocator", "basemap-panel", "geochart", "details", "legend", "guide", "data-table", "layers", "aoi-panel"], + "enum": [ + "geolocator", + "basemap-panel", + "geochart", + "details", + "legend", + "guide", + "data-table", + "layers", + "aoi-panel", + "" + ], "description": "App bar tab to be selected at map load" } }, - "required": ["tabs"] + "required": [ + "tabs" + ] }, "TypeOverviewMapProps": { "type": "object", @@ -229,7 +297,10 @@ "TypeValidMapComponentProps": { "description": "Valid values for the map component array.", "additionalProperties": false, - "enum": ["overview-map", "north-arrow"] + "enum": [ + "overview-map", + "north-arrow" + ] }, "TypeMapComponents": { "description": "Core components to initialize on viewer load. The schema for those are inside this file.", @@ -239,13 +310,18 @@ "items": { "$ref": "#/definitions/TypeValidMapComponentProps" }, - "default": ["overview-map", "north-arrow"], + "default": [ + "overview-map", + "north-arrow" + ], "minItems": 0 }, "TypeValidMapCorePackageProps": { "description": "Valid values for the map core package array.", "additionalProperties": false, - "enum": ["swiper"] + "enum": [ + "swiper" + ] }, "TypeMapCorePackages": { "description": "Core map packages to initialize on viewer load. The schema for those are on their own package. NOTE: config from packages are in the same loaction as core config (<>-<>.json).", @@ -271,7 +347,9 @@ "type": "string" } }, - "required": ["name"] + "required": [ + "name" + ] }, "TypeExternalPackages": { "description": "List of external packages to initialize on viewer load.", @@ -307,7 +385,9 @@ }, "TypeValidVersions": { "description": "The schema version that can be used to validate the configuration file. The schema should enumerate the list of versions accepted by this version of the viewer.", - "enum": ["1.0"] + "enum": [ + "1.0" + ] }, "TypeGlobalSettings": { "additionalProperties": false, @@ -339,17 +419,31 @@ "default": true } }, - "required": ["basemapId", "shaded", "labeled"] + "required": [ + "basemapId", + "shaded", + "labeled" + ] }, "TypeBasemapId": { "description": "Id of the basemap to use.", - "enum": ["transport", "osm", "simple", "nogeom", "shaded", "imagery"], + "enum": [ + "transport", + "osm", + "simple", + "nogeom", + "shaded", + "imagery" + ], "default": "transport" }, "TypeInteraction": { "description": "If map is dynamic (pan/zoom) or static to act as a thumbnail (no nav bar).", "additionalProperties": false, - "enum": ["static", "dynamic"], + "enum": [ + "static", + "dynamic" + ], "default": "dynamic" }, "AbstractGeoviewLayerConfig": { @@ -407,7 +501,9 @@ "const": true } }, - "required": ["useInternalSchema"] + "required": [ + "useInternalSchema" + ] }, "then": { "description": "Use Internal Schema", @@ -435,7 +531,10 @@ } } }, - "required": ["geoviewLayerType", "listOfLayerEntryConfig"] + "required": [ + "geoviewLayerType", + "listOfLayerEntryConfig" + ] }, "TypeListOfLayerEntryConfig": { "description": "The list of layer configurations. The AbstractGeoviewLayerConfig validation ends here. The only thing we need to verify for the moment is it must be an array of at least one element.", @@ -469,7 +568,12 @@ "items": { "type": "number" }, - "default": [-125, 30, -60, 89] + "default": [ + -125, + 30, + -60, + 89 + ] }, "minZoom": { "description": "The minimum zoom level used to determine the resolution constraint. If not set, will use default from basemap.", @@ -492,7 +596,12 @@ "TypeHighlightColors": { "description": "Color to use for feature highlights.", "additionalProperties": false, - "enum": ["black", "white", "red", "green"], + "enum": [ + "black", + "white", + "red", + "green" + ], "default": "black" }, "TypeOverlayObjects": { @@ -548,11 +657,17 @@ "default": 4326 } }, - "required": ["id", "coordinate"] + "required": [ + "id", + "coordinate" + ] }, "TypeDisplayLanguage": { "description": "Display languages supported.", - "enum": ["en", "fr"] + "enum": [ + "en", + "fr" + ] }, "TypeGeoviewLayerType": { "description": "Type of GeoView layer.", @@ -744,16 +859,29 @@ } ] ], - "default": [4.5, [-90, 67]] + "default": [ + 4.5, + [ + -90, + 67 + ] + ] }, "TypeValidMapProjectionCodes": { "description": "Spatial Reference EPSG code supported (https://epsg.io/). We support Web Mercator and Lambert Conical Conform Canada.", - "enum": [3978, 3857], + "enum": [ + 3978, + 3857 + ], "default": 3978 }, "TypeValidSourceProjectionCodes": { "description": "Spatial Reference EPSG code supported (https://epsg.io/). We support Web Mercator and Lambert Conical Conform Canada.", - "enum": [3978, 3857, 4326], + "enum": [ + 3978, + 3857, + 4326 + ], "default": 3978 }, "EsriDynamicLayerConfig": { @@ -768,7 +896,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["esriDynamic"] + "enum": [ + "esriDynamic" + ] } } } @@ -786,7 +916,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["esriImage"] + "enum": [ + "esriImage" + ] } } } @@ -804,7 +936,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["esriFeature"] + "enum": [ + "esriFeature" + ] } } } @@ -822,7 +956,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["ogcWms"] + "enum": [ + "ogcWms" + ] } } } @@ -840,7 +976,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["ogcWfs"] + "enum": [ + "ogcWfs" + ] } } } @@ -858,7 +996,9 @@ "type": "object", "properties": { "geoviewLayerType": { - "enum": ["GeoJSON"] + "enum": [ + "GeoJSON" + ] } } } @@ -924,7 +1064,9 @@ "const": true } }, - "required": ["useInternalSchema"] + "required": [ + "useInternalSchema" + ] }, "then": { "description": "Use Internal Schema", @@ -938,7 +1080,11 @@ "$ref": "#/definitions/TypeLayerEntryType" } }, - "required": ["entryType", "layerId", "layerName"] + "required": [ + "entryType", + "layerId", + "layerName" + ] }, "else": { "description": "Use Input Schema", @@ -955,7 +1101,9 @@ } } }, - "required": ["layerId"] + "required": [ + "layerId" + ] }, "errorMessage": { "if": "The data does not respect the EntryConfigBaseClass schema definition." @@ -998,7 +1146,9 @@ "type": "object", "properties": { "entryType": { - "enum": ["group"] + "enum": [ + "group" + ] }, "listOfLayerEntryConfig": { "description": "The list of layer entry configurations to use from the GeoView layer group.", @@ -1027,7 +1177,9 @@ } }, "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "source": { "$ref": "#/definitions/TypeSourceEsriDynamicInitialConfig" @@ -1051,7 +1203,9 @@ "type": "object", "properties": { "entryType": { - "enum": ["raster-image"] + "enum": [ + "raster-image" + ] }, "source": { "$ref": "#/definitions/TypeSourceEsriImageInitialConfig" @@ -1156,7 +1310,14 @@ }, "TypeStyleGeometry": { "description": "Valid keys for the geometryType property.", - "enum": ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"] + "enum": [ + "Point", + "MultiPoint", + "LineString", + "MultiLineString", + "Polygon", + "MultiPolygon" + ] }, "TypeBaseSourceInitialConfig": { "description": "Base type from which we derive the source properties for all the leaf nodes in the layer tree.", @@ -1226,7 +1387,11 @@ }, "TypeOfServer": { "description": "The type of the remote WMS server.", - "enum": ["mapserver", "geoserver", "qgis"], + "enum": [ + "mapserver", + "geoserver", + "qgis" + ], "default": "mapserver" }, "TypeSourceImageStaticInitialConfig": { @@ -1281,7 +1446,10 @@ }, "strategy": { "description": "The loading strategy to use. By default an all strategy is used, a one-off strategy which loads all features at once.", - "enum": ["all", "bbox"], + "enum": [ + "all", + "bbox" + ], "default": "all" } } @@ -1365,14 +1533,28 @@ "items": { "type": "number" }, - "default": [256, 256] + "default": [ + 256, + 256 + ] } }, - "required": ["origin", "resolutions"] + "required": [ + "origin", + "resolutions" + ] }, "TypeVectorSourceFormats": { "description": "The feature format used by the XHR feature loader when access path is set.", - "enum": ["GeoJSON", "EsriJSON", "KML", "WFS", "featureAPI", "GeoPackage", "CSV"] + "enum": [ + "GeoJSON", + "EsriJSON", + "KML", + "WFS", + "featureAPI", + "GeoPackage", + "CSV" + ] }, "TypeSourceEsriDynamicInitialConfig": { "description": "Type from which we derive the source properties for all the ESRI dynamic leaf nodes in the layer tree.", @@ -1432,7 +1614,12 @@ }, "TypeEsriFormatParameter": { "description": "The format of the exported image.", - "enum": ["png", "jpg", "gif", "svg"], + "enum": [ + "png", + "jpg", + "gif", + "svg" + ], "default": "png" }, "TypeSourceEsriFeatureInitialConfig": { @@ -1472,7 +1659,9 @@ } } }, - "required": ["queryable"] + "required": [ + "queryable" + ] }, "TypeOutfields": { "type": "object", @@ -1504,12 +1693,22 @@ ] } }, - "required": ["name", "alias", "type", "domain"] + "required": [ + "name", + "alias", + "type", + "domain" + ] }, "TypeOutfieldsType": { "description": "The types supported by the outfields object.", "additionalProperties": false, - "enum": ["string", "number", "date", "url"] + "enum": [ + "string", + "number", + "date", + "url" + ] }, "codedValueType": { "description": "Coded value definition.", @@ -1517,7 +1716,9 @@ "type": "object", "properties": { "type": { - "enum": ["codedValue"] + "enum": [ + "codedValue" + ] }, "name": { "description": "The domain name.", @@ -1552,7 +1753,9 @@ "type": "object", "properties": { "type": { - "enum": ["range"] + "enum": [ + "range" + ] }, "name": { "description": "The domain name.", @@ -1567,11 +1770,21 @@ } } }, - "required": ["type", "name", "range"] + "required": [ + "type", + "name", + "range" + ] }, "TypeLayerEntryType": { "description": "Layer entry data type.", - "enum": ["vector", "vector-tile", "raster-tile", "raster-image", "group"] + "enum": [ + "vector", + "vector-tile", + "raster-tile", + "raster-image", + "group" + ] }, "TypeTemporalDimension": { "additionalProperties": false, @@ -1591,7 +1804,10 @@ "$ref": "#/definitions/TypeRangeItems" }, "nearestValues": { - "enum": ["discrete", "absolute"] + "enum": [ + "discrete", + "absolute" + ] }, "singleHandle": { "type": "boolean" @@ -1667,7 +1883,11 @@ }, "TypeLayerStyleConfigType": { "description": "Valid keys for the type property of style configurations.", - "enum": ["simple", "uniqueValue", "classBreaks"] + "enum": [ + "simple", + "uniqueValue", + "classBreaks" + ] }, "TypeLayerStyleConfigInfo": { "type": "object", @@ -1737,7 +1957,12 @@ }, "TypeBaseVectorType": { "description": "Valid values for the type property of the base vector settings.", - "enum": ["lineString", "filledPolygon", "simpleSymbol", "iconSymbol"] + "enum": [ + "lineString", + "filledPolygon", + "simpleSymbol", + "iconSymbol" + ] }, "TypeLineStringVectorConfig": { "description": "Definition of the line symbol vector settings type.", @@ -1750,7 +1975,9 @@ "type": "object", "properties": { "type": { - "enum": ["lineString"] + "enum": [ + "lineString" + ] }, "stroke": { "$ref": "#/definitions/TypeStrokeSymbolConfig" @@ -1803,7 +2030,9 @@ "type": "object", "properties": { "type": { - "enum": ["filledPolygon"] + "enum": [ + "filledPolygon" + ] }, "color": { "type": "string" @@ -1832,7 +2061,16 @@ }, "TypeFillStyle": { "description": "Valid values to specify fill styles.", - "enum": ["null", "solid", "backwardDiagonal", "cross", "diagonalCross", "forwardDiagonal", "horizontal", "vertical"] + "enum": [ + "null", + "solid", + "backwardDiagonal", + "cross", + "diagonalCross", + "forwardDiagonal", + "horizontal", + "vertical" + ] }, "TypeSimpleSymbolVectorConfig": { "description": " Definition of the simple symbol vector settings type.", @@ -1845,7 +2083,9 @@ "type": "object", "properties": { "type": { - "enum": ["simpleSymbol"] + "enum": [ + "simpleSymbol" + ] }, "rotation": { "description": "Symbol rotation in radians.", @@ -1877,7 +2117,15 @@ }, "TypeSymbol": { "description": "Valid values to specify symbol shapes.", - "enum": ["circle", "+", "diamond", "square", "triangle", "X", "star"] + "enum": [ + "circle", + "+", + "diamond", + "square", + "triangle", + "X", + "star" + ] }, "TypeIconSymbolVectorConfig": { "type": "object", @@ -1889,7 +2137,9 @@ "type": "object", "properties": { "type": { - "enum": ["iconSymbol"] + "enum": [ + "iconSymbol" + ] }, "mimeType": { "type": "string" @@ -1946,10 +2196,19 @@ }, "data": { "description": "A required property that can be any type.", - "type": ["object", "array", "string", "number", "boolean", "null"] + "type": [ + "object", + "array", + "string", + "number", + "boolean", + "null" + ] } }, - "required": ["data"] + "required": [ + "data" + ] } } -} +} \ No newline at end of file diff --git a/packages/geoview-core/src/api/config/types/map-schema-types.ts b/packages/geoview-core/src/api/config/types/map-schema-types.ts index e06deba08b9..03cc6cc5b26 100644 --- a/packages/geoview-core/src/api/config/types/map-schema-types.ts +++ b/packages/geoview-core/src/api/config/types/map-schema-types.ts @@ -59,7 +59,8 @@ export type TypeValidAppBarCoreProps = | 'legend' | 'details' | 'data-table' - | 'layers'; + | 'layers' + | ''; /** Configuration available on the application bar. Default = ['geolocator']. The about GeoView and notification are always there. */ export type TypeAppBarProps = { 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 d3ad007f75b..267dad49b18 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 @@ -29,6 +29,7 @@ import { TypeGeoviewLayerConfig, TypeLayerEntryConfig, TypeMapConfig, + TypeMapFeaturesInstance, } from '@/geo/map/map-schema-types'; import { TypeRecordOfPlugin } from '@/api/plugin/plugin-types'; import { CONST_LAYER_TYPES } from '@/geo/layer/geoview-layers/abstract-geoview-layers'; @@ -1157,7 +1158,7 @@ export class MapEventProcessor extends AbstractEventProcessor { * Creates a map config based on current map state. * @param {string} mapId - Id of map. */ - static createMapConfigFromMapState(mapId: string): TypeMapFeaturesConfig | undefined { + static createMapConfigFromMapState(mapId: string): TypeMapFeaturesInstance | undefined { const config = MapEventProcessor.getGeoViewMapConfig(mapId); if (config) { @@ -1201,8 +1202,7 @@ export class MapEventProcessor extends AbstractEventProcessor { }; // Construct map config - const newMapConfig: TypeMapFeaturesConfig = { - mapId, + const newMapConfig: TypeMapFeaturesInstance = { map, theme: AppEventProcessor.getDisplayTheme(mapId), navBar: config.navBar, diff --git a/packages/geoview-core/src/geo/map/map-viewer.ts b/packages/geoview-core/src/geo/map/map-viewer.ts index a5307f87327..fc1bcf8dcae 100644 --- a/packages/geoview-core/src/geo/map/map-viewer.ts +++ b/packages/geoview-core/src/geo/map/map-viewer.ts @@ -33,7 +33,7 @@ import { LayerApi } from '@/geo/layer/layer'; import { TypeFeatureStyle } from '@/geo/layer/geometry/geometry-types'; import { Projection } from '@/geo/utils/projection'; -import { TypeOrderedLayerInfo, api, unmountMap } from '@/app'; +import { TypeMapFeaturesInstance, TypeOrderedLayerInfo, api, unmountMap } from '@/app'; import { Plugin } from '@/api/plugin/plugin'; import { TypeRecordOfPlugin } from '@/api/plugin/plugin-types'; @@ -1216,9 +1216,9 @@ export class MapViewer { /** * Reload a map from a config object stored in store, or provided. It first removes then recreates the map. - * @param {TypeMapFeaturesConfig} mapConfig - Optional map config to use for reload. + * @param {TypeMapFeaturesConfig | TypeMapFeaturesInstance} mapConfig - Optional map config to use for reload. */ - async reload(mapConfig?: TypeMapFeaturesConfig): Promise { + async reload(mapConfig?: TypeMapFeaturesConfig | TypeMapFeaturesInstance): Promise { // If no config is provided, get the original from the store const config = mapConfig || MapEventProcessor.getGeoViewMapConfig(this.mapId); @@ -1529,9 +1529,9 @@ export class MapViewer { /** * Creates a map config based on current map state. - * @returns {TypeMapFeaturesConfig | undefined} Map config with current map state. + * @returns {TypeMapFeaturesInstance | undefined} Map config with current map state. */ - createMapConfigFromMapState(): TypeMapFeaturesConfig | undefined { + createMapConfigFromMapState(): TypeMapFeaturesInstance | undefined { return MapEventProcessor.createMapConfigFromMapState(this.mapId); }