Commit f70486de authored by Thomas Albrecht's avatar Thomas Albrecht

moved roads related texture coord tuples to textures/road.py.

Fixed bug on linux
parent cdc4b1dd
......@@ -9,23 +9,12 @@ import math
import copy
import parameters
import logging
import textures.road
# debug
import test
#import warnings
#warnings.filterwarnings('error')
TRACK = (0/8.,1/8.)
ROAD_1 = (1/8.,2/8.)
ROAD_2 = (2/8.,3/8.)
ROAD_3 = (3/8.,4/8.)
EMBANKMENT_1 = (4/8.,5/8.)
EMBANKMENT_2 = (5/8.,6/8.)
TRAMWAY = (6/8.,7/8.)
UNUSED_2 = (7/8.,8/8.)
BOTTOM = (4/8.-0.05,4/8.)
class LinearObject(object):
......@@ -75,7 +64,7 @@ class LinearObject(object):
- if not, write our node and store node indices in junction
- if yes, use stored node indices
"""
def __init__(self, transform, osm_id, tags, refs, nodes_dict, width=9, tex=EMBANKMENT_1, AGL=0.5):
def __init__(self, transform, osm_id, tags, refs, nodes_dict, width=9, tex=textures.road.EMBANKMENT_1, AGL=0.5):
#self.transform = transform
# self.junction0 = None # these are set on create_linear_objects()
# self.junction1 = None
......
......@@ -15,6 +15,7 @@ from pdb import pm
from vec2d import vec2d
import matplotlib.pyplot as plt
import parameters
import textures.road
#from turtle import Vec2D
class Deck_shape_linear(object):
......@@ -48,7 +49,7 @@ class Deck_shape_poly(object):
return self.a0 + self.a1*s + self.a2*s*s
class LinearBridge(linear.LinearObject):
def __init__(self, transform, elev, osm_id, tags, refs, nodes_dict, width=9, tex=linear.EMBANKMENT_2, AGL=0.5):
def __init__(self, transform, elev, osm_id, tags, refs, nodes_dict, width=9, tex=textures.road.EMBANKMENT_2, AGL=0.5):
super(LinearBridge, self).__init__(transform, osm_id, tags, refs, nodes_dict, width, tex, AGL)
# -- prepare elevation spline
# probe elev at n_probes locations
......@@ -210,17 +211,17 @@ class LinearBridge(linear.LinearObject):
obj.node(-(y+node[0]), h0, -(x+node[1]))
for i in range(self.pillar_nnodes-1):
face = [(ofs+i, 0, linear.BOTTOM[0]),
(ofs+i+1, 1, linear.BOTTOM[0]),
(ofs+i+1+self.pillar_nnodes, 1, linear.BOTTOM[1]),
(ofs+i+self.pillar_nnodes, 0, linear.BOTTOM[1])]
face = [(ofs+i, 0, textures.road.BOTTOM[0]),
(ofs+i+1, 1, textures.road.BOTTOM[0]),
(ofs+i+1+self.pillar_nnodes, 1, textures.road.BOTTOM[1]),
(ofs+i+self.pillar_nnodes, 0, textures.road.BOTTOM[1])]
obj.face(face)
i = self.pillar_nnodes - 1
face = [(ofs+i, 0, linear.BOTTOM[0]),
(ofs, 1, linear.BOTTOM[0]),
(ofs+self.pillar_nnodes, 1, linear.BOTTOM[1]),
(ofs+i+self.pillar_nnodes, 0, linear.BOTTOM[1])]
face = [(ofs+i, 0, textures.road.BOTTOM[0]),
(ofs, 1, textures.road.BOTTOM[0]),
(ofs+self.pillar_nnodes, 1, textures.road.BOTTOM[1]),
(ofs+i+self.pillar_nnodes, 0, textures.road.BOTTOM[1])]
obj.face(face)
nodes_list.append(face)
......@@ -268,7 +269,7 @@ class LinearBridge(linear.LinearObject):
self.write_quads(obj, left_bottom_nodes, left_top_nodes, parameters.EMBANKMENT_TEXTURE[0], parameters.EMBANKMENT_TEXTURE[1], debug_ac=None)
# -- bottom
self.write_quads(obj, right_bottom_nodes, left_bottom_nodes, linear.BOTTOM[0], linear.BOTTOM[1], debug_ac=None)
self.write_quads(obj, right_bottom_nodes, left_bottom_nodes, textures.road.BOTTOM[0], textures.road.BOTTOM[1], debug_ac=None)
# -- end wall 1
the_node = self.edge[0].coords[0]
......
......@@ -21,7 +21,7 @@ from vec2d import vec2d
from pdb import pm
import logging
import traceback
from linear import EMBANKMENT_1
import textures.road
# default_args_start # DO NOT MODIFY THIS LINE
# -*- coding: utf-8 -*-
......@@ -274,7 +274,7 @@ CREATE_BRIDGES_ONLY = 0 # create only bridges and embankments
# default_args_end # DO NOT MODIFY THIS LINE
BRIDGE_LAYER_HEIGHT = 4. # bridge height per layer
BRIDGE_BODY_HEIGHT = 0.9 # height of bridge body
EMBANKMENT_TEXTURE = EMBANKMENT_1 # Texture for the embankement
EMBANKMENT_TEXTURE = textures.road.EMBANKMENT_1 # Texture for the embankement
quiet = False
def get_OSM_file_name():
......
......@@ -89,7 +89,7 @@ import coordinates
import tools
import parameters
import ac3d
from linear import LinearObject, max_slope_for_road, ROAD_1, ROAD_2, ROAD_3, TRACK
import linear
import shapely.geometry as shg
import logging
......@@ -107,7 +107,8 @@ import troubleshoot
import test
from pdb import pm
import math
from linear_bridge import LinearBridge
import linear_bridge
import textures.road
#from memory_profiler import profile
OUR_MAGIC = "osm2roads" # Used in e.g. stg files to mark our edits
......@@ -207,7 +208,7 @@ class Roads(objectlist.ObjectList):
def propagate_h_add_over_edge(self, ref0, ref1, args):
"""propagate h_add over edges of graph"""
obj = self.G[ref0][ref1]['obj']
dh_dx = max_slope_for_road(obj)
dh_dx = linear.max_slope_for_road(obj)
n0 = self.nodes_dict[ref0]
n1 = self.nodes_dict[ref1]
if n1.h_add > 0:
......@@ -362,7 +363,7 @@ class Roads(objectlist.ObjectList):
access = 'yes'
width = 9
tex = ROAD_2
tex = textures.road.ROAD_2
AGL_ofs = random.uniform(0.01, 0.1)
#AGL_ofs = 0.0
#if way.tags.has_key('layer'):
......@@ -375,11 +376,11 @@ class Roads(objectlist.ObjectList):
if the_way.tags['railway'] in ['rail']:
prio = 6
width = 2.87
tex = TRACK
tex = textures.road.TRACK
elif the_way.tags['railway'] in ['tram']:
prio = 6
width = 2.87
tex = TRAMWAY
tex = textures.road.TRAMWAY
# TA: disabled parking for now. While certainly good to have,
# parking in OSM is not a linear feature in general.
# We'd need to add areas.
......@@ -388,7 +389,7 @@ class Roads(objectlist.ObjectList):
# prio = 7
if prio in [1, 2]:
tex = ROAD_1
tex = textures.road.ROAD_1
width=6
if prio == 0 or prio == None:
......@@ -400,11 +401,11 @@ class Roads(objectlist.ObjectList):
try:
if is_bridge(the_way):
obj = LinearBridge(self.transform, self.elev, the_way.osm_id, the_way.tags, the_way.refs, self.nodes_dict, width=width, tex=tex, AGL=0.01+0.005*prio+AGL_ofs)
obj = linear_bridge.LinearBridge(self.transform, self.elev, the_way.osm_id, the_way.tags, the_way.refs, self.nodes_dict, width=width, tex=tex, AGL=0.01+0.005*prio+AGL_ofs)
obj.typ = prio
self.bridges_list.append(obj)
else:
obj = LinearObject(self.transform, the_way.osm_id, the_way.tags, the_way.refs, self.nodes_dict, width=width, tex=tex, AGL=0.01+0.005*prio+AGL_ofs)
obj = linear.LinearObject(self.transform, the_way.osm_id, the_way.tags, the_way.refs, self.nodes_dict, width=width, tex=tex, AGL=0.01+0.005*prio+AGL_ofs)
obj.typ = prio
self.roads_list.append(obj)
except ValueError, reason:
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# road texture coordinates
TRACK = (0/8.,1/8.)
ROAD_1 = (1/8.,2/8.)
ROAD_2 = (2/8.,3/8.)
ROAD_3 = (3/8.,4/8.)
EMBANKMENT_1 = (4/8.,5/8.)
EMBANKMENT_2 = (5/8.,6/8.)
TRAMWAY = (6/8.,7/8.)
UNUSED_2 = (7/8.,8/8.)
BOTTOM = (4/8.-0.05,4/8.)
......@@ -2,6 +2,8 @@ import numpy as np
from PIL import Image
import logging
class Texture(object):
"""
possible texture types:
......
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