-
Notifications
You must be signed in to change notification settings - Fork 34
feat: contains fn #1235
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
feat: contains fn #1235
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.
Thanks for the PR! A couple comments
rust/geoarrow-geo/src/contains.rs
Outdated
pub fn contains<'a>( | ||
left_array: &'a impl GeoArrowArrayAccessor<'a>, | ||
right_array: &'a impl GeoArrowArrayAccessor<'a>, | ||
) -> GeoArrowResult<BooleanArray> { |
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.
Similarly to intersects
, we want the public API to be in terms of &dyn GeoArrowArray
, not GeoArrowArrayAccessor
. The latter would require all users to manually downcast their data to a concrete type, which we don't want to require them to do.
Follow the layout of intersects
which has a separate inner function that takes in GeoArrowArrayAccessor
rust/geoarrow-geo/src/contains.rs
Outdated
assert_eq!( | ||
left_array.len(), | ||
right_array.len(), | ||
"Arrays must have the same length" | ||
); |
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.
Similarly to intersects
we want this to return an error, not panic.
rust/geoarrow-geo/src/contains.rs
Outdated
let result = left_geom.contains(&right_geom); | ||
builder.append_value(result); | ||
} | ||
(None, _) | (_, None) => { |
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 can just be
(_, _)
Thanks! |
Addresses #1205 , Follows #1207 example for DE-9IM predicates and added
contains
. Used geo'scontain
method.Tests right now are right polygon contained in left, two polygons that don't contain one another, and mixed geometry of line and point being contained in line.
Please let me know if more tests should be added.