Мне нужно хранить в дереве два сегмента пользовательских классов, которые представляют целое число как точку.Класс называется hashobject_t и предоставляет get / set_hash, который я хочу использовать в качестве X, Y.
У меня есть следующий код:
#include <algorithm>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/index/rtree.hpp>
#include "hashobject.h"
#ifndef HASHRANGEINDEX_H
#define HASHRANGEINDEX_H
namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
typedef bg::cs::cartesian cs_cartesian;
namespace boost { namespace geometry { namespace traits {
BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(hashobject_t, 2, uint32_t, cs_cartesian)
template<> struct access<hashobject_t, 0> {
static inline double get(hashobject_t const& h) { return h.get_hash(); }
static inline void set(hashobject_t& h, uint32_t const& v) { h.set_hash(v); }
};
template<> struct access<hashobject_t, 1> {
static inline double get(hashobject_t const& h) { return h.get_hash(); }
static inline void set(hashobject_t& h, uint32_t const& v) { h.set_hash(v); }
};
}}}
typedef bg::model::point<hashobject_t, 2, cs_cartesian> point_t;
typedef bg::model::segment<point_t> segment_t;
typedef std::pair<segment_t, pg_shard_t> value_t;
class HashRangeIndex {
private:
bgi::rtree<value_t, bgi::quadratic<16> > skip_range_idx;
public:
vector<value_t> search_hash(hashobject_t hobj) {
std::vector<value_t> result;
skip_range_idx.query(
bgi::contains(point_t(hobj, hobj)),
std::back_inserter(result)
);
return result;
}
void clear() {
skip_range_idx.clear();
}
void ignore(pg_shard_t issuer) {
clear();
hashobject_t hmin = hashobject_t();
hashobject_t hmax = hashobject_t(hashobject_t::get_max());
skip_range_idx.insert(
value_t(
segment_t(point_t(hmin,hmin), point_t(hmax,hmax)), //<-- error here
issuer
)
);
}
Получение таких ошибок:
boost/include/boost/geometry/index/detail/algorithms/content.hpp:45:38: error: no match for ‘operator-’ (operand types are ‘boost::geometry::coordinate_type<boost::geometry::model::box<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> > >::type’ {aka ‘hashobject_t’} and ‘boost::geometry::coordinate_type<boost::geometry::model::box<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> > >::type’ {aka ‘hashobject_t’})
return get<max_corner, 0>(b) - get<min_corner, 0>(b);
boost/include/boost/geometry/index/detail/rtree/visitors/insert.hpp:72:49: error: no match for ‘operator-’ (operand types are ‘boost::geometry::index::detail::rtree::choose_next_node<std::pair<boost::geometry::model::segment<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> >, pg_shard_t>, boost::geometry::index::detail::rtree::options<boost::geometry::index::quadratic<16>, boost::geometry::index::detail::rtree::insert_default_tag, boost::geometry::index::detail::rtree::choose_by_content_diff_tag, boost::geometry::index::detail::rtree::split_default_tag, boost::geometry::index::detail::rtree::quadratic_tag, boost::geometry::index::detail::rtree::node_variant_static_tag>, boost::geometry::model::box<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> >, boost::geometry::index::detail::rtree::allocators<boost::container::new_allocator<std::pair<boost::geometry::model::segment<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> >, pg_shard_t> >, std::pair<boost::geometry::model::segment<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> >, pg_shard_t>, boost::geometry::index::quadratic<16>, boost::geometry::model::box<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> >, boost::geometry::index::detail::rtree::node_variant_static_tag>, boost::geometry::index::detail::rtree::choose_by_content_diff_tag>::content_type’ {aka ‘hashobject_t’} and ‘boost::geometry::index::detail::default_content_result<boost::geometry::model::box<boost::geometry::model::point<hashobject_t, 2, boost::geometry::cs::cartesian> > >::type’ {aka ‘hashobject_t’})
content_type content_diff = content - index::detail::content(ch_i.first);
Но почему он пытается выполнить операцию над hashobject_t, когда я предоставляю get для возврата целых чисел вместо этого?
Я пытался установить точку регистра 2d, но я получаю повторяющиеся ошибки параметров и bg:: cs :: cartesian "::" как ошибка, которую нельзя увидеть внутри макроса, и после этих ошибок макроса я получаю то же самое, что и выше