I have two files: header.h and code.cpp, I can not write any boost namespace on code.cpp, so all "boost::geometry::etc..." calls go on header.h. The idea is to implement two template classes: one for the RTree and other for the RTree Node, this way the user may include the header.h file and implement the RTree on code.cpp using the two template classes on header.h. This is what I have so far:
header.h:
template< class TT > class Node
{
using PointType = boost::geometry::model::d2::point_xy< TT >;
using BoxType = boost::geometry::model::box< PointType >;
using NodeType = std::pair< BoxType, std::string >;
NodeType node;
public:
Node(){}
template< class T >
Node( const BBox< T > &box, const std::string nodeName ){
node = std::make_pair( BoxType{ PointType{ box.xLo(), box.yLo() },
PointType{ box.xHi(), box.yHi() } }, nodeName );
}
};
template< class TT > class RTree
{
using RTreeType = boost::geometry::index::rtree< TT, boost::geometry::index::quadratic< 16 > >;
RTreeType rtree;
public:
RTree(){}
template< T >
void insertBox( const BBox< T > &box, const std::string nodeName ) {
rtree.insert( Node< T >( box, nodeName ) );
}
template< T >
void query( const BBox< T > &box, std::vector< Node< T > > &queryResult ) {
rtree.query( boost::geometry::index::intersects( Node< T >( box, "" ) ),
std::back_inserter( queryResult ) );
}
};
Some of the errors I am getting:
error: could not convert 'boost::geometry::index::detail::indexable<Node<int>, false>::NOT_VALID_INDEXABLE_TYPE31::assert_arg()' from 'mpl_::failed************(boost::geometry::index::detail::indexable<Node<int>, false>::NOT_VALID_INDEXABLE_TYPE::************)(Node<int>)' to 'mpl_::assert<false>::type' {aka 'mpl_::assert<false>'}
31 | BOOST_MPL_ASSERT_MSG(
| ^
| |
| mpl_::failed************ (boost::geometry::index::detail::indexable<Node<int>, false>::NOT_VALID_INDEXABLE_TYPE::************)(Node<int>)
...
error: could not convert 'boost::geometry::traits::point_type<Node<int> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE45::assert_arg()' from 'mpl_::failed************ (boost::geometry::traits::point_type<Node<int> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<Node<int>, mpl_::na, mpl_::na, mpl_::na>)' to 'mpl_::assert<false>::type' {aka 'mpl_::assert<false>'}
45 | BOOST_MPL_ASSERT_MSG
| ^
| |
| mpl_::failed************ (boost::geometry::traits::point_type<Node<int> >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<Node<int>, mpl_::na, mpl_::na, mpl_::na>)
...
error: no type named 'type' in 'struct boost::geometry::traits::point_type<Node<int> >'
66 | >::type type;
| ^~~~
It seems to me I have to use indexable. Although I am not sure how I am supposed to do it with the code I already have. Any help is welcome, thanks in advance.