为什么在使用boost rtree最近查询时会出现编译错误?

时间:2020-10-26 16:10:26

标签: c++ boost geometry

我试图使用由点组成的rtree并对其进行查询,以获取点的最接近值:

#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;
    }
};

但是我有与index.query调用相关的编译错误:

boost_1_74_0 / boost / mpl / assert.hpp:440:42:错误:没有匹配的函数可以调用'assertion_failed(mpl _ :: failed ************(boost :: geometry: :strategy :: distance :: services :: default_strategy ,boost :: geometry :: model :: d2 :: point_xy ,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 ,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())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )\

boost_1_74_0 / boost / geometry / strategies / comparable_distance_result.hpp:51:8:错误:在'struct boost :: geometry :: detail :: distance :: default_strategy ,boost :: geometry :: model :: d2 :: point_xy ,boost :: geometry :: pointlike_tag,boost :: geometry :: pointlike_tag,false>' struct compare_distance_result

和其他,但我不能全部放下。 我试图理解头文件和模板逻辑,但是它太复杂了。 我认为我正在执行非常标准的查询,不是吗? 有想法吗?

0 个答案:

没有答案