how boost::geometry
私はのが機能していないことを理解しようとしfor_each_segment
ます。ドキュメントにfor_each_segment
は、ジオメトリとファンクターが必要であると書かれています。私の例では、このファンクターが呼び出さpolylength_helper
れます。このスニペットがコンパイルされていない限り、コンパイルされるまで単純にするために、そこで数値をインクリメントするだけです。
// foo.h
typedef boost::geometry::model::point<double, 2, bg::cs::cartesian> GeographicPoint;
typedef boost::geometry::model::linestring<GeographicPoint> GeographicPolyLine;
typedef boost::geometry::model::segment<GeographicPoint> GeographicSegment;
double poly_length(const GeographicPolyLine&);
template<typename Segment>
struct polylength_helper{
polylength_helper() : length(0){};
inline void operator()(Segment s){
length += 1;
};
double length;
};
// foo.cpp
double poly_length(GeographicPolyLine &poly){
polylength_helper<GeographicSegment> helper;
bg::for_each_segment(poly, helper);
return helper.length;
}
まあ、これはコンパイルされません。私clang
はより理解しやすい出力に使用しました、それは言います:
note: candidate function not viable: no known
conversion from 'model::referring_segment<point_type>' to
'boost::geometry::model::segment<boost::geometry::model::point<double, 2,
boost::geometry::cs::cartesian> >' for 1st argument
inline void operator()(Segment s){
^
誰かが私を助けることができますか?referring_segment
特に、メッセージのどこから来たのかわかりません。
ドキュメントの例を次に示します。
しかし、sを除いて、これが私のバージョンとどのように異なるのか理解できませんtypedef
。