The tree itself compiles just fine. It's the nearest query that fails. Here is a minimal not working example. I'll send output as an attachment. What bothers me is Strategy=int in the output.
#include
Hi,
W dniu 14.10.2019 o 16:57, vexakul via Boost-users pisze:
Hi all!
I need to store geographic points in rtree and be able to answer nearest query.
Can someone provide an example similar to this https://www.boost.org/doc/libs/1_65_1/libs/geometry/doc/html/geometry/spatia... but with point type bg::model::point
>? Is that supported? For me it fails to compile. When you define the geographic point as R-tree element type the computation should be done in geographic CS by default using WGS84 ellipsoid and andoyer formula to calculate distances. So simply:
using boost::geometry;
using point = model::point
; using rtree = index::rtree
>; rtree rt;
// or
std::vector<point> pts;
rtree rt2{pts.begin(), pts.end()};
If you need different ellipsoid or more accurate formula it is also possible (since Boost 1.71) though it is not documented. It's because I'm not entirely sure what to do with the fact that with this approach the EqualTo is called with two or three arguments depending on the parameters passed into the R-tree so it may be confusing. So there is slight probability that the interface will change in case I found some better way of defining CS-specific parts of the computation. So if you e.g. need to pass a different ellipsoid you can wrap the R-tree parameters together with Index strategy and pass it into the R-tree like that:
using boost::geometry;
using formula = strategy::andoyer;// or more accurate strategy::vincenty srs::spheroid<double> sph(6378137.0, 6356752.3142451793);
using point = model::point
; using parameters = index::parameters < index::rstar<4>, strategy::index::geographic<formula> >; using rtree = index::rtree
; rtree rt{parameters{index::rstar<4>{}, strategy::index::geographic<formula>{sph}}};
// or
std::vector<point> pts;
rtree rt2{pts.begin(), pts.end(), parameters{index::rstar<4>{}, strategy::index::geographic<formula>{sph}}};
Have in mind that I didn't test the code above so there may be some mistakes.
Adam