Skip to content

Commit

Permalink
Merge pull request #137 from stuartwoodman/AUS-4049-Custom-Layers-Zoo…
Browse files Browse the repository at this point in the history
…m-Issue

AUS-4049 Custom Layers Zoom Issue
  • Loading branch information
vjf authored Aug 5, 2024
2 parents 6583eae + 14625c8 commit 64dc9a0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions projects/portal-core-ui/src/lib/model/data/layer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export class LayerModel {
kmlDoc: any; // Document object for custom KML layer
serverType?: string; // Type of server hosting the data
initialLoad: boolean; // if first time loaded, zoom to bbox
minScaleDenominator?: number; // MinScaleDenominator (from GetCapabilities)
maxScaleDenominator?: number; // MaxScaleDenominator (from GetCapabilities)
}
45 changes: 43 additions & 2 deletions projects/portal-core-ui/src/lib/service/wms/get-caps.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,42 @@ export class GetCapsService {
return SimpleXMLService.evaluateXPathString(doc, node, LEGEND_URL, nsResolver);
}

/**
* Get a layer Node's MinScaleDenominator
*
* @param doc the root Document for the GetCapabilities response
* @param node the layer Node
* @param nsResolver namespace resolver function
* @returns the MinScaleDenomintor for the layer, or null if not present
*/
private getMinScaleDenominator(doc: Document, node: Node, nsResolver: (prefix: string) => string): number {
let minScaleDenominator = null;
const METADATA_URL = './xsi:MinScaleDenominator';
const stringVal = SimpleXMLService.evaluateXPathString(doc, node, METADATA_URL, nsResolver);
if (stringVal && stringVal !== '') {
minScaleDenominator = parseFloat(stringVal);
}
return minScaleDenominator;
}

/**
* Get a layer Node's MaxScaleDenominator
*
* @param doc the root Document for the GetCapabilities response
* @param node the layer Node
* @param nsResolver namespace resolver function
* @returns the MaxScaleDenomintor for the layer, or null if not present
*/
private getMaxScaleDenominator(doc: Document, node: Node, nsResolver: (prefix: string) => string): number {
let maxScaleDenominator = null;
const METADATA_URL = './xsi:MaxScaleDenominator';
const stringVal = SimpleXMLService.evaluateXPathString(doc, node, METADATA_URL, nsResolver);
if (stringVal && stringVal !== '') {
maxScaleDenominator = parseFloat(stringVal);
}
return maxScaleDenominator;
}

/**
* Test if the layer should use a post request.
* NOTE: In the future if we parse styles this should also factor in the request length
Expand Down Expand Up @@ -318,6 +354,10 @@ export class GetCapsService {
const metadataUrl = this.getMetadataUrl(rootNode, layerNode, this.nsResolver);
const legendUrl = this.getLegendUrl(rootNode, layerNode, this.nsResolver);

// Only some layers will have Min/MaxScaleDenominators, these can affect if a layer will display at some zoom levels
const minScaleDenominator = this.getMinScaleDenominator(rootNode, layerNode, this.nsResolver);
const maxScaleDenominator = this.getMaxScaleDenominator(rootNode, layerNode, this.nsResolver);

// One cswRecord object per layer
retVal.data.cswRecords.push({
name: cswRecElems['name'],
Expand Down Expand Up @@ -356,7 +396,6 @@ export class GetCapsService {
mapFormats: mapFormats,
applicationProfile: applicationProfile,
accessConstraints:accessConstraints

}];
}

Expand All @@ -368,7 +407,9 @@ export class GetCapsService {
metadataUrl: metadataUrl,
legendUrl: legendUrl,
timeExtent: timeExtent,
bbox: geoElems
bbox: geoElems,
minScaleDenominator: minScaleDenominator,
maxScaleDenominator: maxScaleDenominator
});
}
return retVal;
Expand Down

0 comments on commit 64dc9a0

Please sign in to comment.