Commit a5381284 authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

Parameters and code for underground building exclusion

parent cd30f891
......@@ -40,6 +40,42 @@ OUR_MAGIC = "osm2city" # Used in e.g. stg files to mark edits by osm2city
ALLOWED_BUILDING_PART_VALUES = [s.V_YES, 'residential', 'apartments', 'house', 'commercial', 'retail']
def _in_skip_list(way: op.Way) -> bool:
"""Checking if the way's name or osm_id are SKIP_LIST"""
if s.K_NAME in way.tags:
name = way.tags[s.K_NAME]
if name in parameters.SKIP_LIST:
logging.debug('SKIPPING building with name tag=%s', name)
return True
if way.osm_id in parameters.SKIP_LIST:
logging.debug('SKIPPING building with osm_id=%i', way.osm_id)
return True
return False
def _is_underground(tags: Dict[str, str]) -> bool:
"""Check in tags of building if something looks like underground - depending on parameters."""
if parameters.BUILDING_UNDERGROUND_LOCATION:
if s.K_LOCATION in tags and tags[s.K_LOCATION] in (s.V_UNDERGROUND, s.V_INDOOR):
return True
if parameters.BUILDING_UNDERGROUND_INDOOR:
if s.K_INDOOR in tags and tags[s.K_INDOOR] != s.V_NO:
return True
if parameters.BUILDING_UNDERGROUND_TUNNEL:
if s.K_TUNNEL in tags and tags[s.K_TUNNEL] != s.V_NO:
return True
if parameters.BUILDING_UNDERGROUND_LEVEL_NEGATIVE:
if s.K_LEVEL in tags and op.parse_int(tags[s.K_LEVEL], 0) < 0:
non_negative_levels = False
if s.K_LEVELS in tags and op.parse_int(tags[s.K_LEVELS], 0) >= 0:
non_negative_levels = True
if s.K_BUILDING_LEVELS in tags and op.parse_int(tags[s.K_BUILDING_LEVELS], 0) >= 0:
non_negative_levels = True
if non_negative_levels is False:
return True
return False
def _process_rectify_buildings(nodes_dict: Dict[int, op.Node], rel_nodes_dict: Dict[int, op.Node],
ways_dict: Dict[int, op.Way], coords_transform: coordinates.Transformation) -> None:
if not parameters.RECTIFY_ENABLED:
......@@ -194,6 +230,9 @@ def _process_multipolygon_buildings(nodes_dict: Dict[int, op.Node], rel_ways_dic
if member.type_ == s.V_WAY:
if member.ref in rel_ways_dict:
way = rel_ways_dict[member.ref]
# check whether we really want to have this member
if _in_skip_list(way) or _is_underground(way.tags):
continue
# because the member way already has been processed as normal way, we need to remove
# otherwise we might get flickering due to two buildings on top of each other
my_buildings.pop(way.osm_id, None)
......@@ -462,14 +501,8 @@ def _process_osm_building(nodes_dict: Dict[int, op.Node], ways_dict: Dict[int, o
if not clipping_border.contains(shg.Point(first_node.lon, first_node.lat)):
continue
# checking in SKIP_LIST
if s.K_NAME in way.tags:
name = way.tags[s.K_NAME]
if name in parameters.SKIP_LIST:
logging.debug('SKIPPING building with name tag=%s', name)
continue
if way.osm_id in parameters.SKIP_LIST:
logging.debug('SKIPPING building with osm_id=%i', way.osm_id)
# checking whether a building should be left out
if _in_skip_list(way) or _is_underground(way.tags):
continue
my_building = _make_building_from_way(nodes_dict, way.tags, way, coords_transform)
......@@ -483,7 +516,7 @@ def _process_osm_building(nodes_dict: Dict[int, op.Node], ways_dict: Dict[int, o
def _make_building_from_way(nodes_dict: Dict[int, op.Node], all_tags: Dict[str, str], way: op.Way,
coords_transform: coordinates.Transformation,
inner_ways=list()) -> Optional[building_lib.Building]:
inner_ways=None) -> Optional[building_lib.Building]:
if way.refs[0] == way.refs[-1]:
way.refs = way.refs[0:-1] # -- kick last ref if it coincides with first
......@@ -494,9 +527,9 @@ def _make_building_from_way(nodes_dict: Dict[int, op.Node], all_tags: Dict[str,
# -- make outer and inner rings from refs
outer_ring = _refs_to_ring(coords_transform, way.refs, nodes_dict)
inner_rings_list = list()
for _way in inner_ways:
inner_rings_list.append(_refs_to_ring(coords_transform, _way.refs, nodes_dict))
if inner_ways:
for _way in inner_ways:
inner_rings_list.append(_refs_to_ring(coords_transform, _way.refs, nodes_dict))
except KeyError as reason:
logging.debug("ERROR: Failed to parse building referenced node missing clipped?(%s) WayID %d %s Refs %s" % (
reason, way.osm_id, all_tags, way.refs))
......
......@@ -198,11 +198,14 @@ LOD_PERCENTAGE_DETAIL Decimal 0.5 Of the rema
============================================= ======== ======= ==============================================================================
.. _chapter-parameters-buildings-level-height:
--------------------------
Building Levels and Height
--------------------------
In OSM the height of a building can be described using the following keys:
* ``building:height``
* ``roof:height``
* ``height`` (the total of building_height and roof_height, but most often used alone)
......@@ -210,7 +213,7 @@ In OSM the height of a building can be described using the following keys:
* ``roof:levels`` (not used in osm2city)
* ``levels``
Most often none of these features are tagged and then the number of levels are determined based on the settlement type and the corresponding ``BUILDING_NUMBER_LEVELS_* `` parameter. The height is always calculated as the product of the number of levels times parameter ``BUILDING_LEVEL_HEIGHT_*``. If only the height is given, then the levels are calculated by simple rounding — and this level value is then used for calculating the height. The reason for this is that some uniformity in building heights/values is normally observed in the real world — and because the generic textures used have a defined height per level.
Most often none of these features are tagged and then the number of levels are determined based on the settlement type and the corresponding ``BUILDING_NUMBER_LEVELS_*`` parameter. The height is always calculated as the product of the number of levels times parameter ``BUILDING_LEVEL_HEIGHT_*``. If only the height is given, then the levels are calculated by simple rounding — and this level value is then used for calculating the height. The reason for this is that some uniformity in building heights/values is normally observed in the real world — and because the generic textures used have a defined height per level.
An exception to this is made for building parts in a relationship (`Simple 3D buildings`_), as the heights in this case might be necessary to be correct (e.g. a dome on a church).
......@@ -245,6 +248,42 @@ BUILDING_LEVEL_HEIGHT_INDUSTRIAL Number 6.0 Ditto for b
.. _Simple 3D buildings: http://wiki.openstreetmap.org/wiki/Simple_3D_buildings
.. _chapter-parameters-buildings-underground:
--------------------------------
Visibility Underground Buildings
--------------------------------
There seem to be challenges with consistency etc. in OSM in terms of deciding, whether something is under the ground and therefore ``osm2city`` should not render it.
According to findings in the `FG Forum <https://forum.flightgear.org/viewtopic.php?f=5&t=22809&start=1080#p347959>`_ and OSM there are different tags used, some of them better suited than others according to OSM documentation:
* ``location=underground`` or ``location=indoor`` seems to be a correct way (`key:location <https://wiki.openstreetmap.org/wiki/Key:location>`_)
* ``indoor`` has also some usage (`key:indoor <https://wiki.openstreetmap.org/wiki/Key:indoor>`_)
* ``tunnel`` is according to taginfo (`taginfo tunnel combinations <https://taginfo.openstreetmap.org/keys/?key=tunnel#combinations>`_) used max 1000 times together with buildings
* ``level`` with negative values. NB: not to be confused with ``levels`` and ``building:levels`` (see chapter :ref:`Building Levels and Height <chapter-parameters-buildings-level-height>`)
* ``layer`` is not to be used to determine visibility (`key:layer <https://wiki.openstreetmap.org/wiki/Key:layer>`_)
============================================= ======== ======= ==============================================================================
Parameter Type Default Description / Example
============================================= ======== ======= ==============================================================================
BUILDING_UNDERGROUND_LOCATION Boolean True Do not show buildings or building:parts if key ``location`` has value
``underground`` or ``indoor``.
BUILDING_UNDERGROUND_INDOOR Boolean True Do not show buildings or building:parts if key ``indoor`` is present and its
value is not ``no``.
BUILDING_UNDERGROUND_TUNNEL Boolean True Do not show buildings or building:parts if key ``tunnel`` is present and its
value is not ``no``.
BUILDING_UNDERGROUND_LEVEL_NEGATIVE Boolean True Do not show buildings or building:parts if key ``level`` has a negative value
and neither key ``levels`` or ``building:levels`` have a non-negative value.
============================================= ======== ======= ==============================================================================
.. _chapter-parameters-buildings-european-label:
------------------------------------------
......
......@@ -162,6 +162,12 @@ BUILDING_LEVEL_HEIGHT_URBAN = 3.5 # this value should not be changed unless spe
BUILDING_LEVEL_HEIGHT_RURAL = 2.5 # ditto including periphery
BUILDING_LEVEL_HEIGHT_INDUSTRIAL = 6. # for industrial and warehouse
# make sure not visible buildings or building parts are excluded
BUILDING_UNDERGROUND_LOCATION = True
BUILDING_UNDERGROUND_INDOOR = True
BUILDING_UNDERGROUND_TUNNEL = True
BUILDING_UNDERGROUND_LEVEL_NEGATIVE = True
BUILDING_USE_SHARED_WORSHIP = False # try to use shared models for worship buildings
# a hex value for the colour to be used if the colour value in OSM is missing or cannot be interpreted
......
......@@ -26,8 +26,10 @@ K_LANDUSE = 'landuse'
K_LANES = 'lanes'
K_LAYER = 'layer'
K_LEISURE = 'leisure'
K_LEVEL = 'level'
K_LEVELS = 'levels'
K_LIT = 'lit'
K_LOCATION = 'location'
K_MAN_MADE = 'man_made'
K_MANUFACTURER = 'manufacturer'
K_MANUFACTURER_TYPE = 'manufacturer_type'
......@@ -78,6 +80,7 @@ V_BUILDING = 'building'
V_DISUSED = 'disused'
V_FLAT = 'flat'
V_HANGAR = 'hangar'
V_INDOOR = 'indoor'
V_INNER = 'inner'
V_LIGHT_RAIL = 'light_rail'
V_MOTORWAY = 'motorway'
......@@ -98,6 +101,7 @@ V_TANK = 'tank'
V_TERMINAL = 'terminal'
V_TOWER = 'tower'
V_TRAM = 'tram'
V_UNDERGROUND = 'underground'
V_WATER_TOWER = 'water_tower'
V_WAY = 'way'
V_YES = 'yes'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment