From 55575b7b6b852e6fb01662ea9580192427dd295a Mon Sep 17 00:00:00 2001 From: Ronit Kissis <92728393+RonitKissis@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:16:35 +0200 Subject: [PATCH] fix: add check on boolean contains on both the original and buffered job footprint(MAPCO-5210) (#99) * fix: add check on boolean contains on both the original job footprint and buffered Geometry * fix: area calculation is calculated on the originalJob , not on the buffered --- src/utils/geometry.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/geometry.ts b/src/utils/geometry.ts index 5dc73dc..c446c77 100644 --- a/src/utils/geometry.ts +++ b/src/utils/geometry.ts @@ -28,7 +28,8 @@ export const checkFeatures = (jobRoi: FeatureCollection, exportRoi: FeatureColle // Create a buffered feature around jobRoi's single polygon const bufferedFeature = buffer(jobRoi.features[0], roiBufferMeter, { units: 'meters' }); - const isContained = booleanContains(bufferedFeature as unknown as Geometry, exportRoi.features[0]); + const isContained = + booleanContains(bufferedFeature as unknown as Geometry, exportRoi.features[0]) || booleanContains(jobRoi.features[0], exportRoi.features[0]); // If exportRoi is not contained, return false immediately if (!isContained) { @@ -38,8 +39,8 @@ export const checkFeatures = (jobRoi: FeatureCollection, exportRoi: FeatureColle // Calculate areas and check containment percentage const exportArea = area(exportRoi.features[0]); - const bufferedArea = area(bufferedFeature as unknown as Geometry); - const containedPercentage = (exportArea / bufferedArea) * 100; + const jobArea = area(jobRoi.features[0]); + const containedPercentage = (exportArea / jobArea) * 100; const isSufficientlyContained = containedPercentage >= minContainedPercentage; logger.info({