Skip to content

Commit

Permalink
fix: add check on boolean contains on both the original and buffered …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
RonitKissis authored Nov 6, 2024
1 parent e3d26ef commit 55575b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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({
Expand Down

0 comments on commit 55575b7

Please sign in to comment.