Skip to content

Commit

Permalink
fix: WMS metadata extent parsing
Browse files Browse the repository at this point in the history
If layer extent is missing try to use the one on service, world fallback otherwise
  • Loading branch information
FilipLeitner authored and jmacura committed Feb 5, 2024
1 parent f34f2ee commit 870bc5f
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class HsLayerManagerMetadataService {
}
this.setCapsExtent(
this.hsAddDataUrlService.calcCombinedExtent(
layerObjs.map((lo) => this.getCapsExtent(lo)),
layerObjs.map((lo) => this.getCapsExtent(lo, layerCaps)),
),
olLayer,
);
Expand Down Expand Up @@ -279,7 +279,7 @@ export class HsLayerManagerMetadataService {
});
}
this.collectLegend(layerObj, legends);
this.setCapsExtent(this.getCapsExtent(layerObj), olLayer);
this.setCapsExtent(this.getCapsExtent(layerObj, layerCaps), olLayer);
return layerObj;
}

Expand Down Expand Up @@ -331,14 +331,20 @@ export class HsLayerManagerMetadataService {
/**
* Helper used in to get usable extent from layers capabilities object
*/
private getCapsExtent(layerObj: any): Extent {
let extent = layerObj.EX_GeographicBoundingBox || layerObj.BoundingBox;
//If from BoundingBox picl one usable
extent = extent[0].crs
? extent.find(
(e) => e.crs != 'CRS:84' && getProjection(layerObj.BoundingBox[0]),
)
: extent;
private getCapsExtent(layerObj: any, layerCaps: HsWmsLayer): Extent {
// Extent of selected layer or service in case its missing
let extent =
(layerObj.EX_GeographicBoundingBox || layerObj.BoundingBox) ??
(layerCaps.EX_GeographicBoundingBox || layerCaps.BoundingBox);
//If from BoundingBox pick one usable
extent = !extent
? //In case extent could not be found
[-180, -90, 180, 90]
: extent[0].crs
? extent.find(
(e) => e.crs != 'CRS:84' && getProjection(layerObj.BoundingBox[0]),
)
: extent;
return transformExtent(
//BoundingBox extent is obj with crs, extent, res props
extent.extent ?? extent,
Expand Down

0 comments on commit 870bc5f

Please sign in to comment.