mirror of
https://github.com/enzet/map-machine.git
synced 2025-08-06 10:09:52 +02:00
3D buildings.
This commit is contained in:
parent
f73368e9ba
commit
5c8a49555f
1 changed files with 52 additions and 11 deletions
|
@ -27,11 +27,11 @@ sys.path.append('../lib')
|
||||||
import svg
|
import svg
|
||||||
from vector import Vector
|
from vector import Vector
|
||||||
|
|
||||||
background_color = 'DDDDDD' # 'DDDDDD'
|
background_color = 'EEEEEE' # 'DDDDDD'
|
||||||
outline_color = 'FFFFFF'
|
outline_color = 'FFFFFF'
|
||||||
beach_color = 'F0E0C0'
|
beach_color = 'F0E0C0'
|
||||||
building_color = 'EEEEEE' # 'D0D0C0'
|
building_color = 'EEEEEE' # 'D0D0C0'
|
||||||
building_border_color = 'C4C4C4' # 'AAAAAA'
|
building_border_color = 'DDDDDD' # 'AAAAAA'
|
||||||
construction_color = 'CCCCCC'
|
construction_color = 'CCCCCC'
|
||||||
cycle_color = '4444EE'
|
cycle_color = '4444EE'
|
||||||
desert_color = 'F0E0D0'
|
desert_color = 'F0E0D0'
|
||||||
|
@ -526,6 +526,9 @@ def construct_way(drawing, nodes, tags, path, user, time):
|
||||||
style = 'fill:none;stroke:none;'
|
style = 'fill:none;stroke:none;'
|
||||||
text_y = 0
|
text_y = 0
|
||||||
layer += 40
|
layer += 40
|
||||||
|
levels = 1
|
||||||
|
if 'building:levels' in tags:
|
||||||
|
levels = float(tags['building:levels'])
|
||||||
style = 'fill:#' + building_color + ';stroke:#' + \
|
style = 'fill:#' + building_color + ';stroke:#' + \
|
||||||
building_border_color + ';opacity:1.0;'
|
building_border_color + ';opacity:1.0;'
|
||||||
shapes, fill, processed = process.get_icon(tags, scheme, '444444')
|
shapes, fill, processed = process.get_icon(tags, scheme, '444444')
|
||||||
|
@ -535,8 +538,9 @@ def construct_way(drawing, nodes, tags, path, user, time):
|
||||||
drawing['nodes'].append({'shapes': shapes, 'x': c.x, 'y': c.y,
|
drawing['nodes'].append({'shapes': shapes, 'x': c.x, 'y': c.y,
|
||||||
'color': fill, 'priority': 1, 'processed': processed,
|
'color': fill, 'priority': 1, 'processed': processed,
|
||||||
'tags': tags, 'path': path})
|
'tags': tags, 'path': path})
|
||||||
drawing['ways'].append({'kind': 'way', 'nodes': nodes, 'layer': layer,
|
drawing['ways'].append({'kind': 'building', 'nodes': nodes,
|
||||||
'priority': 50, 'style': style, 'path': path})
|
'layer': layer, 'priority': 50, 'style': style, 'path': path,
|
||||||
|
'levels': levels})
|
||||||
|
|
||||||
# Amenity
|
# Amenity
|
||||||
|
|
||||||
|
@ -981,13 +985,50 @@ def node_sorter(element):
|
||||||
def draw(drawing, show_missed_tags=False, overlap=14, draw=True):
|
def draw(drawing, show_missed_tags=False, overlap=14, draw=True):
|
||||||
ways = sorted(drawing['ways'], key=way_sorter)
|
ways = sorted(drawing['ways'], key=way_sorter)
|
||||||
for way in ways:
|
for way in ways:
|
||||||
if way['nodes']:
|
if way['kind'] == 'way':
|
||||||
path = get_path(way['nodes'])
|
if way['nodes']:
|
||||||
output_file.write('<path d="' + path + '" ' + \
|
path = get_path(way['nodes'])
|
||||||
'style="' + way['style'] + '" />\n')
|
output_file.write('<path d="' + path + '" ' + \
|
||||||
else:
|
'style="' + way['style'] + '" />\n')
|
||||||
output_file.write('<path d="' + way['path'] + '" ' + \
|
else:
|
||||||
'style="' + way['style'] + '" />\n')
|
output_file.write('<path d="' + way['path'] + '" ' + \
|
||||||
|
'style="' + way['style'] + '" />\n')
|
||||||
|
output_file.write('<g style="opacity:0.1;">\n')
|
||||||
|
for way in ways:
|
||||||
|
if way['kind'] == 'building':
|
||||||
|
if way['nodes']:
|
||||||
|
shift = Vector(-5, 5)
|
||||||
|
if 'levels' in way:
|
||||||
|
shift = Vector(-5 * way['levels'], 5 * way['levels'])
|
||||||
|
for i in range(len(way['nodes']) - 1):
|
||||||
|
node_1 = node_map[way['nodes'][i]]
|
||||||
|
node_2 = node_map[way['nodes'][i + 1]]
|
||||||
|
flinged_1 = flinger.fling(Geo(node_1['lat'], node_1['lon']))
|
||||||
|
flinged_2 = flinger.fling(Geo(node_2['lat'], node_2['lon']))
|
||||||
|
output_file.write('<path d="M ' + `flinged_1.x` + ',' + `flinged_1.y` + ' L ' + `flinged_2.x` + ',' + `flinged_2.y` + ' ' + `(flinged_2 + shift).x` + ',' + `(flinged_2 + shift).y` + ' ' + `(flinged_1 + shift).x` + ',' + `(flinged_1 + shift).y` + ' Z" style="fill:#000000;stroke:#000000;stroke-width:1;" />\n')
|
||||||
|
output_file.write('</g>\n')
|
||||||
|
for way in ways:
|
||||||
|
if way['kind'] == 'building':
|
||||||
|
if way['nodes']:
|
||||||
|
shift = Vector(0, -0.5)
|
||||||
|
if 'levels' in way:
|
||||||
|
shift = Vector(0 * way['levels'], -0.5 * way['levels'])
|
||||||
|
for i in range(len(way['nodes']) - 1):
|
||||||
|
node_1 = node_map[way['nodes'][i]]
|
||||||
|
node_2 = node_map[way['nodes'][i + 1]]
|
||||||
|
flinged_1 = flinger.fling(Geo(node_1['lat'], node_1['lon']))
|
||||||
|
flinged_2 = flinger.fling(Geo(node_2['lat'], node_2['lon']))
|
||||||
|
output_file.write('<path d="M ' + `flinged_1.x` + ',' + `flinged_1.y` + ' L ' + `flinged_2.x` + ',' + `flinged_2.y` + ' ' + `(flinged_2 + shift).x` + ',' + `(flinged_2 + shift).y` + ' ' + `(flinged_1 + shift).x` + ',' + `(flinged_1 + shift).y` + ' Z" style="fill:#DDDDDD;stroke:#DDDDDD;stroke-width:1;opacity:1;" />\n')
|
||||||
|
for way in ways:
|
||||||
|
if way['kind'] == 'building':
|
||||||
|
if way['nodes']:
|
||||||
|
shift = Vector(0, -0.5)
|
||||||
|
if 'levels' in way:
|
||||||
|
shift = Vector(0 * way['levels'], -0.5 * way['levels'])
|
||||||
|
# shift = Vector()
|
||||||
|
path = get_path(way['nodes'], shift=shift)
|
||||||
|
output_file.write('<path d="' + path + '" ' + \
|
||||||
|
'style="' + way['style'] + ';opacity:1;" />\n')
|
||||||
nodes = sorted(drawing['nodes'], key=node_sorter)
|
nodes = sorted(drawing['nodes'], key=node_sorter)
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
draw_shapes(node['shapes'], overlap, points, node['x'], node['y'],
|
draw_shapes(node['shapes'], overlap, points, node['x'], node['y'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue