Boost logo

Geometry :

Subject: [geometry] Generic intersects function
From: Ido Shlomo (idosh99_at_[hidden])
Date: 2015-02-15 18:18:05


Hello dear geometry mailing list users!

I would like to ask something i don't find very clear.
I'm trying to write a generic intersects
<http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/reference/algorithms/intersects/intersects_2_two_geometries.html>
/read_wkt
<http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/reference/io/wkt/read_wkt.html>
 function
which reads 2 shapes (can be point/polygon/linestring/box) and returns
whether the shapes intersect.
I tried running the following code but found out Geometry is not a type but
a typename for template:

int _tmain(int argc, _TCHAR* argv[])
{
Geometry g;
Geometry y;

boost::geometry::read_wkt("POLYGON((35 25, 15 25, 15 35, 35 35, 35 25))",
g);
boost::geometry::read_wkt("POLYGON((45 30, 25 30, 25 50, 45 50, 45 30))",
y);

std::cout << intersects(g,y) << std::endl;

return 0;
}

I can see 2 problems:

   1. read_wkt has to know which type it is going to read - polygon / box /
   point / etc..
   2. Same for intersects

Do you have a suggestion how i could decide the type in runtime?
(let's say i'm reading database records which i don't know for sure if they
will be point / polygon)
I don't want to write a code specific to handling each of the cases even if
it won't be long..
Does anyone think of a generic solution?

Thank you very very much
Ido



Geometry list run by mateusz at loskot.net