diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV2Workflow.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV2Workflow.groovy index 45386eb610..a1ad1cb223 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV2Workflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV2Workflow.groovy @@ -85,7 +85,13 @@ Integer loadDataFromPostGIS(Object input_database_properties, Object code, Objec //Check if code is a string or a bbox //The zone is a osm bounding box represented by ymin,xmin , ymax,xmax, if (code in Collection) { - //def tmp_insee = code.join("_") + if(code.size()==3){ + if(code[2]<100){ + error("The distance to create a bbox from a point must be greater than 100 meters") + return + } + code = BDTopoUtils.bbox(code[0], code[1],code[2]) + } String inputTableName = """(SELECT ST_INTERSECTION(st_setsrid(the_geom, $commune_srid), ST_MakeEnvelope(${code[1]},${code[0]},${code[3]},${code[2]}, $commune_srid)) as the_geom, CODE_INSEE from $commune_location where st_setsrid(the_geom, $commune_srid) @@ -306,6 +312,13 @@ def filterLinkedShapeFiles(def location, float distance, LinkedHashMap inputTabl //Check if code is a string or a bbox //The zone is a osm bounding box represented by ymin,xmin , ymax,xmax, if (location in Collection) { + if(location.size()==3){ + if(location[2]<100){ + error("The distance to create a bbox from a point must be greater than 100 meters") + return + } + location = BDTopoUtils.bbox(location[0], location[1],location[2]) + } debug "Loading in the H2GIS database $outputTableName" h2gis_datasource.execute("""DROP TABLE IF EXISTS $outputTableName ; CREATE TABLE $outputTableName as SELECT ST_INTERSECTION(the_geom, ST_MakeEnvelope(${location[1]},${location[0]},${location[3]},${location[2]}, $sourceSRID)) as the_geom, CODE_INSEE from ${inputTables.commune} where the_geom @@ -314,6 +327,8 @@ def filterLinkedShapeFiles(def location, float distance, LinkedHashMap inputTabl debug "Loading in the H2GIS database $outputTableName" h2gis_datasource.execute("""DROP TABLE IF EXISTS $outputTableName ; CREATE TABLE $outputTableName as SELECT $formatting_geom, CODE_INSEE FROM ${inputTables.commune} WHERE CODE_INSEE='$location' or lower(nom)='${location.toLowerCase()}'""".toString()) + }else{ + return } def count = h2gis_datasource."$outputTableName".rowCount if (count > 0) { 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 aa96716a19..f721dbdf93 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/BDTopoV3Workflow.groovy @@ -55,6 +55,14 @@ def filterLinkedShapeFiles(def location, float distance, LinkedHashMap inputTabl debug "Loading in the H2GIS database $outputTableName" def communeColumns = h2gis_datasource.getColumnNames(inputTables.commune) if(communeColumns.contains("INSEE_COM")) { + if(location.size()==3){ + if(location[2]<100){ + error("The distance to create a bbox from a point must be greater than 100 meters") + return + } + location = BDTopoUtils.bbox(location[0], location[1],location[2]) + } + h2gis_datasource.execute("""DROP TABLE IF EXISTS $outputTableName ; CREATE TABLE $outputTableName as SELECT ST_INTERSECTION(the_geom, ST_MakeEnvelope(${location[1]},${location[0]},${location[3]},${location[2]}, $sourceSRID)) as the_geom, INSEE_COM AS CODE_INSEE from ${inputTables.commune} where the_geom && ST_MakeEnvelope(${location[1]},${location[0]},${location[3]},${location[2]}, $sourceSRID) """.toString()) @@ -261,6 +269,13 @@ Integer loadDataFromPostGIS(Object input_database_properties, Object code, Objec if (code in Collection) { def communeColumns = h2gis_datasource.getColumnNames(commune_location) if(communeColumns.contains("INSEE_COM")) { + if(code.size()==3){ + if(code[2]<100){ + error("The distance to create a bbox from a point must be greater than 100 meters") + return + } + code = BDTopoUtils.bbox(code[0], code[1],code[2]) + } String inputTableName = """(SELECT ST_INTERSECTION(st_setsrid(the_geom, $commune_srid), ST_MakeEnvelope(${code[1]},${code[0]},${code[3]},${code[2]}, $commune_srid)) as the_geom, INSEE_COM as CODE_INSEE from $commune_location where st_setsrid(the_geom, $commune_srid) diff --git a/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/utils/Utilities.groovy b/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/utils/Utilities.groovy index 2ee837d9cc..a3570cce19 100644 --- a/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/utils/Utilities.groovy +++ b/osmtools/src/main/groovy/org/orbisgis/geoclimate/osmtools/utils/Utilities.groovy @@ -653,7 +653,8 @@ Geometry geometryFromValues(def bbox) { return buildGeometry([bbox[1], bbox[0], bbox[3], bbox[2]]); } else if (bbox.size()==3){ - if(bbox[2]<=0){ + if(bbox[2]<100){ + error("The distance to create a bbox from a point must be greater than 100 meters") return null } return getAreaFromPoint(bbox[1], bbox[0], bbox[2])