-
Notifications
You must be signed in to change notification settings - Fork 943
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
pointsWithinPolygon: add MultiPoint support #2137
Conversation
From my initial pass through this all looks good I think @twelch ! |
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.
This seems great!
Can you update the @returns annotation to just clarify for JS consumers looking at the docs that the return type mirrors what they passed in?
Also what happens to the typescript types if you pass in a FeatureCollection<Point | Multipoint>
for points? Does it allow it and correctly infer FeatureCollection<Point | Multipoint>
for the output? Maybe add a types.ts test for that.
* @param {Feature|FeatureCollection<Point>} points Points as input search | ||
* @param {FeatureCollection|Geometry|Feature<Polygon|MultiPolygon>} polygons Points must be within these (Multi)Polygon(s) | ||
* @returns {FeatureCollection<Point>} points that land within at least one polygon | ||
* @param {Feature|FeatureCollection<Point|MultiPoint>} points (Multi)Point(s) as input search |
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.
The typescript version of this would be Feature<Point|MultiPoint> | FeatureCollection<Point|Multipoint>
but maybe this is fine for JSDoc?
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.
I agree, as a TS user myself, your suggestion is more correct but looking at the docs for different functions I sensed there was an established convention already. I don't mind changing them, I would just change the params too to match. Since each type becomes a link in the docs, maybe it was done for simplicity.
@mfedderly good suggestions. I have updated the docs and added a mixed Point|Multipoint use case to confirm the returned type is as expected. I hadn't really thought of the user being able to pass in a feature collection containing both types but it is supported so I added a unit test for that as well. |
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.
Thanks! Good point about the jsdoc convention being different than the typescript version. Happy to stick with what we've got already.
This PR adds support for MultiPoints to pointsWithinPolygon per issue #2099.
This implements Option 3 discussed, for each MultiPoint passed, returns a MultiPoint with just the point coordinates that fall within a Polygon.
npm test
at the sub modules where changes have occurred.npm run lint
to ensure code style at the turf module level.