Boost logo

Geometry :

Subject: [ggl] Point/Box in Box Test (Border Cases - 3D)
From: Barend Gehrels (barend)
Date: 2011-07-03 13:10:43


Hi Frank,

> I am searching a predicate slightly different than 'within' (don't
> know the common term) such that expressions like:
>
> withinX(Box(Point(0,0,0), Point(1,1,1)),Box(Point(0,0,0), Point(2,2,2))
>
> would be true. So using < or > for the comparisons of the boxes' edges
> instead of <= or >= (in within.hpp:117). That wouldn't be equivalent to
> "within(Box, Box) || onBorder(Box, Box)" in my understanding.
>
> I had a look into the 'within_util.hpp' file with the within_code
> function and it would be sufficient for point-in-box or point-in-ring
> tests (although it is currently only prepared to work with 2D
> points!?). But what about box-in-box or ring-in-ring use cases?

I updated the trunk, and moved the within_code from within_util to
within.hpp.

There now is geometry::detail::within_code, returning -1,0,1 for
respectively outside, on border and inside. The within function is now
calling that functionality. The strategies were already returning this
code; now the point_in_box and box_in_box functions also return this code.

Note, for a box (or in the future for other areal geometries), the "on
border" can be interpreted as "partly within, partly on border". So it
is (of course) not complete on the border, the thing you can safely
assume is that it is not (even partly) outside.

It stays in namespace detail until there is complete agreement on the
interface (parameter, strategy, function name), so maybe you will have
to rename something in the future, but the functionality is there. I now
believe that it is the best to adapt to PostGIS and Oracle here, they
call it "coveredBy". See
http://postgis.refractions.net/documentation/manual-1.5/ST_CoveredBy.html,
defining it as "Returns 1 (TRUE) if no point in Geometry A is outside
GeometryB", which is what I described. So covered_by would be a
convenient and (I think) intuitive name.

Regards, Barend


Geometry list run by mateusz at loskot.net