-
I want to use read_wkt but I don't know in advance the type of the geometry. |
Beta Was this translation helpful? Give feedback.
Answered by
vissarion
Feb 7, 2024
Replies: 1 comment
-
If I understand your question correctly you can use GEOMETRYCOLLECTION (is implemented in boost geometry but not documented yet). Here is an example that uses a variant of a point or polygon. using Point = boost::geometry::model::d2::point_xy<double>;
using Polygon = boost::geometry::model::polygon<Point>;
using GeometryCollection = boost::geometry::model::geometry_collection
<
boost::variant<Polygon, Point>
>;
GeometryCollection gc;
boost::geometry::read_wkt
("GEOMETRYCOLLECTION(POINT(0 0))", gc);
std::cout << boost::geometry::wkt(gc) << std::endl;
auto point = gc[0];
std::cout << boost::geometry::wkt(point) << std::endl; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
JD31
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I understand your question correctly you can use GEOMETRYCOLLECTION (is implemented in boost geometry but not documented yet).
Here is an example that uses a variant of a point or polygon.