Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add check on boolean contains on both the original and buffered job footprint(MAPCO-5210) #99

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading