Reputation: 12904
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)
. I know that q
is not co linear to (p, t)
. I didn't find and any direct function to use in the boost.geometry library. So I tried to calculate it in a different way.
I construct two triangles (p, q, t)
and (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.
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. But got the same results. Am I missing something ? or this is a problem in Boost.Geometry
Upvotes: 1
Views: 376