Skip to content

Commit

Permalink
Fixed an issue where geocore would respond with a metadata url for a …
Browse files Browse the repository at this point in the history
…WMS already including 'GetCapabilities' wording.. Now curating that url better.

Fixing issue 2605
  • Loading branch information
Alex-NRCan committed Jan 10, 2025
1 parent 1722cb0 commit acc78fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ export abstract class ConfigBaseClass {
}
if (newLayerStatus === 'processed' && this.#waitForProcessedBeforeSendingLoaded) this.layerStatus = 'loaded';

// GV For quick debug, uncomment the line
// if (newLayerStatus === 'error') debugger;

// TODO: Cleanup - Commenting this and leaving it here for now.. It turns out that the parentLayerConfig property can't be trusted
// GV due to a bug with different instances of entryconfigs stored in the objects and depending how you navigate the objects, you get
// GV different instances. Example below (where 'parentLayerConfig.listOfLayerEntryConfig[0]' is indeed going back to 'uniqueValueId/uniqueValueId/4')
Expand Down
16 changes: 9 additions & 7 deletions packages/geoview-core/src/geo/layer/geoview-layers/raster/wms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,21 @@ export class WMS extends AbstractGeoViewRaster {
// GV Layers Refactoring - Obsolete (in config)
protected override async fetchServiceMetadata(): Promise<void> {
const metadataUrl = this.metadataAccessPath;
if (metadataUrl) {
const metadataAccessPathIsXmlFile = metadataUrl.slice(-4).toLowerCase() === '.xml';
let curatedMetadataUrl = metadataUrl;
if (!metadataUrl.includes('request=GetCapabilities')) {
curatedMetadataUrl = `${metadataUrl}?service=WMS&version=1.3.0&request=GetCapabilities`;
}
if (curatedMetadataUrl) {
const metadataAccessPathIsXmlFile = curatedMetadataUrl.slice(-4).toLowerCase() === '.xml';
if (metadataAccessPathIsXmlFile) {
// XML metadata is a special case that does not use GetCapabilities to get the metadata
await this.#fetchXmlServiceMetadata(metadataUrl);
await this.#fetchXmlServiceMetadata(curatedMetadataUrl);
} else {
const layerConfigsToQuery = this.#getLayersToQuery();
if (layerConfigsToQuery.length === 0) {
// Use GetCapabilities to get the metadata
try {
const metadata = await this.#getServiceMetadata(`${metadataUrl}?service=WMS&version=1.3.0&request=GetCapabilities`);
const metadata = await this.#getServiceMetadata(curatedMetadataUrl);
this.metadata = metadata;
this.#processMetadataInheritance();
} catch (error) {
Expand All @@ -125,9 +129,7 @@ export class WMS extends AbstractGeoViewRaster {
for (i = 0; layerConfigsToQuery[i].layerId !== layerConfig.layerId; i++);
if (i === layerIndex)
// This is the first time we execute this query
promisedArrayOfMetadata.push(
this.#getServiceMetadata(`${metadataUrl}?service=WMS&version=1.3.0&request=GetCapabilities&Layers=${layerConfig.layerId}`)
);
promisedArrayOfMetadata.push(this.#getServiceMetadata(`${curatedMetadataUrl}&Layers=${layerConfig.layerId}`));
// query already done. Use previous returned value
else promisedArrayOfMetadata.push(promisedArrayOfMetadata[i]);
});
Expand Down

0 comments on commit acc78fe

Please sign in to comment.