Skip to content

Conversation

nuts-rice
Copy link
Contributor

@nuts-rice nuts-rice commented Jul 15, 2025

Addresses #1205 , Follows #1207 example for DE-9IM predicates and added contains. Used geo's contain 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.

@github-actions github-actions bot added the feat label Jul 15, 2025
Copy link
Member

@kylebarron kylebarron left a 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

Comment on lines 7 to 10
pub fn contains<'a>(
left_array: &'a impl GeoArrowArrayAccessor<'a>,
right_array: &'a impl GeoArrowArrayAccessor<'a>,
) -> GeoArrowResult<BooleanArray> {
Copy link
Member

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

Comment on lines 11 to 15
assert_eq!(
left_array.len(),
right_array.len(),
"Arrays must have the same length"
);
Copy link
Member

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.

let result = left_geom.contains(&right_geom);
builder.append_value(result);
}
(None, _) | (_, None) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be

(_, _)

@kylebarron kylebarron merged commit 49c3861 into geoarrow:main Jul 16, 2025
10 checks passed
@kylebarron
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants