How to split a self-intersection polygon into a multi-polygon
I would like to implement a Java method that can split a self-intersection polygon into a multipolygon. Is there any API or algorithm? Thank.
The following code uses the JavaGeom API .
/**
* Split a polygon by its intersection(s)
* @param polygon
* @return a list of splitted polygons, return itself if no intersection found.
*/
public List<Polygon2D> splitSelfIntersectionPolygon(Polygon2D polygon){
List<Polygon2D> multiPolygon = new ArrayList<Polygon2D>();
Polygon2D splittedPolygon = null;
for(int i = 0; i < polygon.vertexNumber(); i++){
//...
multiPolygon.add(splittedPolygon);
}
return multiPolygon;
}
+3
source to share
No one has answered this question yet
Check out similar questions: