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

Add overlapPolygonArea and overlapPolygonSum, deprecating overlapFeatures #389

Merged
merged 6 commits into from
Dec 18, 2024

Conversation

twelch
Copy link
Contributor

@twelch twelch commented Dec 17, 2024

This PR plits overlapFeatures into overlapPolygonArea and overlapPolygonSum, due to their input parameters and methods for sum and area operations diverging so much.

  • Deprecates overlapFeatures and leaves it as a wrapper to the two new methods.

  • Splits out toMultiPolygon and removeOverlap helper methods.

  • Updates toolbox page to link directly to API doc methods.

  • overlapPolygonArea did get an optimization for the collection-level metric calculation where it merges the sketch collection (with overlap removed) into a single multipolygon before clipping against the features in one shot. This should be faster than clipping each child sketch (sans overlap) one at a time against the features. Testing is needed to make sure that results do not change (they do not in unit testing), but also to make sure that this does not blow up the clip function by trying to do too much at once. The default chunks size of 5000 may need to be adjusted.

// Remove overlap between sketches, merge them into multipolygon
const noOverlapPolygons = removeOverlap(
  featureCollection(truncatedSketches),
);

// calculate collection level area in one shot
collValue = intersectInChunks(
  noOverlapPolygons,
  truncatedFeatures,
  chunkSize,
).reduce(
  (valueSoFar, rem) => (rem ? area(rem) + valueSoFar : valueSoFar),
  0,
);

@twelch twelch changed the title Overlap polygon refactor Add overlapPolygonArea and overlapPolygonSum, deprecating overlapFeatures Dec 17, 2024
@twelch twelch merged commit 51675a4 into dev Dec 18, 2024
2 checks passed
@twelch twelch deleted the overlap-polygon-refactor branch December 18, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant