我正在使用boost 1.61
使用VS2015进行编译
以下代码无法编译。应该这样做---我认为使用适配器BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET是令人沮丧的事情。
知道为什么这不起作用或我如何解决它?
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <vector>
#include <boost/geometry/geometries/register/point.hpp>
class wxPoint
{
public:
wxPoint(double x, double y)
: m_x(x),
m_y(y)
{
}
wxPoint() {}
double getx() const
{
return m_x;
}
double gety() const
{
return m_y;
}
void setx(double in)
{
m_x = in;
}
void sety(double in)
{
m_y = in;
}
private:
double m_x;
double m_y;
};
BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(
wxPoint,
double,
boost::geometry::cs::geographic<boost::geometry::degree>,
wxPoint::getx,
wxPoint::gety,
wxPoint::setx,
wxPoint::sety)
typedef std::pair<wxPoint, unsigned> value;
int main()
{
boost::geometry::index::rtree< value, boost::geometry::index::quadratic<16> > rtree;
wxPoint p(4, 1);
rtree.insert(std::make_pair(p, 1));
std::vector<value> result_s;
typedef boost::geometry::model::polygon<wxPoint> polygon_type;
polygon_type poly;
boost::geometry::read_wkt(
"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
"(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly);
rtree.query(boost::geometry::index::within(poly), std::back_inserter(result_s));
return 0;
}
以下是VC编译器的摘要信息:
Severity Code Description Project File Line Suppression State
Error C2672 'boost::geometry::strategy::intersection::relate_cartesian_segments<boost::geometry::policies::relate::segments_tupled<boost::geometry::policies::relate::segments_intersection_points<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>>,boost::geometry::policies::relate::segments_direction>,CalculationType>::apply': no matching overloaded function found scratch1 c:\users\simon\downloads\boost_1_61_0\boost_1_61_0\boost\geometry\algorithms\detail\overlay\get_turn_info_helpers.hpp 230
Error C2782 'boost::tuples::tuple<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>,boost::geometry::policies::relate::segments_direction::return_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type> boost::geometry::strategy::intersection::relate_cartesian_segments<boost::geometry::policies::relate::segments_tupled<boost::geometry::policies::relate::segments_intersection_points<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>>,boost::geometry::policies::relate::segments_direction>,CalculationType>::apply(const Segment1 &,const Segment2 &,const RobustPolicy &,const RobustPoint &,const RobustPoint &,const RobustPoint &,const RobustPoint &)': template parameter 'RobustPoint' is ambiguous scratch1 c:\users\simon\downloads\boost_1_61_0\boost_1_61_0\boost\geometry\algorithms\detail\overlay\get_turn_info_helpers.hpp 230
Error C2784 'boost::tuples::tuple<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>,boost::geometry::policies::relate::segments_direction::return_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type> boost::geometry::strategy::intersection::relate_cartesian_segments<boost::geometry::policies::relate::segments_tupled<boost::geometry::policies::relate::segments_intersection_points<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>>,boost::geometry::policies::relate::segments_direction>,CalculationType>::apply(const Segment1 &,const Segment2 &,const RobustPolicy &,const RobustPoint &,const RobustPoint &,const RobustPoint &,const RobustPoint &)': could not deduce template argument for 'const RobustPoint &' from 'const boost::geometry::model::point<double,2,boost::geometry::cs::geographic<boost::geometry::degree>>' scratch1 c:\users\simon\downloads\boost_1_61_0\boost_1_61_0\boost\geometry\algorithms\detail\overlay\get_turn_info_helpers.hpp 230
Error C2780 'boost::tuples::tuple<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>,boost::geometry::policies::relate::segments_direction::return_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type> boost::geometry::strategy::intersection::relate_cartesian_segments<boost::geometry::policies::relate::segments_tupled<boost::geometry::policies::relate::segments_intersection_points<boost::geometry::segment_intersection_points<IntersectionPoint,boost::geometry::segment_ratio<double>>>,boost::geometry::policies::relate::segments_direction>,CalculationType>::apply(const Segment1 &,const Segment2 &,const RobustPolicy &)': expects 3 arguments - 7 provided scratch1 c:\users\simon\downloads\boost_1_61_0\boost_1_61_0\boost\geometry\algorithms\detail\overlay\get_turn_info_helpers.hpp 230
以下是更详细的compiler output
答案 0 :(得分:0)
这是由错误导致的,此处有更多信息:https://svn.boost.org/trac/boost/ticket/12189,此处:https://svn.boost.org/trac/boost/ticket/12342
有几种可行的解决方法: