Skip to content

Commit

Permalink
Merge pull request #978 from ebocher/master_infloop
Browse files Browse the repository at this point in the history
Fix endless process on large water geometries
  • Loading branch information
ebocher authored Jun 13, 2024
2 parents 7910c41 + 40a2733 commit 0975662
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils {
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY",
"BUILDING_HEIGHT_DIST", "FRONTAL_AREA_INDEX", "SEA_LAND_FRACTION", "ASPECT_RATIO",
"SVF", "HEIGHT_OF_ROUGHNESS_ELEMENTS", "TERRAIN_ROUGHNESS_CLASS", "URBAN_SPRAWL_AREAS",
"URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCE"]
"URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCES"]
def allowedOutputIndicators = allowed_grid_indicators.intersect(list_indicators*.toUpperCase())
if (allowedOutputIndicators) {
//Update the RSU indicators list according the grid indicators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ String rasterizeIndicators(JdbcDataSource datasource,
/*
* Make aggregation process with previous grid and current rsu lcz
*/
if (list_indicators_upper.intersect(["LCZ_FRACTION", "LCZ_PRIMARY", "URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCE"]) && rsu_lcz) {
if (list_indicators_upper.intersect(["LCZ_FRACTION", "LCZ_PRIMARY", "URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCES"]) && rsu_lcz) {
def indicatorName = "LCZ_PRIMARY"
String upperScaleAreaStatistics = Geoindicators.GenericIndicators.upperScaleAreaStatistics(
datasource, grid, grid_column_identifier,
Expand Down Expand Up @@ -2176,15 +2176,15 @@ Map sprawlIndicators(JdbcDataSource datasource, String grid_indicators, String i
}

//Concert the list of indicators to upper case
allowed_indicators = ["URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCE"]
allowed_indicators = ["URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCES"]
def list_indicators_upper = list_indicators.collect { it.toUpperCase() }

def tablesToDrop = []
def tablesToJoin = [:]
tablesToJoin.put(grid_indicators, id_grid)
String sprawl_areas
String cool_areas
if (list_indicators_upper.intersect(["URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCE"]) && grid_indicators) {
if (list_indicators_upper.intersect(["URBAN_SPRAWL_AREAS", "URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCES"]) && grid_indicators) {
sprawl_areas = Geoindicators.SpatialUnits.computeSprawlAreas(datasource, grid_indicators, distance )
}
if (sprawl_areas) {
Expand All @@ -2207,7 +2207,7 @@ Map sprawlIndicators(JdbcDataSource datasource, String grid_indicators, String i
}
}
}
if (list_indicators_upper.contains("URBAN_SPRAWL_COOL_DISTANCE")) {
if (list_indicators_upper.contains("URBAN_SPRAWL_COOL_DISTANCES")) {
cool_areas = Geoindicators.SpatialUnits.extractCoolAreas(datasource, grid_indicators, sprawl_areas, (distance / 2) as float)
if (cool_areas) {
String inverse_cool_areas = Geoindicators.SpatialUnits.inversePolygonsLayer(datasource, sprawl_areas,cool_areas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Map createGISLayers(JdbcDataSource datasource, String osmFilePath,
parametersMap = readJSONParameters(paramsDefaultFile)
tags = parametersMap.get("tags")
columnsToKeep = parametersMap.get("columns")
String water = OSMTools.Transform.toPolygons(datasource, prefix, epsg, tags, columnsToKeep, geometry, true)
String water = OSMTools.Transform.toPolygons(datasource, prefix, epsg, tags, columnsToKeep, geometry, false)
debug "Create the water layer"
if (water) {
outputHydroTableName = postfix("OSM_WATER")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def extractProcessingParameters(def processing_parameters) throws Exception {
"BUILDING_HEIGHT_WEIGHTED", "BUILDING_SURFACE_DENSITY", "BUILDING_HEIGHT_DIST",
"FRONTAL_AREA_INDEX", "SEA_LAND_FRACTION", "ASPECT_RATIO", "SVF",
"HEIGHT_OF_ROUGHNESS_ELEMENTS", "TERRAIN_ROUGHNESS_CLASS", "URBAN_SPRAWL_AREAS",
"URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCE"]
"URBAN_SPRAWL_DISTANCES", "URBAN_SPRAWL_COOL_DISTANCES"]
def allowedOutputIndicators = allowed_grid_indicators.intersect(list_indicators*.toUpperCase())
if (allowedOutputIndicators) {
//Update the RSU indicators list according the grid indicators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class InputDataFormattingTest {
//def nominatim = org.orbisgis.geoclimate.osmtools.OSMTools.Utilities.getNominatimData(zoneToExtract)
// zoneToExtract = nominatim.bbox

zoneToExtract = [43.824643, 4.383599, 43.827271, 4.388207]
zoneToExtract = [62.2, 28.2, 62.4, 28.4]

//zoneToExtract =[44.795480,12.323227,45.004622,12.627411]
Map extractData = OSM.InputDataLoading.extractAndCreateGISLayers(h2GIS, zoneToExtract)
Expand All @@ -311,7 +311,7 @@ class InputDataFormattingTest {

//Zone envelope
h2GIS.getTable(extractData.zone_envelope).save("${file.absolutePath + File.separator}zone_envelope.fgb", true)
/*

//Urban Areas
def inputUrbanAreas = OSM.InputDataFormatting.formatUrbanAreas(h2GIS,
extractData.urban_areas,extractData.zone)
Expand Down Expand Up @@ -343,17 +343,17 @@ class InputDataFormattingTest {
h2GIS,extractData.vegetation,extractData.zone_envelope)
h2GIS.save(inputVegetationTableName,"${file.absolutePath + File.separator}vegetation.fgb", true)

println("Vegetation formatted")*/
println("Vegetation formatted")

//Hydrography
def inputWaterTableName = OSM.InputDataFormatting.formatWaterLayer(h2GIS, extractData.water, extractData.zone_envelope)

//Impervious
/* String imperviousTable = OSM.InputDataFormatting.formatImperviousLayer(h2GIS, extractData.impervious,
String imperviousTable = OSM.InputDataFormatting.formatImperviousLayer(h2GIS, extractData.impervious,
extractData.zone_envelope)
h2GIS.save(imperviousTable,"${file.absolutePath + File.separator}impervious.fgb", true)

println("Impervious formatted")*/
println("Impervious formatted")

//Save coastlines to debug
h2GIS.save(extractData.coastline, "${file.absolutePath + File.separator}coastlines.fgb", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,12 @@ class WorflowOSMTest extends WorkflowAbstractTest {
File dirFile = new File(directory)
dirFile.delete()
dirFile.mkdir()
def location = "Mâcon"
def location = "Genève, Suisse"
//def nominatim = org.orbisgis.geoclimate.osmtools.OSMTools.Utilities.getNominatimData(location)
def grid_size = 100
//location = nominatim.bbox
// location=[44.795480,12.323227,45.004622,12.627411]
location=[46.178404,6.095524,46.222959,6.190109]
//location =[62.2, 28.2, 62.4, 28.4]
def osm_parmeters = [
"description" : "Example of configuration file to run the OSM workflow and store the result in a folder",
"geoclimatedb": [
Expand All @@ -674,7 +675,7 @@ class WorflowOSMTest extends WorkflowAbstractTest {
"parameters" :
["distance" : 0,
"rsu_indicators" : [
"indicatorUse": ["LCZ"] //, "UTRF", "TEB"]
"indicatorUse": ["LCZ", "TEB"] //, "UTRF", "TEB"]

], "grid_indicators" : [
"x_size" : grid_size,
Expand All @@ -692,9 +693,10 @@ class WorflowOSMTest extends WorkflowAbstractTest {
// "HEIGHT_OF_ROUGHNESS_ELEMENTS", "TERRAIN_ROUGHNESS_CLASS",
"URBAN_SPRAWL_AREAS",
"URBAN_SPRAWL_DISTANCES",
"URBAN_SPRAWL_COOL_DISTANCE"],
"lcz_lod":1
], "worldpop_indicators": true/*
"URBAN_SPRAWL_COOL_DISTANCES"]/*,
"lcz_lod":1*/
], "worldpop_indicators": true
/*
"road_traffic" : true,
"noise_indicators" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,21 +550,12 @@ def extractRelationsAsPolygons(JdbcDataSource datasource, String osmTablesPrefix
CREATE INDEX ON $relationsPolygonsOuterExploded(id_relation);
CREATE INDEX ON $relationsPolygonsInnerExploded(id_relation);
DROP TABLE IF EXISTS $relationsMpHoles;
CREATE TABLE $relationsMpHoles AS (
CREATE TABLE $relationsMpHoles AS
SELECT ST_MAKEPOLYGON(ST_EXTERIORRING(a.the_geom), ST_ACCUM(b.the_geom)) AS the_geom, a.ID_RELATION
FROM $relationsPolygonsOuterExploded AS a
LEFT JOIN $relationsPolygonsInnerExploded AS b
ON(
a.the_geom && b.the_geom
AND st_contains(a.the_geom, b.THE_GEOM)
AND a.ID_RELATION=b.ID_RELATION)
GROUP BY a.the_geom, a.id_relation)
UNION(
SELECT a.the_geom as the_geom , a.ID_RELATION
FROM $relationsPolygonsOuterExploded AS a
LEFT JOIN $relationsPolygonsInnerExploded AS b
ON a.id_relation=b.id_relation
WHERE b.id_relation IS NULL);
ON( a.ID_RELATION=b.ID_RELATION)
GROUP BY a.the_geom, a.id_relation;
CREATE INDEX ON $relationsMpHoles(id_relation);
""".toString()

Expand Down

0 comments on commit 0975662

Please sign in to comment.