Skip to content

Commit

Permalink
refactor(geocore): refactor geocore to match other layer structure
Browse files Browse the repository at this point in the history
Closes #1852
  • Loading branch information
DamonU2 committed Feb 27, 2024
1 parent 0ce303d commit bc03de3
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 157 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/type-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
schedule:
- cron: "42 21 * * 5"

env:
NODE_VERSION: "20.11.0"
PNPM_VERSION: "8.15.0"

jobs:
update_types:
runs-on: ubuntu-latest
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions packages/geoview-core/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@
"loadfailed": "Layer [__param__] failed to load on map __param__.",
"notfound": "The sublayer __param__ of the GeoView layer __param__ does not exist on the server",
"createtwice": "Can not execute twice the createGeoViewRasterLayers method for the map __param__",
"usedtwice": "Duplicate use of geoview layer identifier [__param__] on map __param__"
"usedtwice": "Duplicate use of geoview layer identifier [__param__] on map __param__",
"multipleUUID": "GeoCore layers may only have one GeoCore UUID per layer"
},
"schema": {
"notFound": "A schema error was found, check the console to see what is wrong.",
Expand Down Expand Up @@ -219,4 +220,4 @@
"resizeTooltip": "Resize",
"noTab": "No Tab"
}
}
}
5 changes: 3 additions & 2 deletions packages/geoview-core/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@
"loadfailed": "Le chargement de la couche [__param__] a échoué sur la carte __param__.",
"notfound": "La sous couche __param__ de la couche GeoView __param__ n'existe pas sur le sereur",
"createtwice": "On ne peut exécuter deux fois la méthode createGeoViewRasterLayers pour la carte __param__",
"usedtwice": "Utilisation en double de l'identifiant de couche geoview [__param__] sur la carte __param__"
"usedtwice": "Utilisation en double de l'identifiant de couche geoview [__param__] sur la carte __param__",
"multipleUUID": "Les couches GeoCore ne peuvent avoir qu'un seul UUID GeoCore par couche."
},
"schema": {
"notFound": "Une erreur de schéma a été trouvée, vérifiez la console pour voir ce qui ne va pas.",
Expand Down Expand Up @@ -219,4 +220,4 @@
"resizeTooltip": "Redimensionner",
"noTab": "Pas d'onglet"
}
}
}
169 changes: 102 additions & 67 deletions packages/geoview-core/public/templates/layers/geocore.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,23 @@ <h4 id="HLYR1">1. Many GeoCore Layers</h4>
'listOfGeoviewLayerConfig': [
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'airborneRad',
'listOfLayerEntryConfig': [
{
'layerId': '0fe65119-e96e-4a57-8bfe-9d9245fba06b',
'geocoreLayerName': { 'en': 'HRDEM Mosaic Hillshade' },
'layerId': '21b821cf-0f1c-40ee-8925-eab12d357668',
'geocoreLayerName': { 'en': 'Airborne Radioactivity' },
'listOfLayerEntryConfig': [
{
'layerId': 'dsm-hillshade',
'layerName': { 'en': 'Map' },
'source': {
'style': 'hillshade'
}
'layerId': '0'
}
]
},
}
]
},
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'commem',
'listOfLayerEntryConfig': [
{
'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
'geocoreLayerName': { 'en': 'Commemorative Map' },
Expand All @@ -98,7 +101,13 @@ <h4 id="HLYR1">1. Many GeoCore Layers</h4>
'layerId': '0'
}
]
},
}
]
},
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'MWQ',
'listOfLayerEntryConfig': [
{
'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
'geocoreLayerName': { 'en': 'Marine Water Quality' },
Expand All @@ -107,8 +116,13 @@ <h4 id="HLYR1">1. Many GeoCore Layers</h4>
'layerId': '6'
}
]
},
}
]
},
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'napl',
'listOfLayerEntryConfig': [
{
'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
Expand Down Expand Up @@ -160,65 +174,86 @@ <h4 id="HLYR2">2. GeoCore Layers - with footer bar</h4>
triggerReadyCallback="true"
data-lang="en"
data-config="{
'map': {
'interaction': 'dynamic',
'viewSettings': {
'zoom': 4,
'center': [-100, 60],
'projection': 3978
'map': {
'interaction': 'dynamic',
'viewSettings': {
'zoom': 4,
'center': [-100, 60],
'projection': 3978
},
'basemapOptions': {
'basemapId': 'transport',
'shaded': false,
'labeled': true
},
'listOfGeoviewLayerConfig': [
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'airborneRad',
'listOfLayerEntryConfig': [
{
'layerId': '21b821cf-0f1c-40ee-8925-eab12d357668',
'geocoreLayerName': { 'en': 'Airborne Radioactivity' },
'listOfLayerEntryConfig': [
{
'layerId': '0'
}
]
}
]
},
'basemapOptions': {
'basemapId': 'transport',
'shaded': false,
'labeled': true
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'commem',
'listOfLayerEntryConfig': [
{
'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
'geocoreLayerName': { 'en': 'Commemorative Map' },
'listOfLayerEntryConfig': [
{
'layerId': '0'
}
]
}
]
},
'listOfGeoviewLayerConfig': [
{
'geoviewLayerType': 'geoCore',
'listOfLayerEntryConfig': [
{
'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
'geocoreLayerName': { 'en': 'Commemorative Map' },
'listOfLayerEntryConfig': [
{
'layerId': '0'
}
]
},
{
'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
'geocoreLayerName': { 'en': 'Marine Water Quality' },
'listOfLayerEntryConfig': [
{
'layerId': '6'
}
]
},
{
'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
'listOfLayerEntryConfig': [
{
'layerId': 'regina',
'layerName': { 'en': 'Map of Regina' }
}
]
}
]
}
]
},
'components': ['overview-map'],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table']
{
'geoviewLayerType': 'geoCore',
'geoviewLayerId': 'MWQ',
'listOfLayerEntryConfig': [
{
'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
'geocoreLayerName': { 'en': 'Marine Water Quality' },
'listOfLayerEntryConfig': [
{
'layerId': '6'
}
]
},
{
'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
'listOfLayerEntryConfig': [
{
'layerId': 'regina',
'layerName': { 'en': 'Map of Regina' }
}
]
}
]
}
},
'corePackages': [],
'theme': 'geo.ca',
'suportedLanguages': ['en']
}"
]
},
'components': ['overview-map'],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table']
}
},
'corePackages': [],
'theme': 'geo.ca',
'suportedLanguages': ['en']
}"
></div>

<script src="codedoc.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions packages/geoview-core/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@
},
"required": ["schemaTag", "entryType", "layerId"]
},
"TypeGeocoreLayerEntryConfig": {
"TypeGeoCoreLayerEntryConfig": {
"additionalProperties": false,
"type": "object",
"description": "Layer where configration is extracted by a configuration snippet stored on a server. The server configuration will handle bilangual informations.",
Expand Down Expand Up @@ -1221,7 +1221,7 @@
"$ref": "#/definitions/TypeTileLayerEntryConfig"
},
{
"$ref": "#/definitions/TypeGeocoreLayerEntryConfig"
"$ref": "#/definitions/TypeGeoCoreLayerEntryConfig"
}
]
},
Expand Down Expand Up @@ -1396,7 +1396,7 @@
"$ref": "#/definitions/TypeLayerGroupEntryConfig"
},
{
"$ref": "#/definitions/TypeGeocoreLayerEntryConfig"
"$ref": "#/definitions/TypeGeoCoreLayerEntryConfig"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,20 @@ export class MapEventProcessor extends AbstractEventProcessor {
*
* @param {string} mapId The ID of the map to add the layer to.
* @param {TypeGeoviewLayerConfig} geoviewLayerConfig The config of the layer to add.
* @param {string} layerPathToReplace The layerPath of the info to replace.
* @return {void}
*/
static replaceOrderedLayerInfo(mapId: string, geoviewLayerConfig: TypeGeoviewLayerConfig | TypeLayerEntryConfig): void {
static replaceOrderedLayerInfo(
mapId: string,
geoviewLayerConfig: TypeGeoviewLayerConfig | TypeLayerEntryConfig,
layerPathToReplace?: string
): void {
const { orderedLayerInfo } = this.getMapStateProtected(mapId);
const layerPath = (geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId
? `${(geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId}/${(geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId}`
: (geoviewLayerConfig as TypeLayerEntryConfig).layerPath;
const index = this.getMapIndexFromOrderedLayerInfo(mapId, layerPath);
const replacedLayers = orderedLayerInfo.filter((layerInfo) => layerInfo.layerPath.startsWith(layerPath));
const index = this.getMapIndexFromOrderedLayerInfo(mapId, layerPathToReplace || layerPath);
const replacedLayers = orderedLayerInfo.filter((layerInfo) => layerInfo.layerPath.startsWith(layerPathToReplace || layerPath));
const newOrderedLayerInfo = api.maps[mapId].layer.generateArrayOfLayerOrderInfo(geoviewLayerConfig);
orderedLayerInfo.splice(index, replacedLayers.length, ...newOrderedLayerInfo);
this.setMapOrderedLayerInfo(mapId, orderedLayerInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO Remove when no longer needed
import _ from 'lodash';
import { TypeVectorLayerStyles } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { api } from '@/app';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ export function AddNewLayer(): JSX.Element {
const geoCoreGeoviewLayerInstance = new GeoCore(mapId);
const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL);
if (layers.length === 1) {
if (layers[0].length === 1) {
setLayerName(layers[0][0].geoviewLayerName!.en! as string);
setLayerEntries(layers[0]);
if (layers.length === 1) {
setLayerName(layers[0].geoviewLayerName!.en! as string);
setLayerEntries(layers);
} else {
setLayerList(layers[0]);
setLayerList(layers);
}
}
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export const CONST_GEOVIEW_SCHEMA_BY_TYPE: Record<TypeGeoviewLayerType, string>
esriFeature: 'TypeVectorLayerEntryConfig',
esriImage: 'TypeEsriImageLayerEntryConfig',
GeoJSON: 'TypeVectorLayerEntryConfig',
geoCore: 'TypeGeocoreLayerEntryConfig',
geoCore: 'TypeGeoCoreLayerEntryConfig',
GeoPackage: 'TypeVectorLayerEntryConfig',
xyzTiles: 'TypeTileLayerEntryConfig',
vectorTiles: 'TypeTileLayerEntryConfig',
Expand Down
Loading

0 comments on commit bc03de3

Please sign in to comment.