public static GeometryCollection getHoles ( Geometry geom ) throws SQLException { if ( geom != null ) { if ( geom . getDimension ( ) >= 2 ) { ArrayList < Geometry > holes = new ArrayList < Geometry > ( ) ; for ( int i = 0 ; i < geom . getNumGeometries ( ) ; i ++ ) { Geometry subgeom = geom . getGeometryN ( i ) ; if ( subgeom instanceof Polygon ) { Polygon polygon = ( Polygon ) subgeom ; for ( int j = 0 ; j < polygon . getNumInteriorRing ( ) ; j ++ ) { holes . add ( GEOMETRY_FACTORY . createPolygon ( GEOMETRY_FACTORY . createLinearRing ( polygon . getInteriorRingN ( j ) . getCoordinates ( ) ) , null ) ) ; } } } return GEOMETRY_FACTORY . createGeometryCollection ( holes . toArray ( new Geometry [ 0 ] ) ) ; } else { return GEOMETRY_FACTORY . createGeometryCollection ( null ) ; } } return null ; }
Returns the given geometry s holes as a GeometryCollection .