Skip to content

Commit

Permalink
Solve orbisgis#863
Browse files Browse the repository at this point in the history
  • Loading branch information
j3r3m1 committed Jan 9, 2024
1 parent 9b13b3f commit d456bab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ String formatEstimatedBuilding(JdbcDataSource datasource, String inputTableName,
def heightRoof = row.height_roof
def heightWall = heightRoof
def type = row.type
def nbLevels = Math.floor(heightRoof / h_lev_min)
def nbLevels = Math.max(Math.floor(heightRoof / h_lev_min), 1)
stmt.addBatch """
INSERT INTO ${outputTableName} values(
ST_GEOMFROMTEXT('${row.the_geom}',$epsg),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import java.util.regex.Pattern
* @param building The name of the raw buildings table in the DB
* @param zone an envelope to reduce the study area
* @param urban_areas used to improved the building type
* @param building The name of the raw buildings table in the DB
* @param hLevMin Minimum building level height
* @param jsonFilename Name of the json formatted file containing the filtering parameters
* @return outputTableName The name of the final buildings table
Expand Down Expand Up @@ -806,6 +805,12 @@ static Map formatHeightsAndNbLevels(def heightWall, def heightRoof, def nbLevels
nbLevels = Math.floor(heightWall / h_lev_min)
}
}

// Set the nb of levels to 1 if building height > 0
if (nbLevels == 0 && heightRoof > 0 && heightWall > 0){
nbLevels = 1
}

return [heightWall: heightWall, heightRoof: heightRoof, nbLevels: nbLevels, estimated: estimated]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,13 @@ class InputDataFormattingTest {
assertEquals 1038, h2GIS.getTable(buildingLayer).rowCount
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where NB_LEV is null").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where NB_LEV<0").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where NB_LEV=0").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where HEIGHT_WALL is null").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where HEIGHT_WALL<0").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where HEIGHT_ROOF is null").count == 0
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayer} where HEIGHT_ROOF<0").count == 0
assertEquals 1038, h2GIS.getTable(buildingLayers.building_estimated).rowCount
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayers.building_estimated} where ESTIMATED = false").count == 4
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayers.building_estimated} where ESTIMATED = false").count == 5
assertTrue h2GIS.firstRow("select count(*) as count from ${buildingLayers.building} join ${buildingLayers.building_estimated} using (id_build, id_source) where 1=1").count == 1038

//Buildings without estimation state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ class WorflowOSMTest extends WorkflowAbstractTest {
//def nominatim = org.orbisgis.geoclimate.osmtools.OSMTools.Utilities.getNominatimData("Redon")
// location = nominatim.bbox

location=[50, 8.6, 50.2, 8.8]
location=[43.725068,7.297883,43.727635,7.301284]

def osm_parmeters = [
"description" : "Example of configuration file to run the OSM workflow and store the result in a folder",
Expand All @@ -675,7 +675,7 @@ class WorflowOSMTest extends WorkflowAbstractTest {
["distance" : 0,
"rsu_indicators" : [

"indicatorUse": ["LCZ"] //, "UTRF", "TEB"]
"indicatorUse": ["LCZ", "UTRF"] //, "UTRF", "TEB"]

]/*,"grid_indicators": [
"x_size": 200,
Expand Down
7 changes: 5 additions & 2 deletions osm/src/test/resources/org/orbisgis/geoclimate/osm/redon.osm
Original file line number Diff line number Diff line change
Expand Up @@ -16330,9 +16330,11 @@
<nd ref="1368940458"/>
<nd ref="1368940491"/>
<tag k="addr:housenumber" v="27"/>
<tag k="height" v="13.5"/>
<tag k="height" v="2"/>
<tag k="addr:street" v="Grande Rue"/>
<tag k="building" v="yes"/>
<tag k="roof:height" v="0.3"/>
<tag k="building:levels" v="1"/>
<tag k="source" v="cadastre-dgi-fr source : Direction Générale des Impôts - Cadastre. Mise à jour : 2011"/>
</way>
<way id="122531206">
Expand All @@ -16348,6 +16350,7 @@
<nd ref="1368946413"/>
<nd ref="1368946465"/>
<tag k="building" v="yes"/>
<tag k="height" v="2"/>
<tag k="source" v="cadastre-dgi-fr source : Direction Générale des Impôts - Cadastre. Mise à jour : 2011"/>
</way>
<way id="122531210">
Expand Down Expand Up @@ -64311,4 +64314,4 @@
<tag k="website" v="https://pays-redon.jimdo.com/"/>
</relation>

</osm>
</osm>

0 comments on commit d456bab

Please sign in to comment.