Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BDTopo 3 fix #804

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,15 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
return
}
def allowed_grid_indicators = ["BUILDING_FRACTION", "BUILDING_HEIGHT", "BUILDING_POP", "BUILDING_TYPE_FRACTION", "WATER_FRACTION", "VEGETATION_FRACTION",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION", "UTRF_AREA_FRACTION", "LCZ_FRACTION", "LCZ_PRIMARY", "FREE_EXTERNAL_FACADE_DENSITY",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION", "UTRF_AREA_FRACTION", "UTRF_FLOOR_AREA_FRACTION", "LCZ_FRACTION", "LCZ_PRIMARY", "FREE_EXTERNAL_FACADE_DENSITY",
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY", "BUILDING_HEIGHT_DIST", "FRONTAL_AREA_INDEX", "SEA_LAND_FRACTION"]
def allowedOutputIndicators = allowed_grid_indicators.intersect(list_indicators*.toUpperCase())
if (allowedOutputIndicators) {
//Update the RSU indicators list according the grid indicators
list_indicators.each { val ->
if (val.trim().toUpperCase() in ["LCZ_FRACTION", "LCZ_PRIMARY"]) {
rsu_indicators.indicatorUse << "LCZ"
} else if (val.trim().toUpperCase() in ["UTRF_AREA_FRACTION"]) {
} else if (val.trim().toUpperCase() in ["UTRF_AREA_FRACTION", "UTRF_FLOOR_AREA_FRACTION"]) {
rsu_indicators.indicatorUse << "UTRF"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class WorkflowDebugTest {
]
]
]
BDTopo.v2(bdTopoParameters)
//BDTopo.v2(bdTopoParameters)

input_data = "/media/ebocher/Extreme SSD/bdtopo/bdtopo3/BDTOPO_3-0_TOUSTHEMES_SHP_LAMB93_D035_2022-09-15/BDTOPO/1_DONNEES_LIVRAISON_2022-09-00418/BDT_3-0_SHP_LAMB93_D035-ED2022-09-15"

Expand All @@ -191,7 +191,7 @@ class WorkflowDebugTest {
bdTopoParameters.input.folder=input_data
bdTopoParameters.output.folder.path=directory

BDTopo.v2(bdTopoParameters)
//BDTopo.v2(bdTopoParameters)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ String gatherScales(JdbcDataSource datasource, String buildingTable, String bloc
*/
String upperScaleAreaStatistics(JdbcDataSource datasource, String upperTableName,
String upperColumnId, String lowerTableName,
String lowerColumnName, boolean keepGeometry = true, String prefixName) {
String lowerColumnName, String lowerColumnAlias, boolean keepGeometry = true, String prefixName) {
ISpatialTable upperTable = datasource.getSpatialTable(upperTableName)
def upperGeometryColumn = upperTable.getGeometricColumns().first()
if (!upperGeometryColumn) {
Expand Down Expand Up @@ -991,15 +991,15 @@ String upperScaleAreaStatistics(JdbcDataSource datasource, String upperTableName
AS SELECT $upperColumnId
"""
listValues.each {
def aliasColumn = "${lowerColumnName}_${it.val.toString().replace('.', '_')}"
def aliasColumn = "${lowerColumnAlias}_${it.val.toString().replace('.', '_')}"
query += """
, SUM($aliasColumn)
AS $aliasColumn
"""
}
query += " FROM (SELECT $upperColumnId"
listValues.each {
def aliasColumn = "${lowerColumnName}_${it.val.toString().replace('.', '_')}"
def aliasColumn = "${lowerColumnAlias}_${it.val.toString().replace('.', '_')}"
if (it.val) {
if (isString) {
query += """
Expand Down Expand Up @@ -1043,7 +1043,7 @@ String upperScaleAreaStatistics(JdbcDataSource datasource, String upperTableName
qjoin += ", b.$upperGeometryColumn"
}
listValues.each {
def aliasColumn = "${lowerColumnName}_${it.val.toString().replace('.', '_')}"
def aliasColumn = "${lowerColumnAlias}_${it.val.toString().replace('.', '_')}"
qjoin += """
, CASE WHEN $aliasColumn IS NULL THEN NULL ELSE $aliasColumn / ST_AREA(b.$upperGeometryColumn) END
AS $aliasColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ Map computeTypologyIndicators(JdbcDataSource datasource, String building_indicat
// Join main typo table with distribution table and replace typo by null when it has been set
// while there is no building in the RSU
datasource."$resultsDistrib"."$COLUMN_ID_RSU".createIndex()
datasource.tempo_distrib."$COLUMN_ID_RSU".createIndex()
datasource."tempo_distrib"."$COLUMN_ID_RSU".createIndex()
datasource """ DROP TABLE IF EXISTS $baseNameUtrfRsu$ind;
CREATE TABLE $baseNameUtrfRsu$ind
AS SELECT a.*,
Expand Down Expand Up @@ -1193,10 +1193,6 @@ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String build
def buildingHeightModelName = inputParameters.buildingHeightModelName
def indicatorUse = inputParameters.indicatorUse

def svfSimplified = inputParameters.svfSimplified
def mapOfWeights = inputParameters.mapOfWeights
def utrfModelName = inputParameters.utrfModelName

//Estimate height
if (inputParameters.buildingHeightModelName && datasource.getTable(building).getRowCount() > 0) {
def start = System.currentTimeMillis()
Expand Down Expand Up @@ -1612,7 +1608,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
def indicatorName = "LCZ_PRIMARY"
String upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(
datasource, grid, grid_column_identifier,
rsu_lcz, indicatorName,
rsu_lcz, indicatorName,indicatorName,
false, "lcz")
if (upperScaleAreaStatistics) {
indicatorTablesToJoin.put(upperScaleAreaStatistics, grid_column_identifier)
Expand Down Expand Up @@ -1666,21 +1662,21 @@ String rasterizeIndicators(JdbcDataSource datasource,
* Make aggregation process with previous grid and current rsu urban typo area
*/
if (list_indicators*.toUpperCase().contains("UTRF_AREA_FRACTION") && rsu_utrf_area) {
def indicatorName = "TYPO_MAJ"
String indicatorName = "TYPO_MAJ"
String upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(datasource,
grid, grid_column_identifier, rsu_utrf_area,
indicatorName, false, "utrf_area")
indicatorName,"AREA_TYPO_MAJ", false, "utrf_area")
if (upperScaleAreaStatistics) {
indicatorTablesToJoin.put(upperScaleAreaStatistics, grid_column_identifier)
} else {
info "Cannot aggregate the Urban Typology at grid scale"
}
}

if (list_indicators*.toUpperCase().contains("UTRF_AREA_FRACTION") && rsu_utrf_floor_area) {
if (list_indicators*.toUpperCase().contains("UTRF_FLOOR_AREA_FRACTION") && rsu_utrf_floor_area) {
def indicatorName = "TYPO_MAJ"
def upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(datasource,
grid, grid_column_identifier, rsu_utrf_floor_area, indicatorName, false,
grid, grid_column_identifier, rsu_utrf_floor_area, indicatorName, "FLOOR_AREA_TYPO_MAJ", false,
"utrf_floor_area")
if (upperScaleAreaStatistics) {
indicatorTablesToJoin.put(upperScaleAreaStatistics, grid_column_identifier)
Expand Down Expand Up @@ -1752,7 +1748,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
grid, grid_column_identifier,
grid_column_identifier, unweightedBuildingIndicators,
prefixName)
if (!computeBuildingStats()) {
if (!computeBuildingStats) {
info "Cannot compute the building statistics on grid cells."
return
}
Expand Down Expand Up @@ -1796,7 +1792,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
def upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(datasource, grid,
grid_column_identifier,
createScalesRelationsGridBl,
indicatorName, false,
indicatorName, indicatorName,false,
"building_type_fraction")
if (upperScaleAreaStatistics) {
indicatorTablesToJoin.put(upperScaleAreaStatistics, grid_column_identifier)
Expand Down Expand Up @@ -1852,7 +1848,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
}
}
def roofFractionDistributionExact = Geoindicators.RsuIndicators.roofFractionDistributionExact(datasource,
createScalesRelationsGridBl, grid, grid_column_identifier,
grid, createScalesRelationsGridBl,grid_column_identifier,
[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50], prefixName)
if (roofFractionDistributionExact) {
indicatorTablesToJoin.put(roofFractionDistributionExact, grid_column_identifier)
Expand Down Expand Up @@ -1909,15 +1905,13 @@ String rasterizeIndicators(JdbcDataSource datasource,

def upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(datasource,
grid, grid_column_identifier,
tesselatedSeaLandTab, seaLandTypeField,
tesselatedSeaLandTab, seaLandTypeField,seaLandTypeField,
prefixName)
if (upperScaleAreaStatistics) {
// Modify columns name to postfix with "_FRACTION"
datasource """
ALTER TABLE ${upperScaleAreaStatistics} RENAME COLUMN TYPE_LAND TO LAND_FRACTION;
ALTER TABLE ${
upperScaleAreaStatistics.results.outputTableName
} RENAME COLUMN TYPE_SEA TO SEA_FRACTION;
ALTER TABLE ${upperScaleAreaStatistics} RENAME COLUMN TYPE_SEA TO SEA_FRACTION;
ALTER TABLE ${upperScaleAreaStatistics} DROP COLUMN THE_GEOM;"""
indicatorTablesToJoin.put(upperScaleAreaStatistics, grid_column_identifier)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class GenericIndicatorsTests {
assertEquals(4, h2GIS.getSpatialTable(gridProcess).getRowCount())

def upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(h2GIS,
gridProcess, "id_grid", indicatorTableName, indicatorName, "agg")
gridProcess, "id_grid", indicatorTableName,indicatorName, indicatorName, "agg")

assertNotNull(upperScaleAreaStatistics)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,15 +831,15 @@ def extractProcessingParameters(def processing_parameters) {
return
}
def allowed_grid_indicators = ["BUILDING_FRACTION", "BUILDING_HEIGHT", "BUILDING_POP", "BUILDING_TYPE_FRACTION", "WATER_FRACTION", "VEGETATION_FRACTION",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION", "UTRF_AREA_FRACTION", "LCZ_FRACTION", "LCZ_PRIMARY", "FREE_EXTERNAL_FACADE_DENSITY",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION", "UTRF_AREA_FRACTION","UTRF_FLOOR_AREA_FRACTION", "LCZ_FRACTION", "LCZ_PRIMARY", "FREE_EXTERNAL_FACADE_DENSITY",
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY", "BUILDING_HEIGHT_DIST", "FRONTAL_AREA_INDEX", "SEA_LAND_FRACTION"]
def allowedOutputIndicators = allowed_grid_indicators.intersect(list_indicators*.toUpperCase())
if (allowedOutputIndicators) {
//Update the RSU indicators list according the grid indicators
list_indicators.each { val ->
if (val.trim().toUpperCase() in ["LCZ_FRACTION", "LCZ_PRIMARY"]) {
rsu_indicators.indicatorUse << "LCZ"
} else if (val.trim().toUpperCase() in ["UTRF_AREA_FRACTION"]) {
} else if (val.trim().toUpperCase() in ["UTRF_AREA_FRACTION", "UTRF_FLOOR_AREA_FRACTION"]) {
rsu_indicators.indicatorUse << "UTRF"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class WorflowOSMTest extends WorkflowAbstractTest {
"delete": false
],
"input" : [
"locations": ["Redon"],//[nominatim["bbox"]],
"locations": ["Bastia"],//[nominatim["bbox"]],

/*"timeout":182,
"maxsize": 536870918,
Expand All @@ -577,17 +577,18 @@ class WorflowOSMTest extends WorkflowAbstractTest {
["distance" : 0,
"rsu_indicators" : [
"indicatorUse": ["LCZ"]//, "UTRF", "TEB"]
],/*,"grid_indicators": [
],"grid_indicators": [
"x_size": 100,
"y_size": 100,
//"rowCol": true,
"indicators": ["BUILDING_FRACTION","BUILDING_HEIGHT", "BUILDING_POP",
"BUILDING_TYPE_FRACTION","WATER_FRACTION","VEGETATION_FRACTION",
"ROAD_FRACTION", "IMPERVIOUS_FRACTION", "UTRF_AREA_FRACTION",
"UTRF_FLOOR_AREA_FRACTION",
"LCZ_FRACTION", "LCZ_PRIMARY", "FREE_EXTERNAL_FACADE_DENSITY",
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY",
"BUILDING_HEIGHT_DIST", "FRONTAL_AREA_INDEX", "SEA_LAND_FRACTION"]
], */ "worldpop_indicators": true,
], "worldpop_indicators": true,
"road_traffic" : true,
"noise_indicators" : [
"ground_acoustic": true
Expand Down