Is there a way to remove self-intersections from a polygon using GEOS?
A polygonal boundary may be allowed to cross over itself, creating star polygons and other self-intersecting polygons.
Polygons can intersect in three ways: Overlap—Area of overlap can be produced by leaving the Output Type to its default value (LOWEST). Common boundary/touch at a line—This type of intersection can be produced by specifying LINE as the Output Type.
Repairing invalidity involves stripping a polygon down to its simplest structures (rings), ensuring the rings follow the rules of validity, then building up new polygons that follow the rules of ring enclosure.
If a feature intersects itself at a point and continues by crossing itself, it is considered a self-intersection.
So, I have to answer the question myself. Maybe it will help someone.
You can repair a polygon using the geos::operation::buffer::BufferOp class. E.g.
geos::geom::Geometry * result =
geos::operation::buffer::BufferOp::bufferOp(polygon, 1.0);
You can find some more good recipes in the Secrets of the JTS Topology Suite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With