From d6bb4f90827cb027d1b55381e684045afdfb84ab Mon Sep 17 00:00:00 2001 From: ebocher Date: Sun, 10 Dec 2023 14:44:17 +0100 Subject: [PATCH] Fix issue 885 --- .../geoclimate/osm/WorkflowOSM.groovy | 31 ++++++++++++++----- .../geoclimate/osmtools/Loader.groovy | 5 +++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy index 60107c78bc..9caa77d4dc 100644 --- a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy +++ b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy @@ -362,7 +362,7 @@ Map workflow(def input) { outputDatasource, outputTables, outputSRID, downloadAllOSMData, deleteOutputData, deleteOSMFile, logTableZones, osm_size_area, overpass_timeout, overpass_maxsize) if (!osmprocessing) { - h2gis_datasource.getSpatialTable(logTableZones).save("${databaseFolder + File.separator}logzones.geojson") + h2gis_datasource.save(logTableZones,"${file_outputFolder.getAbsolutePath() + File.separator}logzones.geojson", true) return null } if (delete_h2gis) { @@ -406,7 +406,8 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d def outputTableNamesResult = [:] //Create the table to log on the processed zone h2gis_datasource.execute """DROP TABLE IF EXISTS $logTableZones; - CREATE TABLE $logTableZones (the_geom GEOMETRY(GEOMETRY, 4326), request VARCHAR, info VARCHAR);""".toString() + CREATE TABLE $logTableZones (the_geom GEOMETRY(GEOMETRY, 4326), + location VARCHAR, info VARCHAR, version VARCHAR, build_number VARCHAR);""".toString() int nbAreas = id_zones.size() info "$nbAreas osm areas will be processed" id_zones.each { id_zone -> @@ -539,8 +540,11 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d processing_parameters.prefixName) if (!geoIndicators) { error "Cannot build the geoindicators for the zone $id_zone" - h2gis_datasource.execute "INSERT INTO $logTableZones VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error computing geoindicators')".toString() - + h2gis_datasource.execute(""" + INSERT INTO $logTableZones VALUES(st_geomfromtext('${zones.geometry}',4326) , + '$id_zone', 'Error computing geoindicators', + '${Geoindicators.version()}', + '${Geoindicators.buildNumber()}' )""".toString()) return } else { results.putAll(geoIndicators) @@ -631,7 +635,10 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d } } else { info "Cannot create a grid to aggregate the indicators" - h2gis_datasource.execute "INSERT INTO $logTableZones VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error computing the grid indicators')".toString() + h2gis_datasource.execute("""INSERT INTO $logTableZones + VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error computing the grid indicators' + '${Geoindicators.version()}', + '${Geoindicators.buildNumber()}')""".toString()) } } @@ -648,19 +655,27 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d h2gis_datasource.dropTable(Geoindicators.getCachedTableNames()) } else { - h2gis_datasource.execute "INSERT INTO $logTableZones VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error loading the OSM file')".toString() + h2gis_datasource.execute("""INSERT INTO $logTableZones + VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error loading the OSM file', + '${Geoindicators.version()}', + '${Geoindicators.buildNumber()}')""".toString()) error "Cannot load the OSM file ${extract}" return } } else { //Log in table - h2gis_datasource.execute "INSERT INTO $logTableZones VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error to extract the data with OverPass')".toString() + h2gis_datasource.execute("""INSERT INTO $logTableZones + VALUES(st_geomfromtext('${zones.geometry}',4326) ,'$id_zone', 'Error to extract the data with OverPass' + ,'${Geoindicators.version()}', '${Geoindicators.buildNumber()}')""".toString()) error "Cannot execute the overpass query $query" return } } else { //Log in table - h2gis_datasource.execute "INSERT INTO $logTableZones VALUES(null,'$id_zone', 'Error to extract the zone with Nominatim')".toString() + h2gis_datasource.execute("""INSERT INTO $logTableZones + VALUES(null,'$id_zone', 'Error to extract the zone with Nominatim', + '${Geoindicators.version()}', + '${Geoindicators.buildNumber()}')""".toString()) return } } diff --git a/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/Loader.groovy b/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/Loader.groovy index 07e47a899c..921db702f7 100644 --- a/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/Loader.groovy +++ b/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/Loader.groovy @@ -271,6 +271,11 @@ boolean load(JdbcDataSource datasource, String osmTablesPrefix, String osmFilePa info "Load the OSM file in the database." if (datasource.load(osmFile, osmTablesPrefix, true)) { info "The input OSM file has been loaded in the database." + //We must check if there is some data at least one tag + if (datasource.getRowCount("${osmTablesPrefix}_node_tag".toString())==0) { + error "The downloaded OSM file doesn't contain any data.\n Please check the file ${osmFile} to see what happens.".toString() + return false + } return true } return false