2

I am trying to use a rtree made of points and to query it in order to having the nearest values of a point:

#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <boost/function_output_iterator.hpp>

using namespace boost::geometry;
namespace bgi = boost::geometry::index;

class Entity {
public:
    std::string name;
    int count;
};

class dummy {
public:
    using pointT=model::d2::point_xy<long,cs::cartesian>;
    using valueT=std::pair<pointT,Entity*>;
    using treeT=bgi::rtree<valueT,bgi::quadratic<16>>;

    treeT index;

    Entity* findNearest(const pointT& point) {
        Entity *result= nullptr;
        index.query(bgi::nearest(point,1),
                              boost::make_function_output_iterator([&result](auto const& val){
                                  result=val.second;
                              }));
        return result;
    }
};

But I have compile errors related to the index.query call:

boost_1_74_0/boost/mpl/assert.hpp:440:42: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::geometry::strategy::distance::services::default_strategy<boost::geometry::point_tag, boost::geometry::point_tag, boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::cartesian_tag, boost::geometry::cartesian_tag, void>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION::************)(mpl_::assert_::types<boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::cartesian_tag, boost::geometry::cartesian_tag>))’ , BOOST_PP_CAT(mpl_assertion_in_line_,counter) = sizeof(
~~~ boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) \

and

boost_1_74_0/boost/geometry/strategies/comparable_distance_result.hpp:51:8: error: no type named ‘type’ in ‘struct boost::geometry::detail::distance::default_strategy<boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::model::d2::point_xy<long int, boost::geometry::cs::cartesian>, boost::geometry::pointlike_tag, boost::geometry::pointlike_tag, false>’ struct comparable_distance_result<Geometry1, Geometry2, default_strategy>

and others but I cannot put them all. I tryed to understand the header files and the template logic but it is too complicated... I think that I am doing a very standard query no? Any idea?

Javaddict
  • 223
  • 2
  • 10
  • The answer to this question (adding extra headers) fixed your example for me: https://stackoverflow.com/questions/46156995/boost-1-65-1-geometry-distance-strategy-compile-error-with-visual-studio-2017 – parktomatomi Oct 26 '20 at 16:30
  • Thank you parktomatomi it works for me also – Javaddict Oct 26 '20 at 16:42

0 Answers0