Skip to content

Commit d264261

Browse files
committed
Update on envelope table was not commited
1 parent 91fb0ad commit d264261

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

onomap/src/main/groovy/org/noise_planet/onomap/nc_dump_area.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ public String getDump(DataSource dataSource, File zipFileName, File onomapArchiv
310310

311311
// Process export of raw measures
312312
try(Connection connection = dataSource.getConnection()) {
313-
connection.setAutoCommit(false)
314313
def sql = new Sql(connection)
315314
// Change result set type, this way the PostGIS driver use the db cursor with minimal memory usage
316315
sql.setResultSetType(ResultSet.TYPE_FORWARD_ONLY)
@@ -323,16 +322,20 @@ public String getDump(DataSource dataSource, File zipFileName, File onomapArchiv
323322
}
324323
// Create a table that contains track envelopes
325324
def lastpktrack = sql.firstRow("SELECT MAX(PK_TRACK) FROM NOISECAPTURE_DUMP_TRACK_ENVELOPE")[0] as Integer
325+
int inserted
326326
if(lastpktrack != null) {
327327
// resume analyze of receivers extents
328-
sql.execute("INSERT INTO NOISECAPTURE_DUMP_TRACK_ENVELOPE SELECT pk_track, " +
328+
inserted = sql.executeUpdate ("INSERT INTO NOISECAPTURE_DUMP_TRACK_ENVELOPE SELECT pk_track, " +
329329
"ST_SETSRID(ST_EXTENT(ST_MAKEPOINT(ST_X(the_geom),ST_Y(the_geom))), 4326) the_geom, COUNT(np.pk_point) measure_count" +
330330
" from noisecapture_point np where pk_track > :maxpktrack and not ST_ISEMPTY(the_geom) group by pk_track having st_area(ST_Transform(ST_SETSRID(ST_EXTENT(ST_MAKEPOINT(ST_X(the_geom),ST_Y(the_geom))), 4326), 3857)) < 1e8", [maxpktrack: lastpktrack])
331+
LOGGER.info("NOISECAPTURE_DUMP_TRACK_ENVELOPE {} row(s) inserted", inserted)
331332
} else {
332-
sql.execute("INSERT INTO NOISECAPTURE_DUMP_TRACK_ENVELOPE SELECT pk_track, " +
333+
inserted = sql.executeUpdate("INSERT INTO NOISECAPTURE_DUMP_TRACK_ENVELOPE SELECT pk_track, " +
333334
"ST_SETSRID(ST_EXTENT(ST_MAKEPOINT(ST_X(the_geom),ST_Y(the_geom))), 4326) the_geom, COUNT(np.pk_point) measure_count" +
334335
" from noisecapture_point np where not ST_ISEMPTY(the_geom) group by pk_track having st_area(ST_Transform(ST_SETSRID(ST_EXTENT(ST_MAKEPOINT(ST_X(the_geom),ST_Y(the_geom))), 4326), 3857)) < 1e8")
335336
}
337+
LOGGER.info("NOISECAPTURE_DUMP_TRACK_ENVELOPE {} rows inserted", inserted)
338+
sql.commit()
336339
if (exportTracks) {
337340
long beginTracks = System.currentTimeMillis()
338341
String fileName = "tracks.geojson"

onomap/src/test/groovy/org/noise_planet/onomap/JdbcTestCase.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import org.h2gis.functions.factory.H2GISFunctions
3838
import org.h2gis.functions.io.geojson.GeoJsonRead
3939
import org.h2gis.functions.io.shp.SHPRead
4040
import org.h2gis.postgis_jts.ConnectionWrapper
41+
import org.h2gis.utilities.GeometryTableUtilities
4142
import org.h2gis.utilities.JDBCUtilities
4243
import org.h2gis.utilities.dbtypes.DBTypes
4344
import org.h2gis.utilities.dbtypes.DBUtils
@@ -121,6 +122,7 @@ class JdbcTestCase {
121122
if(!JDBCUtilities.tableExists(connection, "GADM28")) {
122123
GeoJsonRead.importTable(connection, TestNoiseCaptureProcess.getResource("ut_deps.geojson").file, ValueVarchar.get("GADM28"))
123124
JDBCUtilities.createSpatialIndex(connection, "GADM28", "the_geom")
125+
GeometryTableUtilities.alterSRID(connection, "GADM28", "THE_GEOM", 4326)
124126
}
125127
}
126128

0 commit comments

Comments
 (0)