private static void nodesTable ( Statement st , TableLocation nodesName , double tolerance , boolean isH2 , int srid ) throws SQLException { LOGGER . info ( "Creating the nodes table..." ) ; // Creating nodes table by removing copies from the pts table. if ( tolerance > 0 ) { if ( isH2 ) { st . execute ( "CREATE TABLE " + nodesName + "(" + "NODE_ID SERIAL PRIMARY KEY, " + "THE_GEOM POINT, " + "EXP POLYGON" + ") AS " + "SELECT NULL, A.THE_GEOM, A.AREA FROM " + PTS_TABLE + " as A," + PTS_TABLE + " as B " + "WHERE A.AREA && B.AREA " + "GROUP BY A.ID " + "HAVING A.ID=MIN(B.ID);" ) ; } else { st . execute ( "CREATE TABLE " + nodesName + "(" + "NODE_ID SERIAL PRIMARY KEY, " + "THE_GEOM GEOMETRY(POINT, " + srid + "), " + "EXP GEOMETRY(POLYGON," + srid + ")" + ") " ) ; st . execute ( "INSERT INTO " + nodesName + " (SELECT (row_number() over())::int , c.the_geom, c.area FROM (SELECT A.THE_GEOM, A.AREA FROM " + PTS_TABLE + " as A, " + PTS_TABLE + " as B " + "WHERE A.AREA && B.AREA " + "GROUP BY A.ID " + "HAVING A.ID=MIN(B.ID)) as c);" ) ; } } else { if ( isH2 ) { // If the tolerance is zero, we can create the NODES table // by using = rather than &&. st . execute ( "CREATE TABLE " + nodesName + "(" + "NODE_ID SERIAL PRIMARY KEY, " + "THE_GEOM POINT" + ") AS " + "SELECT NULL, A.THE_GEOM FROM " + PTS_TABLE + " as A," + PTS_TABLE + " as B " + "WHERE A.THE_GEOM && B.THE_GEOM AND A.THE_GEOM=B.THE_GEOM " + "GROUP BY A.ID " + "HAVING A.ID=MIN(B.ID);" ) ; } else { // If the tolerance is zero, we can create the NODES table // by using = rather than &&. st . execute ( "CREATE TABLE " + nodesName + "(" + "NODE_ID SERIAL PRIMARY KEY, " + "THE_GEOM GEOMETRY(POINT, " + srid + ")" + ") " ) ; st . execute ( "INSERT INTO " + nodesName + " (SELECT (row_number() over())::int , c.the_geom FROM (SELECT A.THE_GEOM FROM " + PTS_TABLE + " as A," + PTS_TABLE + " as B " + "WHERE A.THE_GEOM && B.THE_GEOM AND A.THE_GEOM=B.THE_GEOM " + "GROUP BY A.ID " + "HAVING A.ID=MIN(B.ID)) as c);" ) ; } } }
Create the nodes table .