private static void firstFirstLastLast ( Statement st , TableLocation tableName , String pkCol , String geomCol , double tolerance ) throws SQLException { LOGGER . info ( "Selecting the first coordinate of the first geometry and " + "the last coordinate of the last geometry..." ) ; final String numGeoms = "ST_NumGeometries(" + geomCol + ")" ; final String firstGeom = "ST_GeometryN(" + geomCol + ", 1)" ; final String firstPointFirstGeom = "ST_PointN(" + firstGeom + ", 1)" ; final String lastGeom = "ST_GeometryN(" + geomCol + ", " + numGeoms + ")" ; final String lastPointLastGeom = "ST_PointN(" + lastGeom + ", ST_NumPoints(" + lastGeom + "))" ; st . execute ( "drop TABLE if exists " + COORDS_TABLE ) ; if ( tolerance > 0 ) { st . execute ( "CREATE TABLE " + COORDS_TABLE + " AS " + "SELECT " + pkCol + " EDGE_ID, " + firstPointFirstGeom + " START_POINT, " + expand ( firstPointFirstGeom , tolerance ) + " START_POINT_EXP, " + lastPointLastGeom + " END_POINT, " + expand ( lastPointLastGeom , tolerance ) + " END_POINT_EXP " + "FROM " + tableName ) ; } else { // If the tolerance is zero, there is no need to call ST_Expand. st . execute ( "CREATE TABLE " + COORDS_TABLE + " AS " + "SELECT " + pkCol + " EDGE_ID, " + firstPointFirstGeom + " START_POINT, " + lastPointLastGeom + " END_POINT " + "FROM " + tableName ) ; } }
Return the first and last coordinates table