diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy index b5ee2f2f54..5992fd5a58 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy @@ -220,7 +220,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { } } } catch (Exception e) { - saveLogZoneTable(h2gis_datasource, databaseFolder, location, e.getLocalizedMessage()) + saveLogZoneTable(h2gis_datasource, databaseFolder, location in Collection ? location.join("_") : location, e.getLocalizedMessage()) //eat the exception and process other zone warn("The zone $location has not been processed. Please check the log table to get more informations.") } @@ -268,7 +268,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { } } } catch (Exception e) { - saveLogZoneTable(h2gis_datasource, databaseFolder, location, e.getLocalizedMessage()) + saveLogZoneTable(h2gis_datasource, databaseFolder, location in Collection ? location.join("_") : location, e.getLocalizedMessage()) //eat the exception and process other zone warn("The zone $location has not been processed. Please check the log table to get more informations.") } @@ -293,23 +293,23 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { void saveLogZoneTable(JdbcDataSource dataSource, String databaseFolder, String location, String message) throws Exception { def logTableZones = postfix("log_zones") //Create the table to log on the processed zone - dataSource.execute("""DROP TABLE IF EXISTS $logTableZones; + dataSource """DROP TABLE IF EXISTS $logTableZones; CREATE TABLE $logTableZones (the_geom GEOMETRY(GEOMETRY, 4326), - location VARCHAR, info VARCHAR, version VARCHAR, build_number VARCHAR);""") + location VARCHAR, info VARCHAR, version VARCHAR, build_number VARCHAR);""" //Find the geometry of the location Geometry geom = dataSource.firstRow("SELECT st_union(st_accum(THE_GEOM)) as the_geom FROM commune").the_geom - if (geom == null) { - dataSource.execute("""INSERT INTO $logTableZones + if (geom == null | geom.isEmpty()) { + dataSource """INSERT INTO $logTableZones VALUES(null,'$location', '$message', '${Geoindicators.version()}', - '${Geoindicators.buildNumber()}')""") + '${Geoindicators.buildNumber()}')""" } else { - dataSource.execute("""INSERT INTO $logTableZones + dataSource """INSERT INTO $logTableZones VALUES(st_geomfromtext('${geom}',${geom.getSRID()}) ,'$location', '$message', '${Geoindicators.version()}', - '${Geoindicators.buildNumber()}')""") + '${Geoindicators.buildNumber()}')""" } - dataSource.save(logTableZones, databaseFolder + File.separator + "log_zones_" + id_zone + ".fgb", true) + dataSource.save(logTableZones, databaseFolder + File.separator + "log_zones_" + location + ".fgb", true) } /** diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy index b2f97c753f..a81f54306c 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy @@ -206,7 +206,7 @@ def filterLinkedShapeFiles(def location, float distance, LinkedHashMap inputTabl return true } else { - throw new Exception("Cannot find any commune with the insee code : $location") + throw new Exception("Cannot find any commune for the following bbox or insee code : $location") } } diff --git a/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy b/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy index 5125c6f6bc..7e727d8cff 100644 --- a/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy +++ b/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy @@ -136,8 +136,9 @@ class WorkflowDebugTest { @Disabled @Test void testIntegrationFolderInput() { - def input_data = "/home/decide/Data/URBIO/Donnees_brutes/BD_TOPO/BDTOPO_3-3_TOUSTHEMES_SHP_LAMB93_D076_2024-03-15" - def locations = ["76005", "76020"] + def input_data = "/home/bernardj/Data/BDT/V3/BDTOPO_3-3_TOUSTHEMES_SHP_LAMB93_R11_2024-03-15" + def locations = [ + [6864452.136340265, 651978.2850116278, 6865452.136340265, 652978.2850116278]] String directory = "/tmp/bdtopo3" File dirFile = new File(directory) dirFile.delete()