Skip to content

Commit 3c0fa08

Browse files
fix: Check bbox value for list of lists (#182)
#180 For specific collection example reported in bug ticket (https://www.eodms-sgdot.nrcan-rncan.gc.ca/stac/collections/rcm-ard) => spatial extent looks like ``` "extent": { "spatial": { "bbox": [-180, -90, 180, 90] },``` when I believe its supposed to be a list of lists ` "extent": { "spatial": { "bbox": [[-180, -90, 180, 90]] },` so change checks for that or just returns list value. --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent c221ce4 commit 3c0fa08

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/layers/map.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,12 @@ function valueToGeoJson(value: StacValue) {
263263
}
264264
}
265265

266-
function getCollectionExtents(collection: StacCollection) {
267-
return collection.extent?.spatial?.bbox?.[0];
266+
function getCollectionExtents(collection: StacCollection): SpatialExtent {
267+
const spatialExtent = collection.extent?.spatial;
268+
// check if bbox is a list of lists, otherwise its a single list of nums
269+
return Array.isArray(spatialExtent?.bbox?.[0])
270+
? spatialExtent?.bbox[0]
271+
: (spatialExtent?.bbox as unknown as SpatialExtent);
268272
}
269273

270274
function getBbox(

0 commit comments

Comments
 (0)