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
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))",
boost::geometry::read_wkt("POLYGON((45 30, 25 30, 25 50, 45 50, 45 30))",

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

Geometry list run by mateusz at