Skip to content

Commit

Permalink
Integration of the source property in the schema and renaming some fi…
Browse files Browse the repository at this point in the history
…elds
  • Loading branch information
ychoquet committed May 8, 2024
1 parent 9c5f8b7 commit cf82921
Show file tree
Hide file tree
Showing 14 changed files with 652 additions and 580 deletions.
238 changes: 189 additions & 49 deletions packages/geoview-core/public/templates/config-sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,48 +93,194 @@ <h1><strong>Sandbox Configuration</strong></h1>
<span></span>
</div>
<textarea id="configGeoview" name="configuration" cols="110">
{
'map': {
'interaction': 'dynamic',
'viewSettings': {
'minZoom': 5,
'projection': 3978
},
'basemapOptions': {
'basemapId': 'transport',
'shaded': false,
'labeled': true
},
'listOfGeoviewLayerConfig': [
{
'geoviewLayerId': 'wmsLYR1',
'geoviewLayerName': {
'en': 'earthquakes'
},
'metadataAccessPath': {
'fr': 'https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/earthquakes_en/MapServer/'
},
'geoviewLayerType': 'esriDynamic',
'listOfLayerEntryConfig': [
{
'layerId': '0'
},
{
'layerId': '1'
}
]
}]
},
'components': ['overview-map'],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table']
}
},
'corePackages': [],
'theme': 'geo.ca',
'suportedLanguages': ['en']
}
{
'map': {
'interaction': 'dynamic',
'viewSettings': {
'projection': 3978
},
'basemapOptions': {
'basemapId': 'transport',
'shaded': false,
'labeled': true
},
'listOfGeoviewLayerConfig': [
{
'geoviewLayerId': 'wmsLYR1',
'geoviewLayerName': {
'en': 'Earthquakes',
'fr': 'Tremblements de terre'
},
'accessPath': {
'en': 'https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/earthquakes_en/MapServer/',
'fr': 'https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/earthquakes_fr/MapServer/'
},
'geoviewLayerType': 'esriFeature',
'listOfLayerEntryConfig': [
{
'id': '0',
'geometryType': 'point',
'name': {
'en': 'Earthquakes 1980-1990',
'fr': ' Tremblements de terre 1980-1990'
},
'initialSettings': {
'controls': {
'query': true
},
'states': {
'queryable': true
}
},
'attributtions': 'Ressources naturelles Canada, Secteur des terres et des minéraux, Commission Géologique du Canada, Service canadien d\'information sur les risques',
'source': {
'layerFilter': '',
'maxRecordCount': 0,
'featureInfo': {
'nameField': 'date',
'outfields': [
{
'name': 'magnitude_codelist',
'alias': 'magnitude_codelist',
'type': 'date',
'domaine': []
},
{
'name': 'magnitude',
'alias': 'Magnitude',
'type': 'number',
'domaine': []
},
{
'name': 'magnitude_type',
'alias': 'Magnitude Type',
'type': 'string',
'domaine': []
},
{
'name': 'date',
'alias': 'Date',
'type': 'string',
'domaine': []
},
{
'name': 'place',
'alias': 'Place',
'type': 'string',
'domaine': []
},
{
'name': 'depth',
'alias': 'Depth',
'type': 'number',
'domaine': []
},
{
'name': 'latitude',
'alias': 'Latitude',
'type': 'number',
'domaine': []
},
{
'name': 'longitude',
'alias': 'Longitude',
'type': 'number',
'domaine': []
},
{
'name': 'OBJECTID',
'alias': 'OBJECTID',
'type': 'number',
'domaine': []
}
]
}
}
},
{
'id': '1',
'name': {
'en': 'Earthquakes 1990-2000',
'fr': ' Tremblements de terre 1990-2000'
},
'attributtions': 'Ressources naturelles Canada, Secteur des terres et des minéraux, Commission Géologique du Canada, Service canadien d\'information sur les risques',
'source': {
'layerFilter': '',
'maxRecordCount': 0,
'featureInfo': {
'nameField': 'date',
'outfields': [
{
'name': 'magnitude_codelist',
'alias': 'magnitude_codelist',
'type': 'date',
'domaine': []
},
{
'name': 'magnitude',
'alias': 'Magnitude',
'type': 'number',
'domaine': []
},
{
'name': 'magnitude_type',
'alias': 'Magnitude Type',
'type': 'string',
'domaine': []
},
{
'name': 'date',
'alias': 'Date',
'type': 'string',
'domaine': []
},
{
'name': 'place',
'alias': 'Place',
'type': 'string',
'domaine': []
},
{
'name': 'depth',
'alias': 'Depth',
'type': 'number',
'domaine': []
},
{
'name': 'latitude',
'alias': 'Latitude',
'type': 'number',
'domaine': []
},
{
'name': 'longitude',
'alias': 'Longitude',
'type': 'number',
'domaine': []
},
{
'name': 'OBJECTID',
'alias': 'OBJECTID',
'type': 'number',
'domaine': []
}
]
}
}
}
]
}]
},
'components': ['overview-map'],
'footerBar': {
'tabs': {
'core': ['legend', 'layers', 'details', 'data-table']
}
},
'corePackages': [],
'theme': 'geo.ca',
'suportedLanguages': ['en']
}
</textarea>
</div>
</td>
Expand Down Expand Up @@ -168,7 +314,7 @@ <h1><strong>Sandbox Configuration</strong></h1>
</div>
<div>
<textarea id="configUrlGeoview" name="Urlconfiguration" cols="210">
p=3857&z=4&c=-100,40&l=en&t=dark&b=basemapId:transport,shaded:false,labeled:true&i=dynamic&cc=overview-map&keys=12acd145-626a-49eb-b850-0a59c9bc7506,ccc75c12-5acc-4a6a-959f-ef6f621147b9
p=3857&z=4&c=-100,40&l=en&t=dark&b=basemapId:transport,shaded:false,labeled:true&i=dynamic&cc=overview-map&keys=12acd145-626a-49eb-b850-0a59c9bc7506,ccc75c12-5acc-4a6a-959f-ef6f621147b9
</textarea>
</div>
</div>
Expand Down Expand Up @@ -196,12 +342,6 @@ <h4 id="HLCONF1">Sanbox Map</h4>
<script src="codedoc.js"></script>

<script>
const isValid = false;
const configAreaString = document.getElementById('configGeoview').value.replaceAll(' ', '');
document.getElementById('configGeoview').value = configAreaString;
const configUrlAreaString = document.getElementById('configUrlGeoview').value.replaceAll(' ', '');
document.getElementById('configUrlGeoview').value = configUrlAreaString;

// Config Validate Button============================================================================================================
const validateJSONButton = document.getElementById('validateConfig');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export abstract class AbstractGeoviewLayerConfig {
*/
geoviewLayerName: string;

/** A flag used to indicate that the layer is a GeoCore layer (default: false). When true, geoviewLayerId must be a geocoreId. */
isGeocore: boolean;

/** The GeoView layer access path (English/French). */
metadataAccessPath: string;
accessPath: string;

/** Date format used by the service endpoint. */
serviceDateFormat: string | undefined;
Expand All @@ -50,7 +53,7 @@ export abstract class AbstractGeoviewLayerConfig {
* Initial settings to apply to the GeoView layer at creation time.
* This attribute is allowed only if listOfLayerEntryConfig.length > 1.
*/
initialSettings: TypeLayerInitialSettings;
#initialSettings: TypeLayerInitialSettings;

/** The layer entries to use from the GeoView layer. */
listOfLayerEntryConfig: ConfigBaseClass[] = [];
Expand All @@ -66,12 +69,17 @@ export abstract class AbstractGeoviewLayerConfig {
this.#mapFeatureConfig = mapFeatureConfig;
this.#language = language;

this.isGeocore = (this.#originalgeoviewLayerConfig.isGeocore as boolean) || false;

this.#initialSettings = Cast<TypeLayerInitialSettings>(
defaultsDeep(this.#originalgeoviewLayerConfig.initialSettings, CV_DEFAULT_LAYER_INITIAL_SETTINGS)
);
// Topmost layer must be a layer group or a leaf node.
if ((this.#originalgeoviewLayerConfig.listOfLayerEntryConfig as TypeJsonArray).length > 1)
(this.#originalgeoviewLayerConfig.listOfLayerEntryConfig as TypeJsonArray) = [
{
layerId: this.#originalgeoviewLayerConfig.geoviewLayerId,
initialSettings: defaultsDeep(this.#originalgeoviewLayerConfig.initialSettings, CV_DEFAULT_LAYER_INITIAL_SETTINGS),
initialSettings: this.#initialSettings as TypeJsonObject,
layerName: { ...(this.#originalgeoviewLayerConfig.geoviewLayerName as object) },
entryType: CV_CONST_SUB_LAYER_TYPES.GROUP as TypeJsonObject,
listOfLayerEntryConfig: this.#originalgeoviewLayerConfig.listOfLayerEntryConfig,
Expand All @@ -80,16 +88,13 @@ export abstract class AbstractGeoviewLayerConfig {

this.geoviewLayerId = (this.#originalgeoviewLayerConfig.geoviewLayerId || generateId()) as string;
this.geoviewLayerName = normalizeLocalizedString(this.#originalgeoviewLayerConfig.geoviewLayerName)![this.#language]!;
this.metadataAccessPath = normalizeLocalizedString(this.#originalgeoviewLayerConfig.metadataAccessPath)![this.#language]!;
this.accessPath = normalizeLocalizedString(this.#originalgeoviewLayerConfig.accessPath)![this.#language]!;
this.serviceDateFormat = (this.#originalgeoviewLayerConfig.serviceDateFormat || 'DD/MM/YYYY HH:MM:SSZ') as string;
this.externalDateFormat = (this.#originalgeoviewLayerConfig.externalDateFormat || 'DD/MM/YYYY HH:MM:SSZ') as string;
this.initialSettings = Cast<TypeLayerInitialSettings>(
defaultsDeep(this.#originalgeoviewLayerConfig.initialSettings, CV_DEFAULT_LAYER_INITIAL_SETTINGS)
);
this.listOfLayerEntryConfig = (this.#originalgeoviewLayerConfig.listOfLayerEntryConfig as TypeJsonArray)
.map((subLayerConfig) => {
if (layerEntryIsGroupLayer(subLayerConfig)) return new GroupLayerEntryConfig(subLayerConfig, this.initialSettings, language, this);
return this.createLeafNode(subLayerConfig, this.initialSettings, language, this);
if (layerEntryIsGroupLayer(subLayerConfig)) return new GroupLayerEntryConfig(subLayerConfig, this.#initialSettings, language, this);
return this.createLeafNode(subLayerConfig, this.#initialSettings, language, this);
})
.filter((subLayerConfig) => {
return subLayerConfig;
Expand Down Expand Up @@ -139,7 +144,7 @@ export abstract class AbstractGeoviewLayerConfig {
* type needed.
*
* @param {TypeJsonObject} layerConfig The sublayer configuration.
* @param {TypeLayerInitialSettings} initialSettings The initial settings inherited.
* @param {TypeLayerInitialSettings | TypeJsonObject} initialSettings The initial settings inherited.
* @param {TypeDisplayLanguage} language The initial language to use when interacting with the geoview layer.
* @param {AbstractGeoviewLayerConfig} geoviewConfig The GeoView instance that owns the sublayer.
* @param {ConfigBaseClass} parentNode The The parent node that owns this layer or undefined if it is the root layer..
Expand All @@ -149,7 +154,7 @@ export abstract class AbstractGeoviewLayerConfig {
*/
abstract createLeafNode(
layerConfig: TypeJsonObject,
initialSettings: TypeLayerInitialSettings,
initialSettings: TypeLayerInitialSettings | TypeJsonObject,
language: TypeDisplayLanguage,
geoviewConfig: AbstractGeoviewLayerConfig,
parentNode?: ConfigBaseClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ export class EsriDynamicLayerConfig extends AbstractGeoviewLayerConfig {
if (!this.geoviewLayerId) {
throw new Error(`geoviewLayerId is mandatory for GeoView layer of type ${this.geoviewLayerType}.`);
}
if (!this.metadataAccessPath) {
throw new Error(`metadataAccessPath is mandatory for GeoView layer ${this.geoviewLayerId} of type ${this.geoviewLayerType}.`);
}
this.validate();
}

Expand All @@ -56,7 +53,7 @@ export class EsriDynamicLayerConfig extends AbstractGeoviewLayerConfig {
}

/**
* Get the service metadata from the metadataAccessPath and store it in a private variable of the geoview layer.
* Get the service metadata from the accessPath and store it in a private variable of the geoview layer.
* @protected
*/
// TODO: Implement this method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export class EsriFeatureLayerConfig extends AbstractGeoviewLayerConfig {
if (!this.geoviewLayerId) {
throw new Error(`geoviewLayerId is mandatory for GeoView layer of type ${this.geoviewLayerType}.`);
}
if (!this.metadataAccessPath) {
throw new Error(`metadataAccessPath is mandatory for GeoView layer ${this.geoviewLayerId} of type ${this.geoviewLayerType}.`);
}
this.validate();
}

Expand All @@ -58,7 +55,7 @@ export class EsriFeatureLayerConfig extends AbstractGeoviewLayerConfig {
}

/**
* Get the service metadata from the metadataAccessPath and store it in a private variable of the geoview layer.
* Get the service metadata from the accessPath and store it in a private variable of the geoview layer.
* @protected
*/
// TODO: Implement this method
Expand Down
Loading

0 comments on commit cf82921

Please sign in to comment.