Skip to content

read_wkt to 'any' geometry #1240

Answered by vissarion
JD31 asked this question in Q&A
Discussion options

You must be logged in to vote

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::e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JD31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants