[英]No Intersection Area for geographic coordinates with Boost Geometry
我需要檢查兩個點(GPS坐標) q
, m
是否在同一側或相反側或與線(大圓弧段) (p,t)
。 我知道q
與(p, t)
不成線性關系。 我沒有發現在boost.geometry庫中使用任何直接函數。 因此,我嘗試以不同的方式進行計算。
我構造了兩個三角形(p, q, t)
和(p, m, t)
。 然后,我將這兩個相交並檢查相交多邊形的面積。 以下是我的代碼。
typedef boost::geometry::model::point<
double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>
> geo_point;
typedef boost::geometry::model::polygon<geo_point> geo_polygon;
geo_point p(110.48316, 29.05043);
geo_point q(110.48416, 29.05104);
geo_point t(110.48416, 29.05228);
geo_point m(110.48408, 29.05079);
geo_polygon ut, es;
boost::geometry::append(ut.outer(), p);
boost::geometry::append(ut.outer(), q);
boost::geometry::append(ut.outer(), t);
boost::geometry::append(ut.outer(), p);
boost::geometry::append(es.outer(), p);
boost::geometry::append(es.outer(), m);
boost::geometry::append(es.outer(), t);
boost::geometry::append(es.outer(), p);
std::list<geo_point> intersection_points;
boost::geometry::intersection(ut, es, intersection_points);
std::cout << intersection_points.size() << std::endl;
std::vector<geo_polygon> intersection_polygons;
boost::geometry::intersection(ut, es, intersection_polygons);
std::cout << intersection_polygons.size() << std::endl;
如果我們繪制這兩個三角形,我們可以清楚地看到它們在3個頂點上相交,從而在相交區域產生了另一個三角形。
上面的代碼正確返回相交點的數量,但不返回任何相交多邊形。
3
0
我嘗試使用geographic
而不是spherical_equatorial
坐標系。 但是得到了相同的結果。 我想念什么嗎? 或者這是Boost.Geometry
的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.