No Intersection Area for geographic coordinates with Boost Geometry












0















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;


Live at cpp.sh



If we plot these two triangles we can clearly see that they intersects on 3 vertices yielding another triangle in the intersected region.



enter image description here



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










share|improve this question

























  • What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

    – MBo
    Nov 27 '18 at 10:07











  • The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

    – Neel Basu
    Nov 27 '18 at 10:14











  • OK, it's reasonable. I made an answer.

    – MBo
    Nov 27 '18 at 10:23
















0















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;


Live at cpp.sh



If we plot these two triangles we can clearly see that they intersects on 3 vertices yielding another triangle in the intersected region.



enter image description here



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










share|improve this question

























  • What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

    – MBo
    Nov 27 '18 at 10:07











  • The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

    – Neel Basu
    Nov 27 '18 at 10:14











  • OK, it's reasonable. I made an answer.

    – MBo
    Nov 27 '18 at 10:23














0












0








0








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;


Live at cpp.sh



If we plot these two triangles we can clearly see that they intersects on 3 vertices yielding another triangle in the intersected region.



enter image description here



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










share|improve this question
















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;


Live at cpp.sh



If we plot these two triangles we can clearly see that they intersects on 3 vertices yielding another triangle in the intersected region.



enter image description here



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







geometry gis computational-geometry boost-geometry






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 8:52







Neel Basu

















asked Nov 27 '18 at 8:33









Neel BasuNeel Basu

7,4451060119




7,4451060119













  • What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

    – MBo
    Nov 27 '18 at 10:07











  • The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

    – Neel Basu
    Nov 27 '18 at 10:14











  • OK, it's reasonable. I made an answer.

    – MBo
    Nov 27 '18 at 10:23



















  • What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

    – MBo
    Nov 27 '18 at 10:07











  • The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

    – Neel Basu
    Nov 27 '18 at 10:14











  • OK, it's reasonable. I made an answer.

    – MBo
    Nov 27 '18 at 10:23

















What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

– MBo
Nov 27 '18 at 10:07





What do you want to get from intersection triangle? I don't see how it could help to solve your problem. But calculation of bearings is useful to determine " the same side"

– MBo
Nov 27 '18 at 10:07













The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

– Neel Basu
Nov 27 '18 at 10:14





The intersection polygon is a straight line if they are on the opposite side, so the area will be 0. Otherwise there will be a non zero area.

– Neel Basu
Nov 27 '18 at 10:14













OK, it's reasonable. I made an answer.

– MBo
Nov 27 '18 at 10:23





OK, it's reasonable. I made an answer.

– MBo
Nov 27 '18 at 10:23












1 Answer
1






active

oldest

votes


















0














To ensure that polygons are closed and oriented as needed, apply correct. Inserting



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


gives result 1 polygon for your test






share|improve this answer
























  • The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

    – Neel Basu
    Nov 27 '18 at 11:03











  • From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

    – MBo
    Nov 27 '18 at 11:04













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53495542%2fno-intersection-area-for-geographic-coordinates-with-boost-geometry%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














To ensure that polygons are closed and oriented as needed, apply correct. Inserting



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


gives result 1 polygon for your test






share|improve this answer
























  • The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

    – Neel Basu
    Nov 27 '18 at 11:03











  • From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

    – MBo
    Nov 27 '18 at 11:04


















0














To ensure that polygons are closed and oriented as needed, apply correct. Inserting



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


gives result 1 polygon for your test






share|improve this answer
























  • The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

    – Neel Basu
    Nov 27 '18 at 11:03











  • From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

    – MBo
    Nov 27 '18 at 11:04
















0












0








0







To ensure that polygons are closed and oriented as needed, apply correct. Inserting



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


gives result 1 polygon for your test






share|improve this answer













To ensure that polygons are closed and oriented as needed, apply correct. Inserting



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


gives result 1 polygon for your test







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '18 at 10:21









MBoMBo

48.8k23050




48.8k23050













  • The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

    – Neel Basu
    Nov 27 '18 at 11:03











  • From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

    – MBo
    Nov 27 '18 at 11:04





















  • The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

    – Neel Basu
    Nov 27 '18 at 11:03











  • From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

    – MBo
    Nov 27 '18 at 11:04



















The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

– Neel Basu
Nov 27 '18 at 11:03





The polygons are closed properly because I append that first point at the end. Isn't that sufficient ? Also what does oriented mean in this context ?

– Neel Basu
Nov 27 '18 at 11:03













From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

– MBo
Nov 27 '18 at 11:04







From description: all rings which are wrongly oriented with respect to their expected orientation are reversed (I was wondering myself)

– MBo
Nov 27 '18 at 11:04






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53495542%2fno-intersection-area-for-geographic-coordinates-with-boost-geometry%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Unable to find Lightning Node

Futebolista