Skip to content

Commit

Permalink
Merge branch 'master' into bdtopo_file_path
Browse files Browse the repository at this point in the history
  • Loading branch information
ebocher authored Jun 5, 2024
2 parents 173b6fb + d99fa36 commit be6eb24
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
* @return a filled map of parameters
*/
def extractProcessingParameters(def processing_parameters) {
def defaultParameters = [distance : 1000f,
distance_buffer: 500f, prefixName: "",
def defaultParameters = [distance : 500f, prefixName: "",
hLevMin : 3]
def rsu_indicators_default = [indicatorUse : [],
svfSimplified : true,
Expand All @@ -440,7 +439,6 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
"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) {
def distanceP = processing_parameters.distance
Expand Down Expand Up @@ -505,10 +503,9 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
rsu_indicators_default.mapOfWeights = mapOfWeightsP
}
}
} else {
rsu_indicators = rsu_indicators_default
}
defaultParameters.put("rsu_indicators", rsu_indicators_default)

}

//Check for grid indicators
def grid_indicators = processing_parameters.grid_indicators
Expand Down Expand Up @@ -929,7 +926,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
results.put("building", building)

//Compute the RSU indicators
if (rsu_indicators_params.indicatorUse) {
if (rsu_indicators_params && rsu_indicators_params.indicatorUse) {
//Build the indicators
rsu_indicators_params.put("utrfModelName", "UTRF_BDTOPO_V2_RF_2_2.model")
Map geoIndicators = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(h2gis_datasource, zone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,51 @@ abstract class WorkflowAbstractTest {
assertNotNull(process)
checkFormatData()
}

@Test
void testOnlyFormatData() {
String dataFolder = getDataFolderPath()
def bdTopoParameters = [
"description" : "Workflow format data",
"geoclimatedb": [
"folder": folder.absolutePath,
"name" : "testFormat;AUTO_SERVER=TRUE",
"delete": false
],
"input" : [
"folder" : dataFolder,
"locations": [getInseeCode()]],
"output" : [
"folder": ["path": folder.absolutePath]]
]

Map process = BDTopo.workflow(bdTopoParameters, getVersion())
assertNotNull(process)

def tableNames = process[getInseeCode()]
assertTrue(tableNames.size() > 0)
H2GIS h2gis = H2GIS.open(folder.absolutePath + File.separator + "testFormat;AUTO_SERVER=TRUE")

//Test zone
assertTrue h2gis.firstRow("select count(*) as count from ${tableNames.zone} where the_geom is not null").count > 0

//Test building
String building_table = tableNames.building
assertTrue(h2gis.firstRow("""SELECT count(*) as count from $building_table where TYPE is not null;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from $building_table where MAIN_USE is not null;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from $building_table where NB_LEV is not null or NB_LEV>0 ;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from $building_table where HEIGHT_WALL is not null or HEIGHT_WALL>0 ;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from $building_table where HEIGHT_ROOF is not null or HEIGHT_ROOF>0 ;""".toString()).count > 0)

//Test water
assertTrue(h2gis.firstRow("""SELECT count(*) as count from ${tableNames.water} where TYPE is not null;""".toString()).count > 0)

//Test vegetation
assertTrue(h2gis.firstRow("""SELECT count(*) as count from ${tableNames.vegetation} where TYPE is not null;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from ${tableNames.vegetation} where HEIGHT_CLASS is not null;""".toString()).count > 0)

//Test road
assertTrue(h2gis.firstRow("""SELECT count(*) as count from ${tableNames.road} where TYPE is not null;""".toString()).count > 0)
assertTrue(h2gis.firstRow("""SELECT count(*) as count from ${tableNames.road} where WIDTH is not null or WIDTH>0 ;""".toString()).count > 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class WorkflowDebugTest {
@Disabled
@Test
void testIntegrationFolderInput() {
def input_data = "/media/ebocher/Extreme SSD/bdtopo/bdtopo2/BDTOPO_2-2_TOUSTHEMES_SHP_LAMB93_D035_2018-09-25/BDTOPO/1_DONNEES_LIVRAISON_2018-11-00144/BDT_2-2_SHP_LAMB93_D035-ED182"
def locations = [ "Bordeaux"]
String directory = "/tmp/bdtopo2"
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"]
String directory = "/tmp/bdtopo3"
File dirFile = new File(directory)
dirFile.delete()
dirFile.mkdir()
Expand All @@ -164,23 +164,13 @@ class WorkflowDebugTest {
/*"grid_indicators": [
"x_size" : 100,
"y_size" : 100,
"indicators" :["BUILDING_FRACTION", "BUILDING_HEIGHT", "BUILDING_POP",
"BUILDING_TYPE_FRACTION", "WATER_FRACTION", "VEGETATION_FRACTION",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION",
//"FREE_EXTERNAL_FACADE_DENSITY",
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY",
"SEA_LAND_FRACTION", "ASPECT_RATIO",
//"SVF",
"HEIGHT_OF_ROUGHNESS_ELEMENTS", "TERRAIN_ROUGHNESS_CLASS",
"UTRF_AREA_FRACTION", "UTRF_FLOOR_AREA_FRACTION",
"LCZ_PRIMARY", "SPRAWL_AREAS",
"SPRAWL_DISTANCES", "SPRAWL_COOL_DISTANCE"]
"indicators" :["FREE_EXTERNAL_FACADE_DENSITY", "BUILDING_FRACTION"]
//, "lcz_lod":2
]*/
]
]
//BDTopo.v2(bdTopoParameters)

/*
input_data = "/home/ebocher/Téléchargements/BDTOPO_3-3_TOUSTHEMES_SHP_LAMB93_D033_2023-12-15/BDTOPO/1_DONNEES_LIVRAISON_2023-12-00099"
directory = "/tmp/bdtopo3"
Expand All @@ -189,7 +179,7 @@ class WorkflowDebugTest {
dirFile.mkdir()
bdTopoParameters.input.folder=input_data
bdTopoParameters.output.folder.path=directory
bdTopoParameters.output.folder.path=directory*/
BDTopo.v3(bdTopoParameters)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,5 @@ class WorkflowBDTopoV2Test extends WorkflowAbstractTest {
assertEquals(count, h2GIS.firstRow("SELECT COUNT(*) as count FROM urban_areas where type is not null").count)
assertEquals(count, h2GIS.firstRow("SELECT COUNT(*) as count FROM urban_areas where ST_ISEMPTY(THE_GEOM)=false OR THE_GEOM IS NOT NULL").count)



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
list_indicators_upper.each {
if (it == "BUILDING_FRACTION"
|| it == "BUILDING_SURFACE_DENSITY" ||
it == "ASPECT_RATIO") {
it == "ASPECT_RATIO" || it == "FREE_EXTERNAL_FACADE_DENSITY") {
columnFractionsList.put(priorities.indexOf("building"), "building")
} else if (it == "WATER_FRACTION") {
columnFractionsList.put(priorities.indexOf("water"), "water")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,60 @@ class WorflowOSMTest extends WorkflowAbstractTest {
assertTrue h2gis.firstRow("select count(*) as count from $building where HEIGHT_WALL>0 and HEIGHT_ROOF>0").count > 0
}


@Test
void testCreateGISLayers() {
String directory = folder.absolutePath + File.separator + "test_creategislayers"
File dirFile = new File(directory)
dirFile.delete()
dirFile.mkdir()
def osm_parmeters = [
"geoclimatedb": [
"folder": dirFile.absolutePath,
"name" : "geoclimate_chain_db",
"delete": false
],
"input" : [
"locations": [[43.726898,7.298452,100]]],
"output" : [
"folder": ["path" : directory,
"tables": ["building", "zone"]]]
]
Map process = OSM.WorkflowOSM.workflow(osm_parmeters)
def tableNames = process.values()
def building = tableNames.building[0]
def zone = tableNames.zone[0]
H2GIS h2gis = H2GIS.open("${directory + File.separator}geoclimate_chain_db;AUTO_SERVER=TRUE")
assertTrue h2gis.firstRow("select count(*) as count from $building where HEIGHT_WALL>0 and HEIGHT_ROOF>0").count > 0
assertEquals(1, h2gis.firstRow("select count(*) as count from $zone").count)
}

@Test
void testCreateGISLayersNoOutput() {
String directory = folder.absolutePath + File.separator + "test_no_output"
directory = "/tmp/db"
File dirFile = new File(directory)
dirFile.delete()
dirFile.mkdir()
def osm_parmeters = [
"geoclimatedb": [
"folder": dirFile.absolutePath,
"name" : "geoclimate_chain_db",
"delete": false
],
"input" : [
"locations": [[43.726898,7.298452,100]]]
]
Map process = OSM.WorkflowOSM.workflow(osm_parmeters)
def tableNames = process.values()[0]
H2GIS h2gis = H2GIS.open("${directory + File.separator}geoclimate_chain_db")
//All tables must exist in the database
tableNames.each {it->
assertTrue(h2gis.hasTable(it.value))
}
}


@Disabled //Because it takes some time to build the OSM query
@Test
void testEstimateBuildingWithAllInputHeightDate() {
Expand Down

0 comments on commit be6eb24

Please sign in to comment.