Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ebocher committed Mar 20, 2024
1 parent 7d1b7a6 commit 8f8651b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,20 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
def defaultParameters = [distance : 1000f,
distance_buffer: 500f, prefixName: "",
hLevMin : 3]
def rsu_indicators_default = [indicatorUse : [],
svfSimplified : true,
surface_vegetation: 10000f,
surface_hydro : 2500f,
def rsu_indicators_default = [indicatorUse : [],
svfSimplified : true,
surface_vegetation : 10000f,
surface_hydro : 2500f,
surface_urban_areas: 10000f,
snappingTolerance : 0.01f,
mapOfWeights : ["sky_view_factor" : 4,
"aspect_ratio" : 3,
"building_surface_fraction" : 8,
"impervious_surface_fraction" : 0,
"pervious_surface_fraction" : 0,
"height_of_roughness_elements": 6,
"terrain_roughness_length" : 0.5],
utrfModelName : "UTRF_BDTOPO_V2_RF_2_2.model"]
snappingTolerance : 0.01f,
mapOfWeights : ["sky_view_factor" : 4,
"aspect_ratio" : 3,
"building_surface_fraction" : 8,
"impervious_surface_fraction" : 0,
"pervious_surface_fraction" : 0,
"height_of_roughness_elements": 6,
"terrain_roughness_length" : 0.5],
utrfModelName : "UTRF_BDTOPO_V2_RF_2_2.model"]
defaultParameters.put("rsu_indicators", rsu_indicators_default)

if (processing_parameters) {
Expand Down Expand Up @@ -564,13 +564,13 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
def grid_indicators_tmp = [
"x_size" : x_size,
"y_size" : y_size,
"output" : "geojson",
"output" : "fgb",
"rowCol" : false,
"indicators": allowedOutputIndicators
]
def grid_output = grid_indicators.output
if (grid_output) {
if (grid_output.toLowerCase() in ["asc", "geojson"]) {
if (grid_output.toLowerCase() in ["asc", "fgb"]) {
grid_indicators_tmp.output = grid_output.toLowerCase()
}
}
Expand Down Expand Up @@ -675,7 +675,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
//Add the GIS layers to the list of results
def outputTableNamesResult = [:]
def grid_indicators_params = processing_parameters.grid_indicators
def outputGrid = "geojson"
def outputGrid = "fgb"
if (grid_indicators_params) {
outputGrid = grid_indicators_params.output
}
Expand Down Expand Up @@ -936,7 +936,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
Map geoIndicators = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(h2gis_datasource, zone,
building, road,
rail, vegetation,
water, impervious, "", "", urban_areas,"",
water, impervious, "", "", urban_areas, "",
rsu_indicators_params, processing_parameters.prefixName)
if (!geoIndicators) {
error "Cannot build the geoindicators for the zone $id_zone"
Expand All @@ -961,7 +961,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
if (!building) {
info "Cannot compute any population data at building level"
}
tablesToDrop<<results.building
tablesToDrop << results.building
//Update the building table with the population data
results.put("building", building)

Expand Down Expand Up @@ -1003,12 +1003,12 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
if (ground_acoustic) {
results.put("ground_acoustic", ground_acoustic)
}
tablesToDrop<<gridP
tablesToDrop << gridP
}
}
}
//Clean the database
if(tablesToDrop) {
if (tablesToDrop) {
h2gis_datasource.execute("DROP TABLE IF EXISTS ${tablesToDrop.join(",")}".toString())
}
info "${id_zone} has been processed"
Expand All @@ -1018,7 +1018,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
}

/**
* Save the geoclimate tables into geojson files
* Save the geoclimate tables into files
* @param id_zone the id of the zone
* @param results a list of tables computed by geoclimate
* @param outputFolder the output folder
Expand All @@ -1029,13 +1029,13 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
def saveOutputFiles(def h2gis_datasource, def results, def outputFiles, def outputFolder, def outputSRID, def reproject, def deleteOutputData, def outputGrid) {
outputFiles.each {
if (it == "grid_indicators") {
if (outputGrid == "geojson") {
Geoindicators.WorkflowUtilities.saveToGeojson(results."$it", "${outputFolder + File.separator + it}.fgb", h2gis_datasource, outputSRID, reproject, deleteOutputData)
if (outputGrid == "fgb") {
Geoindicators.WorkflowUtilities.saveInFile(results."$it", "${outputFolder + File.separator + it}.fgb", h2gis_datasource, outputSRID, reproject, deleteOutputData)
} else if (outputGrid == "asc") {
Geoindicators.WorkflowUtilities.saveToAscGrid(results."$it", outputFolder, it, h2gis_datasource, outputSRID, reproject, deleteOutputData)
}
} else {
Geoindicators.WorkflowUtilities.saveToGeojson(results."$it", "${outputFolder + File.separator + it}.geojson", h2gis_datasource, outputSRID, reproject, deleteOutputData)
Geoindicators.WorkflowUtilities.saveInFile(results."$it", "${outputFolder + File.separator + it}.fgb", h2gis_datasource, outputSRID, reproject, deleteOutputData)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import static org.junit.jupiter.api.Assertions.*

abstract class WorkflowAbstractTest {

@TempDir(cleanup = CleanupMode.ON_SUCCESS)
static File folder


/**
* Get the version of the workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,17 @@
*/
package org.orbisgis.geoclimate.bdtopo.v2

import org.junit.jupiter.api.io.CleanupMode
import org.junit.jupiter.api.io.TempDir
import org.orbisgis.data.H2GIS
import org.orbisgis.geoclimate.bdtopo.WorkflowAbstractTest

import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.assertTrue

class WorkflowBDTopoV2Test extends WorkflowAbstractTest {

@TempDir(cleanup = CleanupMode.ON_SUCCESS)
static File folder

@Override
ArrayList getFileNames() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
package org.orbisgis.geoclimate.bdtopo.v3


import org.junit.jupiter.api.*
import org.junit.jupiter.api.io.CleanupMode
import org.junit.jupiter.api.io.TempDir
import org.orbisgis.data.H2GIS
import org.orbisgis.geoclimate.bdtopo.WorkflowAbstractTest

Expand All @@ -29,11 +30,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue

class WorkflowBDTopoV3Test extends WorkflowAbstractTest {

@TempDir(cleanup = CleanupMode.ON_SUCCESS)
static File folder


public WorkflowBDTopoV3Test(){
new File("/tmp/test_bd").mkdir()
folder = new File("/tmp/test_bd")
}
@Override
int getVersion() {
return 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ def saveToAscGrid(def outputTable, def subFolder, def filePrefix, JdbcDataSource
}

/**
* Method to save a table into a geojson file
* Method to save a table into a file
* @param outputTable name of the table to export
* @param filePath path to save the table
* @param h2gis_datasource connection to the database
* @param outputSRID srid code to reproject the outputTable.
* @param reproject true if the file must be reprojected
* @param deleteOutputData true to delete the file if exists
*/
def saveToGeojson(def outputTable, def filePath, H2GIS h2gis_datasource, def outputSRID, def reproject, def deleteOutputData) {
def saveInFile(def outputTable, def filePath, H2GIS h2gis_datasource, def outputSRID, def reproject, def deleteOutputData) {
if (outputTable && h2gis_datasource.hasTable(outputTable)) {
if (!reproject) {
h2gis_datasource.save(outputTable, filePath, deleteOutputData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import java.sql.SQLException
* * ,
* * [OPTIONAL ENTRY] "output" :{ //If not ouput is set the results are keep in the local database
* * "srid" : //optional value to reproject the data
* * "folder" : "/tmp/myResultFolder" //tmp folder to store the computed layers in a geojson format,
* * "folder" : "/tmp/myResultFolder" //tmp folder to store the computed layers in a fgb format,
* * "database": { //database parameters to store the computed layers.
* * "user": "-",
* * "password": "-",
Expand Down Expand Up @@ -633,7 +633,7 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d
}
}
//Default
def outputGrid = "geojson"
def outputGrid = "fgb"
if (grid_indicators_params) {
if (!geomEnv) {
geomEnv = h2gis_datasource.getSpatialTable(utm_zone_table).getExtent()
Expand Down Expand Up @@ -916,13 +916,13 @@ def extractProcessingParameters(def processing_parameters) {
def grid_indicators_tmp = [
"x_size" : x_size,
"y_size" : y_size,
"output" : "geojson",
"output" : "fgb",
"rowCol" : false,
"indicators": allowedOutputIndicators
]
def grid_output = grid_indicators.output
if (grid_output) {
if (grid_output.toLowerCase() in ["asc", "geojson"]) {
if (grid_output.toLowerCase() in ["asc", "fgb"]) {
grid_indicators_tmp.output = grid_output.toLowerCase()
}
}
Expand Down Expand Up @@ -967,7 +967,7 @@ def extractProcessingParameters(def processing_parameters) {


/**
* Save the geoclimate tables into geojson files
* Save the geoclimate tables into files
* @param id_zone the id of the zone
* @param results a list of tables computed by geoclimate
* @param ouputFolder the ouput folder
Expand All @@ -988,15 +988,15 @@ def saveOutputFiles(def h2gis_datasource, def id_zone, def results, def outputFi
}
outputFiles.each {
if (it == "grid_indicators") {
if (outputGrid == "geojson") {
Geoindicators.WorkflowUtilities.saveToGeojson(results."$it", "${subFolder.getAbsolutePath() + File.separator + it}.geojson", h2gis_datasource, outputSRID, reproject, deleteOutputData)
if (outputGrid == "fgb") {
Geoindicators.WorkflowUtilities.saveInFile(results."$it", "${subFolder.getAbsolutePath() + File.separator + it}.fgb", h2gis_datasource, outputSRID, reproject, deleteOutputData)
} else if (outputGrid == "asc") {
Geoindicators.WorkflowUtilities.saveToAscGrid(results."$it", subFolder.getAbsolutePath(), it, h2gis_datasource, outputSRID, reproject, deleteOutputData)
}
} else if (it == "building_height_missing") {
Geoindicators.WorkflowUtilities.saveToCSV(results."$it", "${subFolder.getAbsolutePath() + File.separator + it}.csv", h2gis_datasource, deleteOutputData)
} else {
Geoindicators.WorkflowUtilities.saveToGeojson(results."$it", "${subFolder.getAbsolutePath() + File.separator + it}.geojson", h2gis_datasource, outputSRID, reproject, deleteOutputData)
Geoindicators.WorkflowUtilities.saveInFile(results."$it", "${subFolder.getAbsolutePath() + File.separator + it}.fgb", h2gis_datasource, outputSRID, reproject, deleteOutputData)
}
}
}
Expand Down

0 comments on commit 8f8651b

Please sign in to comment.