Boost logo

Boost Users :

Subject: [Boost-users] boost::geometry::index::rtree with different CoordinateSystem
From: Ola Martin Lykkja (Ola.Lykkja_at_[hidden])
Date: 2014-03-07 05:02:59


Hi,

I am trying to build a rtree index with a collection if waypoint (about 30.000) each represented by longitude and latitude. When I use Cartesian coordinates rtree.query works as expected. However the results are slightly wrong because of my use of longitude,latitude in the cartesian domain.

I then tried to refine the datatypes to use spherical_equatorial and geographic CoordinateSystem. Now I encounter two problems:

a) With geographic, it does not compile.

b) With spherical_equatorial query(nearest) gives clearly wrong results.

Do you have any clues on what I am doing wrong?
Attached is two images illustrating the query results. Search target is dot with label on it.
I am using boost 1.55.0 on Linux with g++ 4.4.3 (same result with 4.6.3).

typedef bg::model::point<double, 2, bg::cs::cartesian> geo_point;
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > geo_point_with_wrong_results;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point_does_not_compile;
typedef std::pair<geo_point, unsigned int> geo_vg_value;

void test() {
      iterate_over_all_waypoints (wp) {
         geo_point pt(wp->on, wp->lat);
         rtree.insert(std::make_pair(pt, wp->id));
      }

      std::vector<geo_vg_value> result;
      geo_point here(targetLat, targetLat);
      rtree.query(bgi::nearest(here, 20), std::back_inserter(result));
}

Kind regards,
Ola Martin




boost-geometry-with-cartesian.png
boost-geometry-with-spherical.png

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net