1
ポリゴンの内側にある線ストリングの部分を探しようとしています。私はintersection
関数を試しましたが、ポリゴンと重なっている線ストリングの部分ではなく、実際の交差点を見つけるようです。このオブジェクトを取得する方法はありますか?boost :: geometry :: model :: linestringとboost :: geometry :: model :: polygonの交点
はデモの状況です:
#include <iostream>
#include <fstream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/svg/svg_mapper.hpp>
#include <boost/geometry/geometries/linestring.hpp>
using point_type = boost::geometry::model::d2::point_xy<double>;
using polygon_type = boost::geometry::model::polygon<point_type>;
using linestring_type = boost::geometry::model::linestring<point_type>;
int main()
{
polygon_type polygon;
polygon.outer().push_back(point_type{10,10});
polygon.outer().push_back(point_type{12,10});
polygon.outer().push_back(point_type{12,12});
polygon.outer().push_back(point_type{10,12});
polygon.outer().push_back(point_type{10,10});
linestring_type linestring;
linestring.push_back(point_type{11,9});
linestring.push_back(point_type{11,11});
linestring.push_back(point_type{13,11});
// Expected intersections at (11, 10) and (12, 11)
std::ofstream svg("both.svg");
linestring_type output;
boost::geometry::intersection(polygon, linestring, output);
for(auto iter = output.begin(); iter != output.end(); ++iter) {
std::cout << boost::geometry::get<0>(*iter) << " " << boost::geometry::get<1>(*iter) << std::endl;
}
// The output is:
// 11 10
// 12 11
// But I want it to be:
// 11 10
// 11 11
// 12 11
return 0;
}
それはそのように「見える」ものではありません。基本的にここではドキュメントを引用しています。 – sehe
@sehe http://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/reference/algorithms/intersection.htmlから、どのようなタイプが期待されるべきかは全く分かりません可能な入力タイプの組み合わせの数多く。私が試した最初の方法は、この場合、出力として線ストリングを生成するときに正しい解答が期待できたと思います。なぜなら、それは分離していない(複数の)線ストリングではないからです。この例では、これを行うにはここにいます:) –
そのリンクから:_ "GeometryOut& ジオメトリのコレクション:(例:std :: vector、std :: deque、boost :: geometry :: multi * )、value_typeがPoint、LineStringまたはPolygonのコンセプトを満たすか、出力ジオメトリ(例えばボックスの場合) "_私は本当にどの情報を追加できるのか疑問です。また、この例は既にその非常に同じドキュメンテーションページにあります。 – sehe