簡體   English   中英

帶有Boost Geometry的地理坐標沒有交集區域

[英]No Intersection Area for geographic coordinates with Boost Geometry

我需要檢查兩個點(GPS坐標) qm是否在同一側或相反側或與線(大圓弧段) (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;

住在cpp.sh

如果我們繪制這兩個三角形,我們可以清楚地看到它們在3個頂點上相交,從而在相交區域產生了另一個三角形。

在此處輸入圖片說明

上面的代碼正確返回相交點的數量,但不返回任何相交多邊形。

3
0

我嘗試使用geographic而不是spherical_equatorial坐標系。 但是得到了相同的結果。 我想念什么嗎? 或者這是Boost.Geometry的問題

為確保根據需要關閉多邊形並確定其方向,請應用正確的 插入

boost::geometry::correct(ut);
boost::geometry::correct(es);

測試提供結果1多邊形

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM