From 8a57ff993222c56bcb657a9123fa107ece5daa3d Mon Sep 17 00:00:00 2001 From: Camille Moinier Date: Thu, 30 May 2024 16:55:29 +0200 Subject: [PATCH] feat: improve extent function --- .../map/src/lib/utils/map-utils.service.ts | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libs/feature/map/src/lib/utils/map-utils.service.ts b/libs/feature/map/src/lib/utils/map-utils.service.ts index 969c30ee23..a99f1ee611 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -217,21 +217,18 @@ export class MapUtilsService { } getRecordExtent(record: Partial): Extent { - if (!('spatialExtents' in record)) { - return null - } else if (record.spatialExtents.length > 0) { - // transform an array of geojson geometries into a bbox - const totalExtent = record.spatialExtents.reduce( - (prev, curr) => { - const geom = GEOJSON.readGeometry(curr.geometry) - return extend(prev, geom.getExtent()) - }, - [Infinity, Infinity, -Infinity, -Infinity] - ) - return transformExtent(totalExtent, 'EPSG:4326', 'EPSG:3857') - } else { + if (!('spatialExtents' in record) || record.spatialExtents.length === 0) { return null } + // transform an array of geojson geometries into a bbox + const totalExtent = record.spatialExtents.reduce( + (prev, curr) => { + const geom = GEOJSON.readGeometry(curr.geometry) + return extend(prev, geom.getExtent()) + }, + [Infinity, Infinity, -Infinity, -Infinity] + ) + return transformExtent(totalExtent, 'EPSG:4326', 'EPSG:3857') } }