Commit a0e68b0d authored by Thomas Albrecht's avatar Thomas Albrecht

max slope per road type

parent 6326af14
......@@ -214,10 +214,11 @@ class LinearObject(object):
# FIXME: when do we need this? if left_z_set is None and right_z_set is None?
h_add_0 = first_node.h_add
h_add_1 = last_node.h_add
dh_dx = max_slope_for_road(self)
if h_add_0 == 0 and h_add_1 > 0:
h_add = np.array([max(0, h_add_1 - (self.dist[-1] - self.dist[i]) * parameters.DH_DX) for i in range(n_nodes)])
h_add = np.array([max(0, h_add_1 - (self.dist[-1] - self.dist[i]) * dh_dx) for i in range(n_nodes)])
elif h_add_0 > 0 and h_add_1 == 0:
h_add = np.array([max(0, h_add_0 - self.dist[i] * parameters.DH_DX) for i in range(n_nodes)])
h_add = np.array([max(0, h_add_0 - self.dist[i] * dh_dx) for i in range(n_nodes)])
else:
h_add = np.array([max(0, h_add_0 + (h_add_1 - h_add_0) * self.dist[i]/self.dist[-1]) for i in range(n_nodes)])
......@@ -469,6 +470,13 @@ class LinearObject(object):
print "error in osm_id", self.osm_id
return True
def max_slope_for_road(obj):
if obj.tags['highway'] in ['motorway']:
return parameters.MAX_SLOPE_HIGHWAY
else:
return parameters.MAX_SLOPE_ROAD
def main():
ac = ac3d.Writer(tools.stats)
......
......@@ -171,7 +171,8 @@ C2P_POWER_LINE_ALLOW_100M = False
#=============================================================================
TRAFFIC_SHADER_ENABLE = False
DH_DX = 0.1
MAX_SLOPE_HIGHWAY = 0.03
MAX_SLOPE_ROAD = 0.08
MAX_TRANSVERSE_GRADIENT = 0.1
def set_parameters(param_dict):
......
......@@ -75,7 +75,7 @@ import math
import calc_tile
import os
import ac3d
from linear import LinearObject
from linear import LinearObject, max_slope_for_road
from linear_bridge import LinearBridge
import logging
......@@ -167,6 +167,7 @@ class Roads(objectlist.ObjectList):
the_node.MSL = self.elev((the_node.lon, the_node.lat), is_global=True)
the_node.h_add = 0.
def propagate_h_add(self):
"""start at bridges, propagate h_add through nodes"""
for the_bridge in self.bridges_list:
......@@ -182,29 +183,29 @@ class Roads(objectlist.ObjectList):
node1 = the_bridge.refs[-1]
self.G.remove_edge(node0, node1)
for ref0, ref1 in nx.bfs_edges(self.G, node0):
obj = self.G[ref0][ref1]['obj']
dh_dx = max_slope_for_road(obj)
n0 = self.nodes_dict[ref0]
n1 = self.nodes_dict[ref1]
if n1.h_add > 0:
break
if label: self.debug_label_node(ref0, n0.h_add)
#n1.h_add = max(0, n0.h_add - obj.center.length * parameters.DH_DX)
n1.h_add = max(0, n0.MSL + n0.h_add - obj.center.length * parameters.DH_DX - n1.MSL)
n1.h_add = max(0, n0.MSL + n0.h_add - obj.center.length * dh_dx - n1.MSL)
if label: self.debug_label_node(ref1, n1.h_add)
if n1.h_add <= 0.:
break
for ref0, ref1 in nx.bfs_edges(self.G, node1):
obj = self.G[ref0][ref1]['obj']
dh_dx = max_slope_for_road(obj)
n0 = self.nodes_dict[ref0]
n1 = self.nodes_dict[ref1]
if n1.h_add > 0:
break
if label: self.debug_label_node(ref0, n0.h_add)
n1.h_add = max(0, n0.MSL + n0.h_add - obj.center.length * parameters.DH_DX - n1.MSL)
n1.h_add = max(0, n0.MSL + n0.h_add - obj.center.length * dh_dx - n1.MSL)
if label: self.debug_label_node(ref1, n1.h_add)
if n1.h_add <= 0.:
break
......
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