public List < Geometry > getGeometriesIn ( String tableName , Geometry intersectionGeometry , String ... prePostWhere ) throws Exception { List < Geometry > geoms = new ArrayList < Geometry > ( ) ; List < String > wheres = new ArrayList <> ( ) ; String pre = "" ; String post = "" ; String where = "" ; if ( prePostWhere != null && prePostWhere . length == 3 ) { if ( prePostWhere [ 0 ] != null ) pre = prePostWhere [ 0 ] ; if ( prePostWhere [ 1 ] != null ) post = prePostWhere [ 1 ] ; if ( prePostWhere [ 2 ] != null ) { where = prePostWhere [ 2 ] ; wheres . add ( where ) ; } } GeometryColumn gCol = getGeometryColumnsForTable ( tableName ) ; String sql = "SELECT " + pre + gCol . geometryColumnName + post + " FROM " + tableName ; if ( intersectionGeometry != null ) { intersectionGeometry . setSRID ( gCol . srid ) ; wheres . add ( getSpatialindexGeometryWherePiece ( tableName , null , intersectionGeometry ) ) ; } if ( wheres . size ( ) > 0 ) { sql += " WHERE " + DbsUtilities . joinBySeparator ( wheres , " AND " ) ; } IGeometryParser geometryParser = getType ( ) . getGeometryParser ( ) ; String _sql = sql ; return execOnConnection ( connection -> { try ( IHMStatement stmt = connection . createStatement ( ) ; IHMResultSet rs = stmt . executeQuery ( _sql ) ) { while ( rs . next ( ) ) { Geometry geometry = geometryParser . fromResultSet ( rs , 1 ) ; geoms . add ( geometry ) ; } return geoms ; } } ) ; }
Get the geometries of a table intersecting a given geometry .