Skip to content

Commit

Permalink
Integration des commentaires
Browse files Browse the repository at this point in the history
Fix pour charts:[] dans configuration par défaut du GeoChart
  • Loading branch information
Alex-NRCan committed Feb 20, 2024
1 parent 1e2322d commit c3b3dc5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
19 changes: 6 additions & 13 deletions packages/geoview-core/src/core/utils/config/config-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { AnyValidateFunction } from 'ajv/dist/types';

import defaultsDeep from 'lodash/defaultsDeep';

import { generateId, replaceParams, getLocalizedMessage, showError } from '../utilities';

import schema from '../../../../schema.json';
import { TypeBasemapId, TypeBasemapOptions, VALID_BASEMAP_ID } from '@/geo/layer/basemap/basemap-types';
import { geoviewEntryIsWMS } from '@/geo/layer/geoview-layers/raster/wms';
import { geoviewEntryIsImageStatic } from '@/geo/layer/geoview-layers/raster/image-static';
Expand Down Expand Up @@ -42,10 +39,13 @@ import {
TypeEsriImageLayerEntryConfig,
} from '@/geo/map/map-schema-types';
import { Cast, toJsonObject, TypeJsonObject, TypeMapFeaturesConfig } from '@/core/types/global-types';

import { CONST_GEOVIEW_SCHEMA_BY_TYPE, TypeGeoviewLayerType } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { geoviewEntryIsEsriImage } from '@/geo/layer/geoview-layers/raster/esri-image';
import { logger } from '@/core/utils/logger';
import { CONFIG_GEOCORE_URL, CONFIG_GEOLOCATOR_URL } from '@/app';

import { generateId, replaceParams, getLocalizedMessage, showError } from '../utilities';
import schema from '../../../../schema.json';

// ******************************************************************************************************************************
// ******************************************************************************************************************************
Expand All @@ -65,13 +65,6 @@ export class ConfigValidation {
/** The language that will be used to display the GeoView layer. */
private _displayLanguage: TypeDisplayLanguage;

// TODO: Refactor - Environment - How to edit this configuration easily per environment?
/** The default geocore url */
static CONFIG_GEOCORE_URL = 'https://geocore-stage.api.geo.ca';

/** The default geolocator url */
static CONFIG_GEOLOCATOR_URL = 'https://geolocator.api.geo.ca?keys=geonames,nominatim,locate';

/** default configuration if provided configuration is missing or wrong */
private _defaultMapFeaturesConfig: TypeMapFeaturesConfig = {
mapId: '',
Expand Down Expand Up @@ -99,8 +92,8 @@ export class ConfigValidation {
corePackages: [],
overviewMap: undefined,
serviceUrls: {
geocoreUrl: ConfigValidation.CONFIG_GEOCORE_URL,
geolocator: ConfigValidation.CONFIG_GEOLOCATOR_URL,
geocoreUrl: CONFIG_GEOCORE_URL,
geolocator: CONFIG_GEOLOCATOR_URL,
},
displayLanguage: 'en',
triggerReadyCallback: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type GeoChartGeoCoreConfig = TypeJsonObject & {
};
}; // TypeJsonObject, because the definition is in the external package

// #region GeoChart Config types

// The GeoChart Json object expected by GeoView
export type GeoChartConfig = TypeJsonObject & {
layers: [
Expand All @@ -45,6 +47,8 @@ export type UUIDmapConfigReaderResponse = {
geocharts?: GeoChartConfig[];
};

// #endregion

/**
* A class to generate GeoView layers config from a URL using a UUID.
* @exports
Expand Down Expand Up @@ -351,7 +355,7 @@ export class UUIDmapConfigReader {
}

/**
* Generates GeoView layers and geocharts configurations, from GeoCore API, using a list of UUIDs.
* Generates GeoView layers and package configurations (i.e. geochart), from GeoCore API, using a list of UUIDs.
* @param {string} baseUrl the base url of GeoCore API
* @param {string} lang the language to get the config for
* @param {string[]} uuids a list of uuids to get the configurations for
Expand Down
6 changes: 6 additions & 0 deletions packages/geoview-core/src/core/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export const GEO_URL_TEXT = {
text: 'Geo.ca',
};

/** The default geocore url */
export const CONFIG_GEOCORE_URL = 'https://geocore-stage.api.geo.ca';

/** The default geolocator url */
export const CONFIG_GEOLOCATOR_URL = 'https://geolocator.api.geo.ca?keys=geonames,nominatim,locate';

// OpenLayer constants
export const OL_ZOOM_DURATION = 500;

Expand Down
9 changes: 4 additions & 5 deletions packages/geoview-core/src/geo/layer/other/geocore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,14 @@ export class GeoCore {
// Get the language
const lang = api.maps[this.mapId].getDisplayLanguage();

// Generate the url
// TODO: Check - Is the metadataAccessPath still used? Because it seems to be incompatible with the rest now?
// Generate the url using metadataAccessPath when specified or using the geocore url
const url = geocoreLayerConfig.metadataAccessPath?.[lang] || `${mapConfig!.serviceUrls.geocoreUrl}`;
const uuids = [layerConfig.layerId];
const uuid = layerConfig.layerId;

try {
// Get the GV config from UUID and await even if within loop
// eslint-disable-next-line no-await-in-loop
const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, uuids);
const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, [uuid]);

// Cumulate
listOfLayerCreated.push(response.layers);
Expand All @@ -149,7 +148,7 @@ export class GeoCore {
});
} catch (error) {
// Log
logger.logError(`Failed to get the GeoView layer from UUI ${uuids}`, error);
logger.logError(`Failed to get the GeoView layer from UUI ${uuid}`, error);
const message = replaceParams([error as TypeJsonValue, this.mapId], getLocalizedMessage(this.mapId, 'validation.layer.loadfailed'));
showError(this.mapId, message);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/geoview-geochart/default-config-geochart.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"supportedLanguages": ["en", "fr"]
"supportedLanguages": ["en", "fr"],
"charts": []
}

0 comments on commit c3b3dc5

Please sign in to comment.