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

Improve OSM vegetation layer to take into account soccer, rugby and camp_site #852

Merged
merged 3 commits into from
Oct 5, 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 @@ -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