public void addGeometryXYColumnAndIndex ( String tableName , String geomColName , String geomType , String epsg , boolean avoidIndex ) throws Exception { String epsgStr = "4326" ; if ( epsg != null ) { epsgStr = epsg ; } String geomTypeStr = "LINESTRING" ; if ( geomType != null ) { geomTypeStr = geomType ; } if ( geomColName == null ) { geomColName = ASpatialDb . DEFAULT_GEOM_FIELD_NAME ; } String _geomColName = geomColName ; String _epsgStr = epsgStr ; String _geomTypeStr = geomTypeStr ; pgDb . execOnConnection ( connection -> { try ( IHMStatement stmt = connection . createStatement ( ) ) { String sql = sqlTemplates . addGeometryColumn ( tableName , _geomColName , _epsgStr , _geomTypeStr , "2" ) ; stmt . execute ( sql ) ; if ( ! avoidIndex ) { sql = sqlTemplates . createSpatialIndex ( tableName , _geomColName ) ; stmt . execute ( sql ) ; } } return null ; } ) ; }
Adds a geometry column to a table .