From 9bab2beb14d0c16573be0112a1ea655cff1fe85b Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:33:19 -0400 Subject: [PATCH] refactor: clean up code --- client/src/services/geoUtils.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/client/src/services/geoUtils.ts b/client/src/services/geoUtils.ts index 3c6717d0..c1a86e43 100644 --- a/client/src/services/geoUtils.ts +++ b/client/src/services/geoUtils.ts @@ -111,27 +111,19 @@ export function getFeatureCutouts( ): Feature { const polygons: Polygon[] = [] - if (feature.geometry.type === 'Polygon') { - feature.geometry.coordinates.forEach((polygon, i) => { - if (i > 0) { - polygons.push({ - type: 'Polygon', - coordinates: [polygon], - }) - } + const push = (positions: Position[], index: number) => + index > 0 && + polygons.push({ + type: 'Polygon', + coordinates: [positions], }) + + if (feature.geometry.type === 'Polygon') { + feature.geometry.coordinates.forEach(push) } else if (feature.geometry.type === 'MultiPolygon') { - feature.geometry.coordinates.forEach((multi) => { - multi.forEach((polygon, i) => { - if (i > 0) { - polygons.push({ - type: 'Polygon', - coordinates: [polygon], - }) - } - }) - }) + feature.geometry.coordinates.forEach((multi) => multi.forEach(push)) } + return { type: 'Feature', id: `${feature.id}-cutouts`,