Boost logo

Geometry :

Subject: Re: [geometry] [Spatial Index] bug & question
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2013-06-17 07:50:01


TONGARI wrote:
>
> bgi::rtree<std::pair<MyPoint, size_t>, ...> rt; // center and index
>
> and then either adapt your circle to the NSphere concept or use
> model::nsphere:
>
> typedef bg::model::point<T, 2, bg::cs::cartesian> point;
> typedef nsphere<point, T> nsphere;
>
> nsphere s(point(x, y), some_query_radius + circles_radius);
>
> rt.query(bgi::intersects(s), std::back_inserter(...));
>
>
> I guess I could use:
>
> bgi::rtree<nsphere, ...> rt;
> rt.query(bgi::intersects(point(...)), std::back_inserter(...));
>

Unfortunatley, nspheres/circles can't be used as indexables yet. So you
must store values which indexables are points or boxes. If you'd like to
store circles, you should provide user-defined indexable getter, but
circles must be translated to points. Btw, this should be slightly
faster than storing circles. And then you must pass nsphere to
bgi::intersects().

> I'll try that if I get the github update.
> BTW, didn't we miss a 'contains' predicate (within in reverse order)?
>

If I remember correctly we've talked about this earlier. But I can't
remember why we decided to not provide it. Maybe because there is no
such boolean operation in BG. Or maybe because it can be expressed with
other predicates, e.g.: intersects() && !covered_by() && !overlaps().

Nevertheless this functionality could be added, but I'm thinking about
something more general. We could use some operator to 'reverse' spatial
predicates, e.g. bitwise NOT. Then it would look like this:

// return values covered by g1 and those which have got g2 within
rt.query(covered_by(g1) && ~within(g2), ...);

// return values which haven't got g within
rt.query(!~within(g), ...);
// probably the same as
rt.query(~!within(g), ...);

Are you ok with this operator? Or maybe some function would be better?

Barend, Mateusz, Bruno, what do you think?

Regards,
Adam


Geometry list run by mateusz at loskot.net