Skip to content

Commit

Permalink
Merge pull request #620 from ebocher/fix_outputsrid_issues
Browse files Browse the repository at this point in the history
Fix a bug when the user set an output srid
  • Loading branch information
ebocher authored Sep 1, 2021
2 parents ca2f0d2 + eac3682 commit c0a68f8
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bdtopo_v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<parent>
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoclimate-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ IProcess workflow() {
return null
}
def outputSRID = output.get("srid")
if(outputSRID && outputSRID>=0){
error "The ouput srid must be greater or equal than 0"
return null
if(outputSRID && outputSRID <= 0) {
error "The ouput srid must be greater or equal than 0"
return null
}
if (outputDataBase && outputFolder) {
def outputFolderProperties = outputFolderProperties(outputFolder)
Expand Down Expand Up @@ -541,7 +541,7 @@ IProcess workflow() {
return null
}
if (file_outputFolder.canWrite()) {
def codes = inputDataBase.id_zones*.trim()
def codes = inputDataBase.id_zones
if (codes && codes in Collection) {
def inputTableNames = inputDataBase.tables
def h2gis_datasource = H2GIS.open(h2gis_properties)
Expand Down Expand Up @@ -580,7 +580,7 @@ IProcess workflow() {
allowedOutputTableNames.size()
if (allowedOutputTableNames && !notSameTableNames) {
def finalOutputTables = outputTableNames.subMap(allowedOutputTableNames)
def codes = inputDataBase.id_zones*.trim()
def codes = inputDataBase.id_zones
if (codes && codes in Collection) {
def inputTableNames = inputDataBase.tables
def h2gis_datasource = H2GIS.open(h2gis_properties)
Expand Down Expand Up @@ -1263,10 +1263,15 @@ def extractProcessingParameters(def processing_parameters){
*/
def bdtopo_processing(def h2gis_datasource, def processing_parameters,def id_zones, def outputFolder, def outputFiles, def output_datasource, def outputTableNames, def outputSRID, def deleteOutputData=true){
def srid = h2gis_datasource.getSpatialTable("COMMUNE").srid
if(!(id_zones in Collection)){
id_zones = [id_zones]
def id_zone
if(id_zones in Collection){
id_zone = id_zones.join("-")
}else if (id_zones instanceof String){
id_zone = id_zones
}
if(!id_zone){
error "Invalid id_zones input"
}
int nbAreas = id_zones.size();

def reproject =false
if(outputSRID){
Expand All @@ -1276,8 +1281,7 @@ def bdtopo_processing(def h2gis_datasource, def processing_parameters,def id_zo
}else{
outputSRID =srid
}
//Let's run the BDTopo process for each insee code
id_zones.eachWithIndex { id_zone, index->
//Let's run the BDTopo process for the id_zone
def start = System.currentTimeMillis()
info "Starting to process insee id_zone $id_zone"
//Load and format the BDTopo data
Expand Down Expand Up @@ -1377,11 +1381,7 @@ def bdtopo_processing(def h2gis_datasource, def processing_parameters,def id_zo

}
info "${id_zone} has been processed"


}
info "Number of areas processed ${index+1} on $nbAreas"
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,65 @@ class WorkflowBDTopo_V2Test extends WorkflowAbstractTest{
assertTrue(process.execute(configurationFile: createConfigFile(workflow_parameters, directory)))
}

@Disabled //Use it for integration test with a postgis database
@org.junit.jupiter.api.Test
void testIntegrationPostGISInput() {
def user = ""
def password = ""
def url = "jdbc:postgresql://x:5432/x"

def id_zones = [[6785161.292786511,346264.052218681,6794396.60947986,356288.94475984486], "56223"]
String directory ="./target/bdtopo_workflow_postgis_input"
File dirFile = new File(directory)
dirFile.delete()
dirFile.mkdir()
def bdTopoParameters = [
"description" :"Example of configuration file to run the BDTopo workflow and store the results in a folder",
"geoclimatedb" : [
"folder" : "${dirFile.absolutePath}",
"name" : "bdtopo_workflow_db;AUTO_SERVER=TRUE",
"delete" :true
],
"input" : ["bdtopo_v2": [
"database": [
"user":user,
"password": password,
"url": url,
"id_zones":id_zones,
"tables": ["commune":"ign_bdtopo_2017.commune",
"bati_indifferencie":"ign_bdtopo_2017.bati_indifferencie",
"bati_industriel":"ign_bdtopo_2017.bati_industriel",
"bati_remarquable":"ign_bdtopo_2017.bati_remarquable",
"route":"ign_bdtopo_2017.route",
"troncon_voie_ferree":"ign_bdtopo_2017.troncon_voie_ferree",
"surface_eau":"ign_bdtopo_2017.surface_eau",
"zone_vegetation":"ign_bdtopo_2017.zone_vegetation",
"terrain_sport":"ign_bdtopo_2017.terrain_sport",
"construction_surfacique":"ign_bdtopo_2017.construction_surfacique",
"surface_route":"ign_bdtopo_2017.surface_route",
"surface_activite":"ign_bdtopo_2017.surface_activite",
"piste_aerodrome":"ign_bdtopo_2017.piste_aerodrome"]
]]],
"output" :[
"folder" : ["path": "$directory"]],
"parameters":
["distance" : 0,
rsu_indicators: [
"indicatorUse": ["LCZ", "UTRF"],
"svfSimplified": true
],
"grid_indicators": [
"x_size": 1000,
"y_size": 1000,
"indicators": ["LCZ_FRACTION"]
]
]
]
IProcess process = BDTopo_V2.WorkflowBDTopo_V2.workflow()
assertTrue(process.execute(configurationFile: createConfigFile(bdTopoParameters, directory)))

}


/**
* Check if the table exist and contains at least one row
Expand Down
2 changes: 1 addition & 1 deletion geoclimate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoclimate-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GeoclimateTest {

@Test
void propertiesTest() {
assert "1.0.0-SNAPSHOT" == Geoclimate.version
assert "0.0.1" == Geoclimate.version
assert Pattern.compile("\\d\\d\\d\\d(-\\d\\d){5}").matcher(Geoclimate.build).matches()
}

Expand Down
4 changes: 2 additions & 2 deletions geoindicators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<parent>
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoclimate-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoindicators</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 2 additions & 2 deletions osm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<artifactId>geoclimate-parent</artifactId>
<groupId>org.orbisgis.geoclimate</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>osm</artifactId>
<groupId>org.orbisgis.geoclimate</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ IProcess workflow() {
return
}
def outputSRID = output.get("srid")
if(!outputSRID && outputSRID>=0){
if(outputSRID && outputSRID<=0){
error "The output srid must be greater or equal than 0"
return null
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoclimate-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1</version>
<modules>
<module>geoindicators</module>
<module>bdtopo_v2</module>
Expand Down

0 comments on commit c0a68f8

Please # to comment.