Boost logo

Geometry :

Subject: Re: [geometry] Querying index using intersection with custom geometry
From: Michael Nett (netto.mihyaeru_at_[hidden])
Date: 2014-04-01 03:00:53


Hi Adam,

this works perfect under g++ (tried it at the office using Boost 1.48 and
it still works). I've updated the question on stackoverflow (see
http://stackoverflow.com/questions/19490435/boost-geometry-spatial-query-shapes/22778869#22778869
)

Thanks a lot!

- Michael

On Mon, Mar 31, 2014 at 10:32 PM, Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]
> wrote:

> Hi,
>
>
> Michael Nett wrote:
>
>> Hi again,
>>
>> sorry for the confusion. I tried your example at work (with Boost 1.48)
>> and now at home (using 1.54) and both produce the same errors.
>>
>>
> I tested it using VS. To compile under GCC the overloaded bg::intersects()
> must be defined before the rtree is included. Otherwise the compiler tries
> to use the original version. Let me know if this works:
>
> #include <boost/geometry.hpp>
>
>
> struct MyFrustum
> {
> MyFrustum(int d) : dummy(d) {}
> int dummy;
> };
>
> namespace boost { namespace geometry {
>
> // This will be called for Nodes and Values!
>
> template <typename Box> inline
> bool intersects(Box const& b, MyFrustum const& f)
> {
> std::cout << "checking the intersection with " << f.dummy << std::endl;
> return true;
> }
>
> }}
>
> #include <boost/geometry/index/rtree.hpp>
>
>
> int main()
> {
> namespace bg = boost::geometry;
> namespace bgi = bg::index;
> namespace bgm = bg::model;
> typedef bgm::point<float, 2, bg::cs::cartesian> pt;
> typedef bgm::box<pt> box;
>
> // check your implementation
> bool ok = bg::intersects(box(pt(0, 0), pt(1, 1)), MyFrustum(5));
>
> std::cout << "-------------------" << std::endl;
>
> // now use the rtree
> bgi::rtree<box, bgi::rstar<8> > rt;
> // insert some values
> rt.insert(box(pt(0, 0), pt(1, 1)));
> rt.insert(box(pt(2, 2), pt(3, 3)));
>
> // performa a query
> std::vector<box> vec;
> rt.query(bgi::intersects(MyFrustum(10)), std::back_inserter(vec));
>
> std::cout << vec.size() << std::endl;
> }
>
> Regards,
> Adam
>
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry
>



Geometry list run by mateusz at loskot.net