Skip to content

Commit

Permalink
Merge pull request #852 from ebocher/osm_tourism_tag
Browse files Browse the repository at this point in the history
Improve OSM vegetation layer to take into account soccer, rugby and camp_site
  • Loading branch information
ebocher authored Oct 5, 2023
2 parents b858e91 + 5becb77 commit 008e4c8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,29 @@ String formatVegetationLayer(JdbcDataSource datasource, String vegetation, Strin
datasource.eachRow(queryMapper) { row ->
def type = getTypeValue(row, columnNames, mappingType)
if (type) {
def height_class = typeAndVegClass[type]
def zindex = getZIndex(row."layer")
Geometry geom = row.the_geom
int epsg = geom.getSRID()
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry subGeom = geom.getGeometryN(i)
if (subGeom instanceof Polygon && subGeom.getArea()>1) {
stmt.addBatch """
//Check surface
boolean addGeom = true
if (row."surface" && row."surface" != "grass") {
addGeom=false
}
if (addGeom) {
def height_class = typeAndVegClass[type]
def zindex = getZIndex(row."layer")

Geometry geom = row.the_geom
int epsg = geom.getSRID()
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry subGeom = geom.getGeometryN(i)
if (subGeom instanceof Polygon && subGeom.getArea() > 1) {
stmt.addBatch """
INSERT INTO $outputTableName VALUES(
ST_GEOMFROMTEXT('${subGeom}',$epsg),
${rowcount++},
'${row.id}',
${singleQuote(type)},
${singleQuote(height_class)}, ${zindex})
""".toString()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Map extractAndCreateGISLayers(JdbcDataSource datasource, Object zoneToExtract, f
def keysValues = ["building", "railway", "amenity",
"leisure", "highway", "natural",
"landuse", "landcover",
"vegetation", "waterway", "area", "aeroway", "area:aeroway"]
"vegetation", "waterway", "area", "aeroway", "area:aeroway", "tourism", "sport"]
query = "[maxsize:1073741824]" + OSMTools.Utilities.buildOSMQueryWithAllData(envelope, keysValues, OSMElement.NODE, OSMElement.WAY, OSMElement.RELATION)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d
def keysValues = ["building", "railway", "amenity",
"leisure", "highway", "natural",
"landuse", "landcover",
"vegetation", "waterway", "area", "aeroway", "area:aeroway"]
"vegetation", "waterway", "area", "aeroway", "area:aeroway", "tourism", "sport"]
query = "[timeout:$overpass_timeout][maxsize:$overpass_maxsize]" + OSMTools.Utilities.buildOSMQueryWithAllData(zones.envelope, keysValues, OSMElement.NODE, OSMElement.WAY, OSMElement.RELATION)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"produce": [],
"surface": [
"grass"
]
],
"tourism": ["camp_site"],
"sport": []
},
"columns": [
"natural",
Expand All @@ -63,7 +65,9 @@
"produce",
"layer",
"surface",
"leisure"
"leisure",
"tourism",
"sport"
],
"type": {
"farmland": {
Expand Down Expand Up @@ -121,7 +125,9 @@
],
"surface": [
"grass"
]
],
"tourism": ["camp_site"],
"sport": ["soccer", "rugby"]
},
"grassland": {
"landcover": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class InputDataFormattingTest {
assertEquals 1038, h2GIS.getTable(extractData.building).rowCount
assertEquals 211, h2GIS.getTable(extractData.road).rowCount
assertEquals 44, h2GIS.getTable(extractData.rail).rowCount
assertEquals 135, h2GIS.getTable(extractData.vegetation).rowCount
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
Expand Down Expand Up @@ -248,7 +248,7 @@ class InputDataFormattingTest {
assertEquals 1038, h2GIS.getTable(extractData.building).rowCount
assertEquals 211, h2GIS.getTable(extractData.road).rowCount
assertEquals 44, h2GIS.getTable(extractData.rail).rowCount
assertEquals 135, h2GIS.getTable(extractData.vegetation).rowCount
assertEquals 136, h2GIS.getTable(extractData.vegetation).rowCount
assertEquals 10, h2GIS.getTable(extractData.water).rowCount
assertEquals 47, h2GIS.getTable(extractData.impervious).rowCount

Expand Down Expand Up @@ -311,7 +311,7 @@ class InputDataFormattingTest {

zoneToExtract = "Göteborgs Stad"

zoneToExtract = "Dijon"
zoneToExtract = "Ploemeur"

//zoneToExtract = [69.24666, 28.3359, 69.32999, 28.41923]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class InputDataLoadingTest {
Map extract = OSM.InputDataLoading.createGISLayers(h2GIS, osmfile, 2154)
assertEquals 1038, h2GIS.getTable(extract.building).rowCount

assertEquals 135, h2GIS.getTable(extract.vegetation).rowCount
assertEquals 136, h2GIS.getTable(extract.vegetation).rowCount
assertEquals 211, h2GIS.getTable(extract.road).rowCount

assertEquals 44, h2GIS.getTable(extract.rail).rowCount
Expand Down

0 comments on commit 008e4c8

Please sign in to comment.