diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy index 2393453556..06ae84953a 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy @@ -930,7 +930,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { Map geoIndicators = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(h2gis_datasource, zone, building, road, rail, vegetation, - water, impervious, "", "", "", + water, impervious, "", "", urban_areas,"", rsu_indicators_params, processing_parameters.prefixName) if (!geoIndicators) { error "Cannot build the geoindicators for the zone $id_zone" diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnits.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnits.groovy index 48d4fa77fa..0b1a9da7a7 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnits.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnits.groovy @@ -50,6 +50,7 @@ import static org.h2gis.network.functions.ST_ConnectedComponents.getConnectedCom * @param vegetation The vegetation table to be processed * @param water The water table to be processed * @param sea_land_mask The table to distinguish sea from land + * @param urban_areas The table to distinguish the urban areas * @param surface_vegetation A double value to select the vegetation geometry areas. * Expressed in geometry unit of the vegetationTable, default 10000 * @param surface_hydro A double value to select the hydrographic geometry areas. @@ -59,7 +60,7 @@ import static org.h2gis.network.functions.ST_ConnectedComponents.getConnectedCom */ String createTSU(JdbcDataSource datasource, String zone, double area = 1f, String road, String rail, String vegetation, - String water, String sea_land_mask, + String water, String sea_land_mask,String urban_areas, double surface_vegetation, double surface_hydro, String prefixName) { def BASE_NAME = "rsu" @@ -70,7 +71,7 @@ String createTSU(JdbcDataSource datasource, String zone, def tsuDataPrepared = prepareTSUData(datasource, zone, road, rail, - vegetation, water, sea_land_mask, surface_vegetation, surface_hydro, prefixName) + vegetation, water, sea_land_mask, urban_areas, surface_vegetation, surface_hydro, prefixName) if (!tsuDataPrepared) { info "Cannot prepare the data for RSU calculation." return @@ -156,6 +157,8 @@ String createTSU(JdbcDataSource datasource, String inputTableName, String inputz * @param rail The rail table to be processed * @param vegetation The vegetation table to be processed * @param water The hydrographic table to be processed + * @param water The sea mask to be processed + * @param water The urban areas table to be processed * @param surface_vegetation A double value to select the vegetation geometry areas. * Expressed in geometry unit of the vegetationTable. 10000 m² seems correct. * @param sea_land_mask The table to distinguish sea from land @@ -167,7 +170,7 @@ String createTSU(JdbcDataSource datasource, String inputTableName, String inputz * @return A database table name. */ String prepareTSUData(JdbcDataSource datasource, String zone, String road, String rail, - String vegetation, String water, String sea_land_mask, + String vegetation, String water, String sea_land_mask, String urban_areas, double surface_vegetation, double surface_hydro, String prefixName = "unified_abstract_model") { if (surface_vegetation <= 100) { error("The surface of vegetation must be greater or equal than 100 m²") @@ -320,6 +323,14 @@ String prepareTSUData(JdbcDataSource datasource, String zone, String road, Strin } } + if (water && datasource.hasTable(urban_areas)) { + if (datasource.getColumnNames(urban_areas).size() > 0) { + debug "Preparing urban areas..." + queryCreateOutputTable += [urban_areas_tmp: "(SELECT ST_ToMultiLine(THE_GEOM) FROM $urban_areas)"] + + } + } + // The input table that contains the geometries to be transformed as TSU debug "Grouping all tables..." if (queryCreateOutputTable) { diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index db1146f88e..53f407da35 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -1006,6 +1006,8 @@ Map computeTypologyIndicators(JdbcDataSource datasource, String building_indicat * @param rail The rail table to be processed * @param vegetation The vegetation table to be processed * @param water The hydrographic table to be processed + * @param sea_land_mask The sea areas to be processed + * @param urban_areas The urban areas table to be processed * @param rsu Only if the RSU table is provided by the user (otherwise the default RSU is calculated) * @param surface_vegetation The minimum area of vegetation that will be considered to delineate the RSU (default 100,000 m²) * @param surface_hydro The minimum area of water that will be considered to delineate the RSU (default 2,500 m²) @@ -1021,7 +1023,7 @@ Map computeTypologyIndicators(JdbcDataSource datasource, String building_indicat */ Map createUnitsOfAnalysis(JdbcDataSource datasource, String zone, String building, String road, String rail, String vegetation, - String water, String sea_land_mask, + String water, String sea_land_mask, String urban_areas, String rsu, double surface_vegetation, double surface_hydro, double snappingTolerance, List indicatorUse = ["LCZ", "UTRF", "TEB"], String prefixName = "") { info "Create the units of analysis..." @@ -1031,7 +1033,7 @@ Map createUnitsOfAnalysis(JdbcDataSource datasource, String zone, String buildin // Create the RSU rsu = Geoindicators.SpatialUnits.createTSU(datasource, zone, road, rail, vegetation, water, - sea_land_mask, surface_vegetation, + sea_land_mask, urban_areas, surface_vegetation, surface_hydro, prefixName) if (!rsu) { info "Cannot compute the RSU." @@ -1203,7 +1205,7 @@ Map getParameters(Map parameters) { */ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String building, String road, String rail, String vegetation, String water, String impervious, String buildingEstimateTableName, - String sea_land_mask, String rsuTable, + String sea_land_mask,String urban_areas, String rsuTable, Map parameters = [:], String prefixName) { Map inputParameters = getParameters() if (parameters) { @@ -1232,7 +1234,7 @@ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String build road, rail, vegetation, water, impervious, buildingEstimateTableName, - sea_land_mask, rsuTable, + sea_land_mask, urban_areas, rsuTable, surface_vegetation, surface_hydro, snappingTolerance, buildingHeightModelName, prefixName) @@ -1272,7 +1274,7 @@ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String build Map spatialUnitsForCalc = createUnitsOfAnalysis(datasource, zone, building, road, rail, vegetation, - water, sea_land_mask, rsuTable, + water, sea_land_mask, "", rsuTable, surface_vegetation, surface_hydro, snappingTolerance, indicatorUse, prefixName) @@ -1322,7 +1324,7 @@ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String build Map spatialUnits = createUnitsOfAnalysis(datasource, zone, building, road, rail, vegetation, - water, sea_land_mask, "", + water, sea_land_mask, "","", surface_vegetation, surface_hydro, snappingTolerance, indicatorUse, prefixName) @@ -1359,7 +1361,7 @@ Map computeAllGeoIndicators(JdbcDataSource datasource, String zone, String build Map estimateBuildingHeight(JdbcDataSource datasource, String zone, String building, String road, String rail, String vegetation, String water, String impervious, - String building_estimate, String sea_land_mask, String rsu, + String building_estimate, String sea_land_mask, String urban_areas, String rsu, double surface_vegetation, double surface_hydro, double snappingTolerance, String buildingHeightModelName, String prefixName = "") { if (!building_estimate) { @@ -1375,7 +1377,7 @@ Map estimateBuildingHeight(JdbcDataSource datasource, String zone, String buildi //Create spatial units and relations : building, block, rsu Map spatialUnits = createUnitsOfAnalysis(datasource, zone, building, road, rail, vegetation, - water, sea_land_mask, rsu, + water, sea_land_mask, urban_areas, rsu, surface_vegetation, surface_hydro, snappingTolerance, ["UTRF"], prefixName) if (!spatialUnits) { diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicatorsTests.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicatorsTests.groovy index 8690354c73..db6476f092 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicatorsTests.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicatorsTests.groovy @@ -413,7 +413,7 @@ class RsuIndicatorsTests { def outputTableGeoms = Geoindicators.SpatialUnits.prepareTSUData(h2GIS, 'zone_test', 'road_test', '', - 'veget_test', 'hydro_test', "", + 'veget_test', 'hydro_test', "","", 10000, 2500, "prepare_rsu") assertNotNull h2GIS.getTable(outputTableGeoms) diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnitsTests.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnitsTests.groovy index 69f301f2b3..812b8bf789 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnitsTests.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/SpatialUnitsTests.groovy @@ -79,7 +79,7 @@ class SpatialUnitsTests { def outputTableGeoms = Geoindicators.SpatialUnits.prepareTSUData(h2GIS, 'zone_test', 'road_test', 'rail_test', - 'veget_test', 'hydro_test', "", + 'veget_test', 'hydro_test', "","", 10000, 2500, "block") assertNotNull(outputTableGeoms) @@ -103,7 +103,7 @@ class SpatialUnitsTests { def createRSU = Geoindicators.SpatialUnits.createTSU(h2GIS, "zone_test", 'road_test', 'rail_test', 'veget_test', 'hydro_test', - "", 10000, 2500, "block") + "","", 10000, 2500, "block") assert createRSU assert h2GIS.getSpatialTable(createRSU).save(new File(folder, "rsu.shp").getAbsolutePath(), true) @@ -188,7 +188,7 @@ class SpatialUnitsTests { def outputTableGeoms = Geoindicators.SpatialUnits.prepareTSUData(h2GIS, 'zone_test', 'road_test', 'rail_test', 'veget_test', - 'hydro_test', "", 10000, 2500, "block") + 'hydro_test', "", "",10000, 2500, "block") assertNotNull(outputTableGeoms) diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 7943131526..13ac4da1a8 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -130,7 +130,7 @@ class WorkflowGeoIndicatorsTest { Map geoIndicatorsCompute_i = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(datasource, inputTableNames.zoneTable, inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, - inputTableNames.hydrographicTable, "", "", "", "", + inputTableNames.hydrographicTable, "", "", "", "","", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -173,7 +173,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", + "", "", "","", ["indicatorUse": indicatorUse, svfSimplified: false, "utrfModelName": "UTRF_BDTOPO_V2_RF_2_2.model"], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -245,7 +245,7 @@ class WorkflowGeoIndicatorsTest { Map geoIndicatorsCompute_i = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(datasource, inputTableNames.zoneTable, inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, - inputTableNames.hydrographicTable, "", + inputTableNames.hydrographicTable, "","", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -287,7 +287,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "","", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -327,7 +327,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "", "",["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -368,7 +368,8 @@ class WorkflowGeoIndicatorsTest { .computeAllGeoIndicators(datasource, inputTableNames.zoneTable, inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, - inputTableNames.hydrographicTable, "", "", "", "", + inputTableNames.hydrographicTable, "", "", "", + "","", ["indicatorUse": indicatorUse, "svfSimplified": false], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -410,7 +411,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "", "",["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) def expectListRsuTempo = listColBasic + listColCommon diff --git a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy index 81f068e9a8..90abd4a345 100644 --- a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy +++ b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy @@ -1001,12 +1001,22 @@ String formatUrbanAreas(JdbcDataSource datasource, String urban_areas, String zo queryMapper += ", a.the_geom as the_geom FROM $urban_areas as a" } + + def constructions = ["industrial", "commercial", "residential"] int rowcount = 1 datasource.withBatch(100) { stmt -> datasource.eachRow(queryMapper) { row -> def typeAndUseValues = getTypeAndUse(row, columnNames, mappingType) def use = typeAndUseValues[1] def type = typeAndUseValues[0] + //Check if the urban areas is under construction + if(type == "construction"){ + def construction = row."construction" + if(construction && construction in constructions){ + type = construction + use = construction + } + } Geometry geom = row.the_geom int epsg = geom.getSRID() for (int i = 0; i < geom.getNumGeometries(); i++) { diff --git a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy index 95e27e96f7..a22326ecc5 100644 --- a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy +++ b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy @@ -534,7 +534,7 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d hydrographicTableName, imperviousTableName, buildingEstimateTableName, seaLandMaskTableName, - "", + urbanAreasTable,"", rsu_indicators_params, processing_parameters.prefixName) if (!geoIndicators) { diff --git a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json index 90376e022c..b9d18e6f0b 100644 --- a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json +++ b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json @@ -4,14 +4,22 @@ "commercial", "residential", "retail", - "industrial" - ] + "industrial", + "construction" + ], + "construction":[] }, "columns": [ "landuse", - "industrial" + "industrial", + "construction" ], "type": { + "construction": { + "landuse": [ + "construction" + ] + }, "commercial": { "landuse": [ "commercial", diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy index 7bdb802b1f..7c8ef62e05 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy @@ -67,7 +67,7 @@ class InputDataFormattingTest { assertEquals 136, h2GIS.getTable(extractData.vegetation).rowCount assertEquals 10, h2GIS.getTable(extractData.water).rowCount assertEquals 47, h2GIS.getTable(extractData.impervious).rowCount - assertEquals 6, h2GIS.getTable(extractData.urban_areas).rowCount + assertEquals 7, h2GIS.getTable(extractData.urban_areas).rowCount assertEquals 0, h2GIS.getTable(extractData.coastline).rowCount //Buildings diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataLoadingTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataLoadingTest.groovy index f20e8f0593..0fa82566c7 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataLoadingTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataLoadingTest.groovy @@ -66,7 +66,7 @@ class InputDataLoadingTest { assertEquals 47, h2GIS.getTable(extract.impervious).rowCount - assertEquals 6, h2GIS.getTable(extract.urban_areas).rowCount + assertEquals 7, h2GIS.getTable(extract.urban_areas).rowCount } //This test is used for debug purpose diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy index 36a62227b4..d68a1e9305 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy @@ -101,8 +101,8 @@ class WorflowOSMTest extends WorkflowAbstractTest { datasource.load(urlZone, zone, true) //Run tests geoIndicatorsCalc(dirFile.absolutePath, datasource, zone, buildingTableName, roadTableName, - railTableName, vegetationTableName, hydrographicTableName, null, "", - saveResults, svfSimplified, indicatorUse, prefixName) + railTableName, vegetationTableName, hydrographicTableName, "", "","", + saveResults, svfSimplified, indicatorUse, prefixName, false) } @Test @@ -196,7 +196,7 @@ class WorflowOSMTest extends WorkflowAbstractTest { //Run tests geoIndicatorsCalc(dirFile.absolutePath, datasource, zone, buildingTableName, roadTableName, - railTableName, vegetationTableName, hydrographicTableName, imperviousTableName, sealandTableName, + railTableName, vegetationTableName, hydrographicTableName, imperviousTableName, sealandTableName,"", saveResults, svfSimplified, indicatorUse, prefixName, true) } @@ -663,7 +663,7 @@ class WorflowOSMTest extends WorkflowAbstractTest { "delete": false ], "input" : [ - "locations": ["Redon"],//["Pont-de-Veyle"],//[nominatim["bbox"]],//["Lorient"], + "locations": [[47.081403,-1.481352,47.110619,-1.423845]],//["Pont-de-Veyle"],//[nominatim["bbox"]],//["Lorient"], "area": 2800, /*"timeout":182, "maxsize": 536870918, diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorkflowAbstractTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorkflowAbstractTest.groovy index a965a6b913..7e2c6dee7c 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorkflowAbstractTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorkflowAbstractTest.groovy @@ -44,13 +44,14 @@ class WorkflowAbstractTest { */ void geoIndicatorsCalc(String directory, def datasource, String zone, String buildingTableName, String roadTableName, String railTableName, String vegetationTableName, - String hydrographicTableName, String imperviousTableName = null, String sealandmaskTableName = "", + String hydrographicTableName, String imperviousTableName , String sealandmaskTableName , + String urban_areas , boolean saveResults, boolean svfSimplified = false, def indicatorUse, String prefixName = "", boolean onlySea = false) { //Create spatial units and relations : building, block, rsu Map spatialUnits = Geoindicators.WorkflowGeoIndicators.createUnitsOfAnalysis(datasource, zone, buildingTableName, roadTableName, railTableName, vegetationTableName, - hydrographicTableName, sealandmaskTableName, "", 10000, + hydrographicTableName, sealandmaskTableName, urban_areas, "", 10000, 2500, 0.01, indicatorUse, prefixName) String relationBuildings = spatialUnits.building