private static Collection < Polygon > splitPolygonizer ( Polygon polygon , LineString lineString ) throws SQLException { LinkedList < LineString > result = new LinkedList < LineString > ( ) ; ST_ToMultiSegments . createSegments ( polygon . getExteriorRing ( ) , result ) ; result . add ( lineString ) ; int holes = polygon . getNumInteriorRing ( ) ; for ( int i = 0 ; i < holes ; i ++ ) { ST_ToMultiSegments . createSegments ( polygon . getInteriorRingN ( i ) , result ) ; } // Perform union of all extracted LineStrings (the edge-noding process) UnaryUnionOp uOp = new UnaryUnionOp ( result ) ; Geometry union = uOp . union ( ) ; // Create polygons from unioned LineStrings Polygonizer polygonizer = new Polygonizer ( ) ; polygonizer . add ( union ) ; Collection < Polygon > polygons = polygonizer . getPolygons ( ) ; if ( polygons . size ( ) > 1 ) { return polygons ; } return null ; }
Splits a Polygon with a LineString .