Skip to content

Commit

Permalink
Fix WMS sharekeys
Browse files Browse the repository at this point in the history
  • Loading branch information
nf-s committed Nov 3, 2023
1 parent 4f5abdd commit c2d5cf1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/Models/Catalog/Ows/WebMapServiceCatalogGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class GetCapabilitiesStratum extends LoadableStratum(
// At the moment we ignore duplicate layers
this.catalogGroup.terria.addModel(
model,
this.getLayerShareKeys(layer)
this.getLayerShareKeys(layer, layerId)
);
} catch (e) {
TerriaError.from(e, "Failed to add CatalogGroup").log();
Expand Down Expand Up @@ -253,7 +253,10 @@ class GetCapabilitiesStratum extends LoadableStratum(
try {
// Sometimes WMS Layers have duplicate names
// At the moment we ignore duplicate layers
this.catalogGroup.terria.addModel(model, this.getLayerShareKeys(layer));
this.catalogGroup.terria.addModel(
model,
this.getLayerShareKeys(layer, layerId)
);
} catch (e) {
TerriaError.from(e, "Failed to add WebMapServiceCatalogItem").log();
return;
Expand Down Expand Up @@ -330,14 +333,20 @@ class GetCapabilitiesStratum extends LoadableStratum(
}

/** For backward-compatibility.
* If layer.Name is defined, we will use it to create layer autoID (see `this.getLayerId`).
* Previously we used layer.Title, so we now add it as a shareKey
* Previously we have used the following IDs
* - `WMS Group Catalog ID/WMS Layer Name` - regardless of nesting
* - `WMS Group Catalog ID/WMS Layer Title`
*/
getLayerShareKeys(layer: CapabilitiesLayer) {
getLayerShareKeys(layer: CapabilitiesLayer, layerId: string) {
const shareKeys: string[] = [];

if (layerId !== `${this.catalogGroup.uniqueId}/${layer.Name}`)
shareKeys.push(`${this.catalogGroup.uniqueId}/${layer.Name}`);

if (isDefined(layer.Name) && layer.Title !== layer.Name)
return [`${this.catalogGroup.uniqueId}/${layer.Title}`];
shareKeys.push(`${this.catalogGroup.uniqueId}/${layer.Title}`);

return [];
return shareKeys;
}
}

Expand Down

0 comments on commit c2d5cf1

Please sign in to comment.