-
Notifications
You must be signed in to change notification settings - Fork 21
[DRAFT] ITEP-66486 - Replace clipperjs Part 1 #210
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the annotation intersection logic by replacing clipper-js operations with Turf-based geometry utilities and adds a new geometry-utils module. Key changes include:
- Removal of clipper-js imports and transformation logic in the selecting-tool utilities.
- Introduction of a new geometry-utils file that wraps Turf functions for various geometry operations.
- Addition of tests for the new geometry utilities.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
web_ui/src/pages/annotator/tools/selecting-tool/utils.ts | Removed clipper-js logic and replaced it with a Turf-based shapesIntersect function to check geometry intersections. |
web_ui/src/core/annotations/geometry-utils.ts | Introduced a suite of Turf-based functions for polygon conversion, area calculation, union/difference, and point-in-polygon checks. |
Files not reviewed (1)
- web_ui/package.json: Language not supported
Comments suppressed due to low confidence (1)
web_ui/src/pages/annotator/tools/selecting-tool/utils.ts:44
- Ensure that the updated intersection logic using shapesIntersect is comprehensively covered by unit tests, verifying behavior that matches the previous clipper-js implementation.
if (shapesIntersect(shape, annotationShape)) {
@@ -37,6 +38,7 @@ | |||
"dotenv": "^16.5.0", | |||
"filesize": "^10.1.6", | |||
"framer-motion": "^12.9.4", | |||
"geojson": "^0.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use case of geojson
versus turf
? From their readme it looks like it is very specific to geo-data (e.g. latitude and longitude information), do we need this to be able to use turf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More context: https://turfjs.org/docs/getting-started#typescript . But perhaps i can add it to devDependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm but if they're only types then could we skip installing it completely? To me it would be fine if we don't use these type explicitly as they won't be part of any type contract.
📝 Description
Previous PR was too big so i will make this change in multiple PRs.
This will be the biggest since it has 2.5k lines on the package-lock file alone
PR 1 (current)
turf
andgeojson
selecting-tool
PR 2 (next)
PR 3 (final)
✨ Type of Change
Select the type of change your PR introduces:
🧪 Testing Scenarios
Describe how the changes were tested and how reviewers can test them too:
✅ Checklist
Before submitting the PR, ensure the following: