[英]No Intersection Area for geographic coordinates with Boost Geometry
I need to check whether two points (GPS coordinates) q
, m
are in the same side or on the opposite side or co linear to a line (great circle segment) (p,t)
. 我需要检查两个点(GPS坐标)
q
, m
是否在同一侧或相反侧或与线(大圆弧段) (p,t)
。 I know that q
is not co linear to (p, t)
. 我知道
q
与(p, t)
不成线性关系。 I didn't find and any direct function to use in the boost.geometry library. 我没有发现在boost.geometry库中使用任何直接函数。 So I tried to calculate it in a different way.
因此,我尝试以不同的方式进行计算。
I construct two triangles (p, q, t)
and (p, m, t)
. 我构造了两个三角形
(p, q, t)
和(p, m, t)
。 Then I intersect these two and check the area of the intersection polygon. 然后,我将这两个相交并检查相交多边形的面积。 Following is my code.
以下是我的代码。
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;
If we plot these two triangles we can clearly see that they intersects on 3 vertices yielding another triangle in the intersected region. 如果我们绘制这两个三角形,我们可以清楚地看到它们在3个顶点上相交,从而在相交区域产生了另一个三角形。
The above code correctly returns the number of intersected points, but it doesn't return any intersection polygon. 上面的代码正确返回相交点的数量,但不返回任何相交多边形。
3
0
I have tried using geographic
instead of using spherical_equatorial
coordinate system. 我尝试使用
geographic
而不是spherical_equatorial
坐标系。 But got the same results. 但是得到了相同的结果。 Am I missing something ?
我想念什么吗? or this is a problem in
Boost.Geometry
或者这是
Boost.Geometry
的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.