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

Reenabled railways in roads.py and introduced two new parameters:...

Reenabled railways in roads.py and introduced two new parameters: POINTS_ON_LINE_DISTANCE_MAX and HIGHWAY_TYPE_MIN
parent 8645dad8
No preview for this file type
......@@ -111,6 +111,60 @@ LOD_PERCENTAGE_DETAIL Decimal 0.5 Of the rema
============================================= ======== ======= ==============================================================================
.. _chapter-parameters-roads:
--------------
Linear Objects
--------------
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.
============================================= ======== ======= ==============================================================================
Parameter Type Default Description / Example
============================================= ======== ======= ==============================================================================
TRAFFIC_SHADER_ENABLE Boolean False If True then the traffic shader gets enabled, otherwise the lightmap shader.
These effects are only for roads, not railways.
BRIDGE_MIN_LENGTH Decimal 20. Discard short bridges and draw roads or railways instead.
MIN_ABOVE_GROUND_LEVEL Decimal 0.01 How much a highway / railway is at least hovering above ground
HIGHWAY_TYPE_MIN Integer 5 The lower the number, the smaller ways in the highway hierarchy are added.
Currently the numbers are as follows (see roads.py -> HighwayType).
motorway = 12
trunk = 11
primary = 10
secondary = 9
tertiary = 8
unclassified = 7
road = 6
residential = 5
living_street = 4
service = 3
pedestrian = 2
slow = 1 (cycle ways, tracks, footpaths etc).
POINTS_ON_LINE_DISTANCE_MAX Integer 1000 The maximum distance between two points on a line. If longer, then new points
are added. This parameter might need to get set to a smaller value in order to
have enough elevation probing along a road/highway. Together with parameter
MIN_ABOVE_GROUND_LEVEL it makes sure that fewer residuals of ways are below
the scenery ground. The more uneven a scenery ground is, the smaller this
value should be chosen. The drawback of small values are that the number
of faces gets bigger affecting frame rates.
============================================= ======== ======= ==============================================================================
.. MAX_SLOPE_RAILWAY = 0.04
MAX_SLOPE_MOTORWAY = 0.03 # max slope for motorways
MAX_SLOPE_ROAD = 0.08
MAX_TRANSVERSE_GRADIENT = 0.1 #
BRIDGE_MIN_LENGTH = 20. # discard short bridges, draw road instead
DEBUG_PLOT = 0
CREATE_BRIDGES_ONLY = 0 # create only bridges and embankments
BRIDGE_LAYER_HEIGHT = 4. # bridge height per layer
BRIDGE_BODY_HEIGHT = 0.9 # height of bridge body
EMBANKMENT_TEXTURE = textures.road.EMBANKMENT_1 # Texture for the embankment
.. [#] The only exception to the rule is the possibility to adjust the :ref:`Actual Distance of LOD Ranges <chapter-lod-label>`.
......@@ -5,7 +5,7 @@
graph support stuff
"""
import networkx as nx
from pdb import pm
def for_edges_in_bfs_call(func, args, G, node0_set, visited_set):
"""Start at nodes in node0_set. Breadth-first search, excluding nodes
......@@ -36,6 +36,7 @@ class Stub(object):
self.is_first = is_first
self.joint_nodes = joint_nodes
class Junction(object):
"""store attached ways, joint_node indices
current usage of attached_ways_dict:
......@@ -54,7 +55,7 @@ class Junction(object):
def __init__(self, way, is_first, joint_nodes=[]):
self._attached_ways = [way]
self._is_first = [is_first]
self.joint_nodes = joint_nodes # list of tuples -- unused?
self.joint_nodes = joint_nodes # list of tuples -- unused?
self.reset()
def reset(self):
......@@ -71,18 +72,18 @@ class Junction(object):
def _use_left_node(self, way, is_left):
i = self._attached_ways.index(way)
assert(i==0 or i==1)
assert(i == 0 or i == 1)
return (i + self._is_first[i] + is_left) % 2 == 0
def get_other_node(self, way, is_left, cluster_ref):
if self._cluster_ref != cluster_ref:
raise KeyError
if self._use_left_node(way, is_left):
if self._left_node == None:
if self._left_node is None:
raise KeyError
return self._left_node
else:
if self._right_node == None:
if self._right_node is None:
raise KeyError
return self._right_node
......@@ -98,9 +99,9 @@ class Junction(object):
raise ValueError("other node already set")
self._right_node = node
class Graph(nx.Graph):
"""Inherit from nx.Graph, make accessing graph node attribute (Junction) easier"""
#def __init__(self, graph):
def junction(self, the_ref):
"""return object attached to node"""
return self.node[the_ref]['obj']
......@@ -137,7 +138,7 @@ class Graph(nx.Graph):
if __name__ == "__main__":
import osm
G=Graph()
G = Graph()
junction1 = 'j1'
junction2 = 'j2'
......@@ -148,7 +149,7 @@ if __name__ == "__main__":
#G.add_node(3, "hj")
G.add_edge(osm.Way(1, [], [1, 2]))
G.add_edge(osm.Way(2, [], [4, 3]))
bla
print "aa", G.node["a"]['obj']
print "cur"
print G["a"]
......@@ -158,4 +159,3 @@ if __name__ == "__main__":
for the_node in G.nodes(data=True):
print the_node[0], " --",
print the_node[1]['obj']
\ No newline at end of file
......@@ -30,6 +30,7 @@ import xml.sax
import coordinates
import osmparser
import parameters
import roads
import stg_io2
import tools
import vec2d
......@@ -1282,36 +1283,14 @@ class LinearOSMFeature(object):
class Highway(LinearOSMFeature):
TYPE_MOTORWAY = 11
TYPE_TRUNK = 12
TYPE_PRIMARY = 13
TYPE_SECONDARY = 14
TYPE_TERTIARY = 15
TYPE_UNCLASSIFIED = 16
TYPE_ROAD = 17
TYPE_RESIDENTIAL = 18
TYPE_LIVING_STREET = 19
TYPE_SERVICE = 20
TYPE_PEDESTRIAN = 21
TYPE_SLOW = 30 # cycle ways, tracks, footpaths etc
def __init__(self, osm_id):
super(Highway, self).__init__(osm_id)
self.is_roundabout = False
def get_width(self): # FIXME: replace with parameters and a bit of logic including number of lanes
if self.type_ in [Highway.TYPE_SERVICE, Highway.TYPE_RESIDENTIAL, Highway.TYPE_LIVING_STREET
, Highway.TYPE_PEDESTRIAN]:
my_width = 5.0
elif self.type_ in [Highway.TYPE_ROAD, Highway.TYPE_UNCLASSIFIED, Highway.TYPE_TERTIARY]:
my_width = 6.0
elif self.type_ in [Highway.TYPE_SECONDARY, Highway.TYPE_PRIMARY, Highway.TYPE_TRUNK]:
my_width = 7.0
elif self.type_ is Highway.TYPE_MOTORWAY:
my_width = 14.0
else: # TYPE_SLOW
my_width = 3.0
return my_width
def get_width(self):
highway_attributes = roads.get_highway_attributes(self.type_)
return highway_attributes[2]
def process_osm_highway(nodes_dict, ways_dict, my_coord_transformator):
......@@ -1325,31 +1304,8 @@ def process_osm_highway(nodes_dict, ways_dict, my_coord_transformator):
value = way.tags[key]
if "highway" == key:
valid_highway = True
if value in ["motorway", "motorway_link"]:
my_highway.type_ = Highway.TYPE_MOTORWAY
elif value in ["trunk", "trunk_link"]:
my_highway.type_ = Highway.TYPE_TRUNK
elif value in ["primary", "primary_link"]:
my_highway.type_ = Highway.TYPE_PRIMARY
elif value in ["secondary", "secondary_link"]:
my_highway.type_ = Highway.TYPE_SECONDARY
elif value in ["tertiary", "tertiary_link"]:
my_highway.type_ = Highway.TYPE_TERTIARY
elif value == "unclassified":
my_highway.type_ = Highway.TYPE_UNCLASSIFIED
elif value == "road":
my_highway.type_ = Highway.TYPE_ROAD
elif value == "residential":
my_highway.type_ = Highway.TYPE_RESIDENTIAL
elif value == "living_street":
my_highway.type_ = Highway.TYPE_LIVING_STREET
elif value == "service":
my_highway.type_ = Highway.TYPE_SERVICE
elif value == "pedestrian":
my_highway.type_ = Highway.TYPE_PEDESTRIAN
elif value in ["tack", "footway", "cycleway", "bridleway", "steps", "path"]:
my_highway.type_ = Highway.TYPE_SLOW
else:
my_highway.type_ = roads.highway_type_from_osm_tags(key, value)
if None is my_highway.type_:
valid_highway = False
elif ("tunnel" == key) and ("yes" == value):
is_challenged = True
......
......@@ -73,6 +73,8 @@ ELEV_RASTER_Y = 10
TELNET_PORT = 5501 # The port FlightGear listens to. Needed for ELEV_MODE = "Telnet"
quiet = False
#=============================================================================
# PARAMETERS RELATED TO BUILDINGS IN osm2city
#=============================================================================
......@@ -241,7 +243,9 @@ CREATE_BRIDGES_ONLY = 0 # create only bridges and embankments
BRIDGE_LAYER_HEIGHT = 4. # bridge height per layer
BRIDGE_BODY_HEIGHT = 0.9 # height of bridge body
EMBANKMENT_TEXTURE = textures.road.EMBANKMENT_1 # Texture for the embankment
quiet = False
MIN_ABOVE_GROUND_LEVEL = 0.01 # how much a highway / railway is at least hovering above ground
HIGHWAY_TYPE_MIN = 4 # The lower the number, the more ways are added. See roads.HighwayType
POINTS_ON_LINE_DISTANCE_MAX = 1000 # the maximum distance between two points on a line. If longer, then new points are added
# default_args_end # DO NOT MODIFY THIS LINE
......
This diff is collapsed.
......@@ -2,15 +2,15 @@
# -*- coding: utf-8 -*-
# road texture coordinates
TRACK = (0/8.,1/8.)
ROAD_1 = (1/8.,2/8.)
ROAD_2 = (2/8.,3/8.)
BRIDGE_1 = (3/8.,4/8.)
EMBANKMENT_1 = (4/8.,5/8.)
EMBANKMENT_2 = (6/8.,6/8.)
ROAD_3 = (5/8.,6/8.)
TRAMWAY = (7/8.,8/8.)
TRACK = (0/8., 1/8.)
ROAD_1 = (1/8., 2/8.)
ROAD_2 = (2/8., 3/8.)
BRIDGE_1 = (3/8., 4/8.)
EMBANKMENT_1 = (4/8., 5/8.)
EMBANKMENT_2 = (6/8., 6/8.)
ROAD_3 = (5/8., 6/8.)
TRAMWAY = (7/8., 8/8.)
#UNUSED_2 = (7/8.,8/8.)
BOTTOM = (4/8.-0.05,4/8.)
BOTTOM = (4/8.-0.05, 4/8.)
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