Skip to content

Support covered_by() for box, geometry combinations - #1046

Merged
vissarion merged 13 commits into
boostorg:developfrom
vissarion:feature/covered_by_box_mpoly
Oct 13, 2022
Merged

Support covered_by() for box, geometry combinations#1046
vissarion merged 13 commits into
boostorg:developfrom
vissarion:feature/covered_by_box_mpoly

Conversation

@vissarion

Copy link
Copy Markdown
Member

This PR implements support for covered_by() for the following combinations of a box and a geometry:

  • convered_by(box, areal) (only cartesian CS)
  • convered_by(geometry, box)

The first case resolves issue #604

@vissarion vissarion added this to the 1.81 milestone Jul 28, 2022
Comment on lines +71 to +73
box_type box_areal;
geometry::envelope(geometry, box_areal, strategy);
return strategy.covered_by(box_areal, box).apply(box_areal, box);

@awulkiew awulkiew Aug 4, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This approach while giving the correct result is suboptimal because it cannot be interrupted if e.g. one of the points/segments of a geometry is outside the box. The whole envelope is calculated each time. If that's acceptable then ok. But if it isn't but for whatever reason you decide to not implement this now maybe you could put TODO here and create another issue about this.

Comment on lines +34 to +38
using is_cartesian = std::is_same
<
typename traits::coordinate_system<typename traits::point_type<Box>::type>::type,
cs::cartesian
>;

@awulkiew awulkiew Aug 4, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should probably use Strategy::cs_tag to distinguish between CSes. It's because the CS of a geometry may be undefined and it's the Strategy that defines CS-related operations.

Comment on lines +59 to +61
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for this coordinate system.",
typename traits::coordinate_system<typename traits::point_type<Box>::type>::type);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a breaking change? AFAIU previously box was silently converted to ring in non-cartesian CSes, correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we are OK since this operation was not supported in the past, i.e. covered_by(box, polygon) do not compile in any cs before this PR.

@vissarion

Copy link
Copy Markdown
Member Author

@awulkiew thanks for your comments I addressed them by pushing new commits.

@vissarion

Copy link
Copy Markdown
Member Author

@barendgehrels are you OK with this PR?

@barendgehrels barendgehrels left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I made some comments, still pending, but basically I'm OK. Thanks!

return strategy.covered_by(box1, box2).apply(box1, box2);
box_type box_areal;
geometry::envelope(geometry, box_areal, strategy);
return strategy.covered_by(box_areal, box).apply(box_areal, box);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this sufficient for the generic case? It looks surprisingly simple.

But probably yes.
image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fox box/box , calculating the envelope is actually not necessary.
For box/point neither.
Maybe the replaced code should still stay, and this new case to support other combinations.

You covered that already below, fine.

}
};
using point_type = typename point_type<Geometry>::type;
using box_type = model::box<point_type>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We probably should use a helper geometry here, in case point_type is not mutable

Comment thread include/boost/geometry/algorithms/detail/relate/box_areal.hpp Outdated
Comment thread include/boost/geometry/algorithms/detail/relate/box_areal.hpp Outdated
Comment thread include/boost/geometry/algorithms/detail/relate/box_areal.hpp Outdated
Comment thread include/boost/geometry/algorithms/detail/relate/box_areal.hpp Outdated
@barendgehrels

Copy link
Copy Markdown
Collaborator

@barendgehrels are you OK with this PR?

See my review remark, basically yes, but can you look at my comments I made earlier?

@vissarion

Copy link
Copy Markdown
Member Author

@barendgehrels are you OK with this PR?

See my review remark, basically yes, but can you look at my comments I made earlier?

Thanks for the review! Somehow your comments appeared to me yesterday. I addressed them and now I can merge this PR.

@vissarion
vissarion merged commit 938f6f6 into boostorg:develop Oct 13, 2022
@vissarion
vissarion deleted the feature/covered_by_box_mpoly branch October 13, 2022 11:40
@vissarion vissarion modified the milestones: 1.81, 1.82 Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants