Skip to content

Commit

Permalink
Merge pull request Canadian-Geospatial-Platform#1773 from ychoquet/BU…
Browse files Browse the repository at this point in the history
…G=raw-feature-info_on_load

BUG=raw-feature-info on load (Canadian-Geospatial-Platform#1773)
  • Loading branch information
jolevesq authored Feb 8, 2024
2 parents 5d8ba1b + 55f7cfe commit 4d8cd51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '@/api/events/payloads';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';
import { EsriImage, layerConfigIsEsriImage } from './raster/esri-image';
import { logger } from '@/core/utils/logger';

/** ***************************************************************************************************************************
* This method reads the service metadata from the metadataAccessPath.
Expand All @@ -47,11 +48,12 @@ export async function commonfetchServiceMetadata(this: EsriDynamic | EsriFeature
if (metadataString === '{}') this.setAllLayerStatusTo('error', this.listOfLayerEntryConfig, 'Unable to read metadata');
else {
this.metadata = JSON.parse(metadataString) as TypeJsonObject;
if ('error' in this.metadata) throw new Error(`Error code = ${this.metadata.error.code}, ${this.metadata.error.message}`);
const { copyrightText } = this.metadata;
if (copyrightText) this.attributions.push(copyrightText as string);
}
} catch (error) {
console.log(error);
logger.logInfo('Unable to read metadata', error);
this.setAllLayerStatusTo('error', this.listOfLayerEntryConfig, 'Unable to read metadata');
}
} else {
Expand All @@ -70,9 +72,10 @@ export function commonValidateListOfLayerEntryConfig(this: EsriDynamic | EsriFea
this.setLayerPhase('validateListOfLayerEntryConfig');
listOfLayerEntryConfig.forEach((layerConfig: TypeLayerEntryConfig, i) => {
const { layerPath } = layerConfig;
if (layerConfig.layerStatus === 'error') return;
if (layerEntryIsGroupLayer(layerConfig)) {
this.validateListOfLayerEntryConfig(layerConfig.listOfLayerEntryConfig!);
if (!layerConfig.listOfLayerEntryConfig.length) {
if (!(layerConfig as TypeLayerGroupEntryConfig).listOfLayerEntryConfig.length) {
this.layerLoadError.push({
layer: layerPath,
consoleMessage: `Empty layer group (mapId: ${this.mapId}, layerPath: ${layerPath})`,
Expand Down Expand Up @@ -112,7 +115,7 @@ export function commonValidateListOfLayerEntryConfig(this: EsriDynamic | EsriFea
const newListOfLayerEntryConfig: TypeListOfLayerEntryConfig = [];
// Group layer are not registered to layer sets.
if (this.registerToLayerSetListenerFunctions[layerPath]) this.unregisterFromLayerSets(layerConfig as TypeBaseLayerEntryConfig);
const switchToGroupLayer = cloneDeep(layerConfig);
const switchToGroupLayer = Cast<TypeLayerGroupEntryConfig>(cloneDeep(layerConfig));
switchToGroupLayer.entryType = 'group';
switchToGroupLayer.layerName = {
en: this.metadata!.layers[esriIndex].name as string,
Expand Down
2 changes: 1 addition & 1 deletion packages/geoview-core/src/geo/map/map-schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,10 @@ export abstract class TypeBaseLayerEntryConfig extends ConfigBaseClass {

// Definition of the load end listener functions
const loadEndListener = () => {
this.loadedFunction();
this.geoviewLayerInstance!.setLayerPhase('loaded', this.layerPath);
this.geoviewLayerInstance!.setLayerStatus('loaded', this.layerPath);
this._olLayer!.get('source').un(`${loadEndListenerType}loaderror`, loadErrorListener);
this.loadedFunction();
};

loadErrorListener = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/geoview-core/src/geo/map/map-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class MapViewer {
mapIsReady(): boolean {
if (this.layer === undefined) return false;
return !Object.keys(this.layer.geoviewLayers).find((geoviewLayerId) => {
return !this.layer.geoviewLayers[geoviewLayerId].allLayerStatusAreIn(['processed', 'loading', 'loaded', 'error']);
return !this.layer.geoviewLayers[geoviewLayerId].allLayerStatusAreIn(['loaded', 'error']);
});
}

Expand All @@ -202,7 +202,7 @@ export class MapViewer {
let allGeoviewLayerReady =
this.mapFeaturesConfig.map.listOfGeoviewLayerConfig?.length === 0 || Object.keys(geoviewLayers).length !== 0;
Object.keys(geoviewLayers).forEach((geoviewLayerId) => {
const layerIsReady = geoviewLayers[geoviewLayerId].allLayerStatusAreIn(['processed', 'loading', 'error', 'loaded']);
const layerIsReady = geoviewLayers[geoviewLayerId].allLayerStatusAreIn(['error', 'loaded']);
logger.logTraceDetailed('map-viewer.mapReady? geoview layer ready?', geoviewLayerId, layerIsReady);
allGeoviewLayerReady &&= layerIsReady;
});
Expand Down

0 comments on commit 4d8cd51

Please sign in to comment.