How to redo a self-intersecting polygon?

Is there a way to restore a polygon that has self-intersections to the geosphere?

+5
source share
3 answers

So, I have to answer the question myself. Maybe this will help someone.

You can restore the polygon using the geos :: operation :: buffer :: BufferOp class. For instance.

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 package.

+7
source

Intersection points often intersect, so you can change

1  2   4
*--*   *       
|   \ /|
|    X |
|   / \|
*--*   *
6  5   3

to

1  2   4
*--*   *       
|   \ /|
|   3*6|
|   / \|
*--*   *
8  7   5

where points 3 and 6 coincide. If intersections of points are not allowed, move one of them a small amount.

, , , .

+1

A self-intersecting polygon is invalid. Therefore, BufferOp may give an incorrect result. I have not found a way to fix a self-intersecting polygon in geostationary conditions. The st_makevalid function in PostGIS uses geospheres. Thus, you can examine the source code.

0
source

All Articles