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 28, 2024
1 parent 7e6725d commit 60e6e4d
Show file tree
Hide file tree
Showing 21 changed files with 272 additions and 215 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 @@ -173,6 +173,24 @@ export class MapEventProcessor extends AbstractEventProcessor {
);
// #endregion FEATURE SELECTION

const unsubOrderedLayerInfo = store.subscribe(
(state) => state.mapState.orderedLayerInfo,
(cur) => {
// Log
logger.logTraceCoreStoreSubscription('MAP EVENT PROCESSOR - orderedLaterInfo', mapId, cur);

const curVisibleLayers = cur
.map((layerInfo) => {
if (layerInfo.visible) return layerInfo.layerPath;
return undefined;
})
.filter((layerPath) => layerPath);
const prevVisibleLayers = [...store.getState().mapState.visibleLayers];
if (JSON.stringify(prevVisibleLayers) !== JSON.stringify(curVisibleLayers))
store.getState().mapState.actions.setVisibleLayers(curVisibleLayers as string[]);
}
);

// Return the array of subscriptions so they can be destroyed later
return [
unsubMapHighlightedFeatures,
Expand All @@ -181,6 +199,7 @@ export class MapEventProcessor extends AbstractEventProcessor {
unsubMapPointerPosition,
unsubMapProjection,
unsubMapSelectedFeatures,
unsubOrderedLayerInfo,
unsubMapZoom,
unsubMapSingleClick,
];
Expand Down Expand Up @@ -421,15 +440,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
Expand Up @@ -11,8 +11,8 @@ import {
useDetailsStoreActions,
useDetailsStoreAllFeaturesDataArray,
useUIActiveFooterBarTabId,
useMapOrderedLayerInfo,
useDatatableStoreTableHeight,
useMapVisibleLayers,
} from '@/core/stores';
import { LayerListEntry, Layout } from '../common';
import { logger } from '@/core/utils/logger';
Expand Down Expand Up @@ -48,7 +48,7 @@ export function Datapanel({ fullWidth }: DataPanelType) {
const { setSelectedLayerPath } = useDataTableStoreActions();
const { triggerGetAllFeatureInfo } = useDetailsStoreActions();
const selectedTab = useUIActiveFooterBarTabId();
const orderedLayerInfo = useMapOrderedLayerInfo();
const visibleLayers = useMapVisibleLayers();

// Create columns for data table.
const mappedLayerData = useFeatureFieldInfos(layerData);
Expand All @@ -57,17 +57,10 @@ export function Datapanel({ fullWidth }: DataPanelType) {
* Order the layers by visible layer order.
*/
const orderedLayerData = useMemo(() => {
const visibleLayers = orderedLayerInfo
.map((layerInfo) => {
if (layerInfo.visible) return layerInfo.layerPath;
return undefined;
})
.filter((layerPath) => layerPath !== undefined);

return visibleLayers
.map((layerPath) => mappedLayerData.filter((data) => data.layerPath === layerPath)[0])
.filter((layer) => layer !== undefined);
}, [mappedLayerData, orderedLayerInfo]);
}, [mappedLayerData, visibleLayers]);

/**
* Update local states when layer is changed from layer list.
Expand Down
Loading

0 comments on commit 60e6e4d

Please sign in to comment.