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

Added parameter BOUNDARY_CLIPPING_COMPLETE_WAYS

parent aaa6ba29
This diff is collapsed.
No preview for this file type
......@@ -111,11 +111,46 @@ LOD_PERCENTAGE_DETAIL Decimal 0.5 Of the rema
============================================= ======== ======= ==============================================================================
.. _chapter-parameters-clipping:
----------------
Clipping Region
----------------
The boundary of a scenery as specified by the parameters ``BOUNDARY_*`` is not necessarily sharp. As described in :ref:`Getting OpenStreetMap Data <chapter-getting-data-label>` it is recommended to use ``completeWays=yes``, when manipulating/getting OSM data - this happens also to be the case when using the `OSM Extended API`_ to retrieve data e.g. as part of :ref:`Working in batch mode <chapter-batch-mode>`. The parameters below give the possibility to influence, which data outside of the boundary is processed.
.. _`OSM Extended API`: http://wiki.openstreetmap.org/wiki/Xapi
BOUNDARY_CLIPPING = True
BOUNDARY_CLIPPING_BORDER_SIZE = 0.25
============================================= ======== ======= ==============================================================================
Parameter Type Default Description / Example
============================================= ======== ======= ==============================================================================
BOUNDARY_CLIPPING Boolean True If True the everythin outside the boundary is clipped away. This clipping
includes ways (e.g. roads, buildings), where nodes outside the boundary
are removed.
If both this parameter and ``BOUNDARY_CLIPPING_COMPLETE_WAYS`` are set to
False, then make sure that the ``OSM_FILE`` only contain the necessary data
(which in most situations is recommended).
BOUNDARY_CLIPPING_BORDER_SIZE Decimal 0.25 Additional border in meters to catch OSM data just at the edge. Used together
with ``BOUNDARY_CLIPPING=True``.
BOUNDARY_CLIPPING_COMPLETE_WAYS Boolean False If True it overrides ``BOUNDARY_CLIPPING`` and keeps all those ways, where the
first referenced node is within the boundary as specified by ``BOUNDARY_*``.
This leads to more a graceful handling when different adjacent sceneries are
created (e.g. batch processing), such that e.g. roads not just stop on either
side of the boundary. However this comes with the cost of more needed
processing. Do not use if just one scenery area in one pass is created.
============================================= ======== ======= ==============================================================================
.. _chapter-parameters-roads:
--------------
Linear Objects
--------------
--------------------------------
Linear Objects (Roads, Railways)
--------------------------------
Parameters for roads, railways and related bridges. One of the challenges to show specific textures based on OSM data is to fit the texture such that it drapes ok on top of the scenery. Therefore several parameters relate to enabling proper draping.
......
......@@ -130,7 +130,7 @@ PATH_TO_SCENERY
likely you'll want to use your TerraSync path here.
PATH_TO_OUTPUT
The generated scenery (.stg, .ac, .xml) will be written to this path — specified without triling slash. If empty then the correct location in PATH_TO_SCENERY is used. Note that if you use TerraSync for PATH_TO_SCENERY, you MUST choose a different path here. Otherwise, TerraSync will overwrite the generated scenery. Unless you know what you are doing, there is no reason not to specify a dedicated path here. While not absolutely needed it is good practice to name the output folder the same as ``PREFIX``.
The generated scenery (.stg, .ac, .xml) will be written to this path — specified without trailing slash. If empty then the correct location in PATH_TO_SCENERY is used. Note that if you use TerraSync for PATH_TO_SCENERY, you MUST choose a different path here. Otherwise, TerraSync will overwrite the generated scenery. Unless you know what you are doing, there is no reason not to specify a dedicated path here. While not absolutely needed it is good practice to name the output folder the same as ``PREFIX``.
OSM_FILE
The file containing OpenStreetMap data. See previous chapter :ref:`Getting OpenStreetMap Data <chapter-getting-data-label>`. The file should reside in $PREFIX and no path components are allowed (i.e. pure file name).
BOUNDARY_*
......@@ -168,7 +168,7 @@ Please be aware that the scenery data needed for your area might not have been d
Available Elevation Probing Modes
---------------------------------
There are a few different possibilities to generate elevation data, each of which is discussed in details in subchapters below. This is what is specified in parameter ``ELEV_MODE`` in the ``params.ini`` file:
There are a few different possibilities to generate elevation data, each of which is discussed in details in sub-chapters below. This is what is specified in parameter ``ELEV_MODE`` in the ``params.ini`` file:
* :ref:`ELEV_MODE = "FgelevCaching" <chapter-elev-fgelevcaching-label>`: most automated and convenient
* :ref:`ELEV_MODE = "Fgelev" <chapter-elev-fgelev-label>`: use this instead of ``FgelevCaching`` if you have clear memory or speed limitations
......
......@@ -15,7 +15,7 @@ class ObjectList(object):
Class for storing a List OSM Objects
'''
def __init__(self, transform=None, clusters=None):
def __init__(self, transform=None, clusters=None, boundary_clipping_complete_way=None):
'''
Constructor
'''
......@@ -27,6 +27,7 @@ class ObjectList(object):
self.minlat = 91.
self.maxlat = -91.
self.min_max_scanned = False
self.boundary_clipping_complete_way = boundary_clipping_complete_way
def _process_nodes(self, nodes_dict):
self.nodes_dict = nodes_dict
......
......@@ -282,11 +282,17 @@ def get_extent_global():
return cmin, cmax
def get_clipping_extent():
rect = [(BOUNDARY_WEST-BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_SOUTH-BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_EAST+BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_SOUTH-BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_EAST+BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_NORTH+BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_WEST-BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_NORTH+BOUNDARY_CLIPPING_BORDER_SIZE)]
def get_clipping_extent(use_border=True):
if use_border:
rect = [(BOUNDARY_WEST-BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_SOUTH-BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_EAST+BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_SOUTH-BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_EAST+BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_NORTH+BOUNDARY_CLIPPING_BORDER_SIZE),
(BOUNDARY_WEST-BOUNDARY_CLIPPING_BORDER_SIZE, BOUNDARY_NORTH+BOUNDARY_CLIPPING_BORDER_SIZE)]
else:
rect = [(BOUNDARY_WEST, BOUNDARY_SOUTH),
(BOUNDARY_EAST, BOUNDARY_SOUTH),
(BOUNDARY_EAST, BOUNDARY_NORTH),
(BOUNDARY_WEST, BOUNDARY_NORTH)]
return rect
......
......@@ -63,6 +63,9 @@ class Piers(ObjectList):
req_keys = ['man_made']
valid_keys = ['area']
def __init__(self, transform, clusters, boundary_clipping_complete_way):
ObjectList.__init__(self, transform, clusters, boundary_clipping_complete_way)
def create_from_way(self, way, nodes_dict):
if not self.min_max_scanned:
self._process_nodes(nodes_dict)
......@@ -74,6 +77,11 @@ class Piers(ObjectList):
if col is None:
return
if self.boundary_clipping_complete_way is not None:
first_node = nodes_dict[way.refs[0]]
if not self.boundary_clipping_complete_way.contains(shg.Point(first_node.lon, first_node.lat)):
return
pier = Pier(self.transform, way.osm_id, way.tags, way.refs, nodes_dict)
self.objects.append(pier)
self.clusters.append(pier.anchor, pier)
......@@ -349,11 +357,13 @@ def main():
lmax = vec2d(tools.transform.toLocal(cmax))
clusters = Clusters(lmin, lmax, parameters.TILE_SIZE, parameters.PREFIX)
piers = Piers(transform, clusters)
if parameters.BOUNDARY_CLIPPING:
border = None
boundary_clipping_complete_way = None
if parameters.BOUNDARY_CLIPPING_COMPLETE_WAYS:
boundary_clipping_complete_way = shg.Polygon(parameters.get_clipping_extent(False))
elif parameters.BOUNDARY_CLIPPING:
border = shg.Polygon(parameters.get_clipping_extent())
else:
border = None
piers = Piers(transform, clusters, boundary_clipping_complete_way)
handler = osmparser.OSMContentHandler(valid_node_keys=[], border=border)
source = open(osm_fname)
logging.info("Reading the OSM file might take some time ...")
......
......@@ -55,8 +55,8 @@ class Platforms(ObjectList):
req_keys = ['railway']
valid_keys = ['area', 'layer']
def __init__(self, transform, clusters):
ObjectList.__init__(self, transform, clusters)
def __init__(self, transform, clusters, boundary_clipping_complete_way):
ObjectList.__init__(self, transform, clusters, boundary_clipping_complete_way)
self.logger = logging.getLogger("platforms")
def create_from_way(self, way, nodes_dict):
......@@ -73,6 +73,11 @@ class Platforms(ObjectList):
if 'layer' in way.tags and atoi(way.tags['layer']) < 0:
return
if self.boundary_clipping_complete_way is not None:
first_node = nodes_dict[way.refs[0]]
if not self.boundary_clipping_complete_way.contains(shg.Point(first_node.lon, first_node.lat)):
return
platform = Platform(self.transform, way.osm_id, way.tags, way.refs, nodes_dict)
self.objects.append(platform)
self.clusters.append(platform.anchor, platform)
......@@ -244,11 +249,13 @@ def main():
lmax = vec2d(tools.transform.toLocal(cmax))
clusters = Clusters(lmin, lmax, parameters.TILE_SIZE, parameters.PREFIX)
platforms = Platforms(transform, clusters)
if parameters.BOUNDARY_CLIPPING:
border = None
boundary_clipping_complete_way = None
if parameters.BOUNDARY_CLIPPING_COMPLETE_WAYS:
boundary_clipping_complete_way = shg.Polygon(parameters.get_clipping_extent(False))
elif parameters.BOUNDARY_CLIPPING:
border = shg.Polygon(parameters.get_clipping_extent())
else:
border = None
platforms = Platforms(transform, clusters, boundary_clipping_complete_way)
handler = osmparser.OSMContentHandler(valid_node_keys=[], border=border)
source = open(osm_fname)
logging.info("Reading the OSM file might take some time ...")
......
......@@ -348,8 +348,8 @@ class Roads(objectlist.ObjectList):
VALID_NODE_KEYS = []
REQ_KEYS = ['highway', 'railway']
def __init__(self, transform, elev):
super(Roads, self).__init__(transform)
def __init__(self, transform, elev, boundary_clipping_complete_way):
super(Roads, self).__init__(transform, None, boundary_clipping_complete_way)
self.elev = elev
self.ways_list = list()
self.bridges_list = list()
......@@ -392,6 +392,11 @@ class Roads(objectlist.ObjectList):
if not _is_processed_railway(way):
return
if self.boundary_clipping_complete_way is not None:
first_node = nodes_dict[way.refs[0]]
if not self.boundary_clipping_complete_way.contains(shg.Point(first_node.lon, first_node.lat)):
return
if not self.min_max_scanned:
self._process_nodes(nodes_dict)
......@@ -408,7 +413,9 @@ class Roads(objectlist.ObjectList):
self._cleanup_topology()
self._check_points_on_line_distance()
self._remove_unused_nodes()
self._probe_elev_at_nodes()
logging.debug("before linear " + str(self))
# self._debug_show_h_add("before linear ob")
......@@ -431,9 +438,13 @@ class Roads(objectlist.ObjectList):
self._keep_only_bridges_and_embankments()
self._clusterize()
#roads.cleanup_junctions()
# roads.objects = [roads.objects[0]]
def _remove_unused_nodes(self):
"""Remove all nodes which are not used in ways in order not to do elevation probing in vane."""
used_nodes_dict = dict()
for way in self.ways_list:
for ref in way.refs:
used_nodes_dict[ref] = self.nodes_dict[ref]
self.nodes_dict = used_nodes_dict
def _probe_elev_at_nodes(self):
"""Add elevation info to all nodes.
......@@ -1128,11 +1139,14 @@ def main():
transform = coordinates.Transformation(center_global, hdg=0)
tools.init(transform)
elev = tools.get_interpolator(fake=parameters.NO_ELEV)
roads = Roads(transform, elev)
if parameters.BOUNDARY_CLIPPING:
border = None
boundary_clipping_complete_way = None
if parameters.BOUNDARY_CLIPPING_COMPLETE_WAYS:
boundary_clipping_complete_way = shg.Polygon(parameters.get_clipping_extent(False))
elif parameters.BOUNDARY_CLIPPING:
border = shg.Polygon(parameters.get_clipping_extent())
else:
border = None
roads = Roads(transform, elev, boundary_clipping_complete_way)
handler = osmparser.OSMContentHandler(roads.VALID_NODE_KEYS, border=border)
logging.info("Reading the OSM file might take some time ...")
......
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