-
Notifications
You must be signed in to change notification settings - Fork 154
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
Consistently validate polygon inputs for GeoArrow offset format #973
Consistently validate polygon inputs for GeoArrow offset format #973
Conversation
… validate polygon inputs.
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 think this is good in general - my point-polygon distance can also benefit from this macro. Would you like to wait till the closedness discussion to close (no-pun intended) until we merge this PR?
I plan to update this based on that discussion, yes. Especially the change to the arithmetic for empty lists. |
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.
Approving CMake changes
Updated |
Co-authored-by: H. Thomson Comer <thomcom@gmail.com>
"Each ring must have at least four vertices"); | ||
|
||
CUSPATIAL_EXPECTS(test_points_x.size() == poly_offsets.size(), | ||
CUSPATIAL_EXPECTS(test_points_x.size() == std::max(poly_offsets.size() - 1, 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.
Since offsets must be greater or equal to 1, poly_offsets.size() - 1 >= 0
. No need to wrap with std::max
.
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 needs to pass when an empty test_points column is passed, regardless of whether the polygon offsets are malformed. If an empty offsets array is also passed, this will be 0 == -1, and this will throw. Hence the need for std::max. Even though an empty polygon offsets column is not technically correct, I think we should consider it to mean "zero polygons" for this case where there are also zero test points.
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.
Ok... Note that in header only API you added the test macro, if the offset is malformed the API will throw anyway.
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.
If I remove std::max
this test fails:
TYPED_TEST(PairwisePointInPolygonTest, Empty) |
If I leave it in, it passes. I think we want this case to not throw.
/merge |
Closes #958. Replaces usage of GDAL `contains` in the quadtree point-in-polygon tests with a call to a different cuSpatial point-in-polygon function. This allows us to remove all current dependencies on GDAL in cuSpatial. Depends on #973. This PR currently updates some expectations to make tests pass that are fixed in that PR. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Wang (https://github.com/isVoid) - H. Thomson Comer (https://github.com/thomcom) - Paul Taylor (https://github.com/trxcllnt) - Jordan Jacobelli (https://github.com/jjacobelli) URL: #974
…dsai#973) Fixes rapidsai#962. Discussion: rapidsai#972. Adds a new C++ macro to validate polygon offset array sizes. Updates all C++ APIs that accepts polygons to use this macro for consistent validation and requirements. All C++ functions that accept polygon data should accept and enforce GeoArrow offset format ("N + 1 offsets"). Updates C++ tests to correctly pass offsets. Updates Python implementation to no longer slice off final offsets. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Robert Maynard (https://github.com/robertmaynard) - H. Thomson Comer (https://github.com/thomcom) - Michael Wang (https://github.com/isVoid) URL: rapidsai#973
Closes rapidsai#958. Replaces usage of GDAL `contains` in the quadtree point-in-polygon tests with a call to a different cuSpatial point-in-polygon function. This allows us to remove all current dependencies on GDAL in cuSpatial. Depends on rapidsai#973. This PR currently updates some expectations to make tests pass that are fixed in that PR. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Wang (https://github.com/isVoid) - H. Thomson Comer (https://github.com/thomcom) - Paul Taylor (https://github.com/trxcllnt) - Jordan Jacobelli (https://github.com/jjacobelli) URL: rapidsai#974
…cts (#976) - Adds `multipolygon_range`, `multipolygon_ref`, `polygon_ref` as non-owning objects for geoarrow compliant polygon types. - Adds `pairwise_point_polygon_distance` to compute the shortest distances between two columns of multipoints and multipolygons. - Refactors `is_point_in_polygon` with geometry object input. Dependent on #973 since geometry objects requires geoarrow input. closes #703 Authors: - Michael Wang (https://github.com/isVoid) Approvers: - Mark Harris (https://github.com/harrism) - H. Thomson Comer (https://github.com/thomcom) URL: #976
Description
Fixes #962. Discussion: #972.
Adds a new C++ macro to validate polygon offset array sizes. Updates all C++ APIs that accepts polygons to use this macro for consistent validation and requirements. All C++ functions that accept polygon data should accept and enforce GeoArrow offset format ("N + 1 offsets").
Updates C++ tests to correctly pass offsets.
Updates Python implementation to no longer slice off final offsets.
Checklist