mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-10 15:46:51 +02:00
More tags and icons.
This commit is contained in:
parent
efe3fcfba8
commit
4c01cded68
3 changed files with 1112 additions and 205 deletions
929
icons.svg
929
icons.svg
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 83 KiB |
384
mapper.py
384
mapper.py
|
@ -41,7 +41,7 @@ output_file = svg.SVG(open(sys.argv[2], 'w+'))
|
||||||
|
|
||||||
w, h = 2000, 2000
|
w, h = 2000, 2000
|
||||||
|
|
||||||
background_color = '000000' # 'EEEEEE'
|
background_color = 'EEEEEE'
|
||||||
grass_color = 'C8DC94'
|
grass_color = 'C8DC94'
|
||||||
sand_color = 'F0E0D0'
|
sand_color = 'F0E0D0'
|
||||||
beach_color = 'F0E0C0'
|
beach_color = 'F0E0C0'
|
||||||
|
@ -54,11 +54,17 @@ wood_color = 'B8CC84'
|
||||||
|
|
||||||
tags_to_write = ['operator', 'opening_hours', 'cuisine', 'network', 'website',
|
tags_to_write = ['operator', 'opening_hours', 'cuisine', 'network', 'website',
|
||||||
'phone', 'branch', 'route_ref', 'brand', 'ref', 'wikipedia',
|
'phone', 'branch', 'route_ref', 'brand', 'ref', 'wikipedia',
|
||||||
'description', 'level', 'wikidata', 'name']
|
'description', 'level', 'wikidata', 'name', 'alt_name',
|
||||||
|
'image', 'fax', 'old_name', 'artist_name', 'int_name',
|
||||||
|
'official_name', 'full_name', 'email', 'designation']
|
||||||
|
|
||||||
prefix_to_write = ['addr', 'contact', 'name', 'operator', 'wikipedia']
|
prefix_to_write = ['addr', 'contact', 'name', 'operator', 'wikipedia',
|
||||||
|
'alt_name', 'description', 'old_name', 'inscription',
|
||||||
|
'route_ref', 'is_in', 'website']
|
||||||
|
|
||||||
tags_to_skip = ['note', 'layer']
|
tags_to_skip = ['note', 'layer', 'source', 'building:part', 'fixme', 'comment']
|
||||||
|
|
||||||
|
prefix_to_skip = ['source']
|
||||||
|
|
||||||
output_file.begin(w, h)
|
output_file.begin(w, h)
|
||||||
output_file.rect(0, 0, w, h, color=background_color)
|
output_file.rect(0, 0, w, h, color=background_color)
|
||||||
|
@ -147,16 +153,23 @@ def draw_path(nodes, style, shift=Vector()):
|
||||||
def draw_point_shape(name, x, y, fill):
|
def draw_point_shape(name, x, y, fill):
|
||||||
if not isinstance(name, list):
|
if not isinstance(name, list):
|
||||||
name = [name]
|
name = [name]
|
||||||
|
for one_name in name:
|
||||||
|
shape, xx, yy = get_d_from_file(one_name)
|
||||||
|
draw_point_outline(shape, x, y, fill, size=16, xx=xx, yy=yy)
|
||||||
for one_name in name:
|
for one_name in name:
|
||||||
shape, xx, yy = get_d_from_file(one_name)
|
shape, xx, yy = get_d_from_file(one_name)
|
||||||
draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy)
|
draw_point(shape, x, y, fill, size=16, xx=xx, yy=yy)
|
||||||
|
|
||||||
def draw_point(shape, x, y, fill, size=16, xx=0, yy=0):
|
def draw_point_outline(shape, x, y, fill, size=16, xx=0, yy=0):
|
||||||
x = int(float(x))
|
x = int(float(x))
|
||||||
y = int(float(y))
|
y = int(float(y))
|
||||||
output_file.write('<path d="' + shape + \
|
output_file.write('<path d="' + shape + \
|
||||||
'" style="fill:#FFFFFF;opacity:0.5;stroke:#FFFFFF;stroke-width:3;stroke-linejoin:round;" transform="translate(' + \
|
'" style="fill:#FFFFFF;opacity:0.5;stroke:#FFFFFF;stroke-width:3;stroke-linejoin:round;" transform="translate(' + \
|
||||||
str(x - size / 2.0 - xx * 16) + ',' + str(y - size / 2.0 - yy * 16) + ')" />\n')
|
str(x - size / 2.0 - xx * 16) + ',' + str(y - size / 2.0 - yy * 16) + ')" />\n')
|
||||||
|
|
||||||
|
def draw_point(shape, x, y, fill, size=16, xx=0, yy=0):
|
||||||
|
x = int(float(x))
|
||||||
|
y = int(float(y))
|
||||||
output_file.write('<path d="' + shape + \
|
output_file.write('<path d="' + shape + \
|
||||||
'" style="fill:#' + fill + ';fill-opacity:1" transform="translate(' + \
|
'" style="fill:#' + fill + ';fill-opacity:1" transform="translate(' + \
|
||||||
str(x - size / 2.0 - xx * 16) + ',' + str(y - size / 2.0 - yy * 16) + ')" />\n')
|
str(x - size / 2.0 - xx * 16) + ',' + str(y - size / 2.0 - yy * 16) + ')" />\n')
|
||||||
|
@ -168,10 +181,9 @@ def draw_text(text, x, y, fill):
|
||||||
if text[:7] == 'http://' or text[:8] == 'https://':
|
if text[:7] == 'http://' or text[:8] == 'https://':
|
||||||
text = 'link'
|
text = 'link'
|
||||||
fill = '0000FF'
|
fill = '0000FF'
|
||||||
return
|
output_file.write('<text x="' + str(x) + '" y="' + str(y) + \
|
||||||
output_file.write('<text x="' + x + '" y="' + y + \
|
|
||||||
'" style="font-size:10;text-anchor:middle;font-family:Myriad Pro;fill:#FFFFFF;stroke-linejoin:round;stroke-width:5;stroke:#FFFFFF;opacity:0.5;">' + text + '</text>')
|
'" style="font-size:10;text-anchor:middle;font-family:Myriad Pro;fill:#FFFFFF;stroke-linejoin:round;stroke-width:5;stroke:#FFFFFF;opacity:0.5;">' + text + '</text>')
|
||||||
output_file.write('<text x="' + x + '" y="' + y + \
|
output_file.write('<text x="' + str(x) + '" y="' + str(y) + \
|
||||||
'" style="font-size:10;text-anchor:middle;font-family:Myriad Pro;fill:#' + fill + ';">' + text + '</text>')
|
'" style="font-size:10;text-anchor:middle;font-family:Myriad Pro;fill:#' + fill + ';">' + text + '</text>')
|
||||||
|
|
||||||
def point(k, v, x, y, fill, text_y):
|
def point(k, v, x, y, fill, text_y):
|
||||||
|
@ -179,12 +191,10 @@ def point(k, v, x, y, fill, text_y):
|
||||||
missed_tags['node ' + k + ': ' + v] += 1
|
missed_tags['node ' + k + ': ' + v] += 1
|
||||||
else:
|
else:
|
||||||
missed_tags['node ' + k + ': ' + v] = 1
|
missed_tags['node ' + k + ': ' + v] = 1
|
||||||
#output_file.circle(float(x), float(y), 2, fill=fill, color=fill)
|
|
||||||
text = k + ': ' + v
|
text = k + ': ' + v
|
||||||
if type(text) == unicode:
|
if type(text) == unicode:
|
||||||
text = text.encode('utf-8')
|
text = text.encode('utf-8')
|
||||||
output_file.write('<text x="' + str(x) + '" y="' + str(int(float(y)) + text_y + 10) + \
|
draw_text(text, x, float(y) + text_y + 18, '734A08')
|
||||||
'" style="font-size:10;text-anchor:middle;font-family:Myriad Pro;fill:#FF0000;">' + text + '</text>')
|
|
||||||
|
|
||||||
# Ways drawing
|
# Ways drawing
|
||||||
|
|
||||||
|
@ -201,7 +211,7 @@ def construct_layers():
|
||||||
if not (int(way['tags']['layer']) in layers):
|
if not (int(way['tags']['layer']) in layers):
|
||||||
layers[int(way['tags']['layer'])] = \
|
layers[int(way['tags']['layer'])] = \
|
||||||
{'b': [], 'h1': [], 'h2': [], 'r': [], 'n': [], 'l': [],
|
{'b': [], 'h1': [], 'h2': [], 'r': [], 'n': [], 'l': [],
|
||||||
'a': [], 'le': [], 'ba': [], 'bo': []}
|
'a': [], 'le': [], 'ba': [], 'bo': [], 'w': []}
|
||||||
layer = layers[int(way['tags']['layer'])]
|
layer = layers[int(way['tags']['layer'])]
|
||||||
if 'building' in way['tags']:
|
if 'building' in way['tags']:
|
||||||
layer['b'].append(way)
|
layer['b'].append(way)
|
||||||
|
@ -222,6 +232,8 @@ def construct_layers():
|
||||||
layer['h2'].append(way)
|
layer['h2'].append(way)
|
||||||
if 'boundary' in way['tags']:
|
if 'boundary' in way['tags']:
|
||||||
layer['bo'].append(way)
|
layer['bo'].append(way)
|
||||||
|
if 'waterway' in way['tags']:
|
||||||
|
layer['w'].append(way)
|
||||||
#else:
|
#else:
|
||||||
# empty = True
|
# empty = True
|
||||||
# for key in way['tags'].keys():
|
# for key in way['tags'].keys():
|
||||||
|
@ -289,10 +301,10 @@ def draw_ways():
|
||||||
else:
|
else:
|
||||||
style = 'fill:#0000FF;stroke:none;'
|
style = 'fill:#0000FF;stroke:none;'
|
||||||
draw_path(way['nodes'], style)
|
draw_path(way['nodes'], style)
|
||||||
for tag in way['tags']:
|
#for tag in way['tags']:
|
||||||
if not (tag in ['landuse', 'layer']):
|
# if not (tag in ['landuse', 'layer']):
|
||||||
point(tag, str(way['tags'][tag]), c.x, c.y, '000000', text_y)
|
# point(tag, str(way['tags'][tag]), c.x, c.y, '000000', text_y)
|
||||||
text_y += 10
|
# text_y += 10
|
||||||
for way in layer['a']:
|
for way in layer['a']:
|
||||||
c = line_center(way['nodes'])
|
c = line_center(way['nodes'])
|
||||||
if way['tags']['amenity'] == 'parking':
|
if way['tags']['amenity'] == 'parking':
|
||||||
|
@ -322,6 +334,12 @@ def draw_ways():
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
draw_path(way['nodes'], style)
|
draw_path(way['nodes'], style)
|
||||||
|
for way in layer['w']:
|
||||||
|
if way['tags']['waterway'] == 'riverbank':
|
||||||
|
style = 'fill:#' + water_color + ';stroke:#' + water_border_color + ';stroke-width:1.0;'
|
||||||
|
elif way['tags']['waterway'] == 'river':
|
||||||
|
style = 'fill:none;stroke:#' + water_color + ';stroke-width:10.0;'
|
||||||
|
draw_path(way['nodes'], style)
|
||||||
for way in layer['r']:
|
for way in layer['r']:
|
||||||
v = way['tags']['railway']
|
v = way['tags']['railway']
|
||||||
style = 'fill:none;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:round;stroke-width:'
|
style = 'fill:none;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:round;stroke-width:'
|
||||||
|
@ -348,7 +366,7 @@ def draw_ways():
|
||||||
elif v == 'service': style += '7'
|
elif v == 'service': style += '7'
|
||||||
elif v == 'track': style += '3'
|
elif v == 'track': style += '3'
|
||||||
elif v in ['footway', 'pedestrian']: style += '2'
|
elif v in ['footway', 'pedestrian']: style += '2'
|
||||||
elif v == 'steps': style += '5;stroke-dasharray:1,2;stroke-linecap:round'
|
elif v == 'steps': style += '5;stroke-dasharray:1,2;stroke-linecap:butt'
|
||||||
elif v == 'path': style += '1;stroke-dasharray:5,5;stroke-linecap:round'
|
elif v == 'path': style += '1;stroke-dasharray:5,5;stroke-linecap:round'
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
@ -401,18 +419,18 @@ def draw_ways():
|
||||||
draw_point_shape('shop_gift', c.x, c.y, '444444')
|
draw_point_shape('shop_gift', c.x, c.y, '444444')
|
||||||
elif tag == 'power':
|
elif tag == 'power':
|
||||||
draw_point_shape('electricity', c.x, c.y, '444444')
|
draw_point_shape('electricity', c.x, c.y, '444444')
|
||||||
elif tag in ['name', 'addr:housenumber', 'cladr:code',
|
#elif tag in ['name', 'addr:housenumber', 'cladr:code',
|
||||||
'addr:city', 'addr:street', 'website',
|
# 'addr:city', 'addr:street', 'website',
|
||||||
'wikidata'] or \
|
# 'wikidata'] or \
|
||||||
'name' in tag or 'wikipedia' in tag:
|
# 'name' in tag or 'wikipedia' in tag:
|
||||||
draw_text(v, str(c.x), str(c.y + 18 + text_y), '444444')
|
# draw_text(v, str(c.x), str(c.y + 18 + text_y), '444444')
|
||||||
text_y += 10
|
# text_y += 10
|
||||||
elif tag == 'addr:country':
|
#elif tag == 'addr:country':
|
||||||
if v == 'RU':
|
# if v == 'RU':
|
||||||
draw_text('Россия', str(c.x), str(c.y + 18 + text_y), '444444')
|
# draw_text('Россия', str(c.x), str(c.y + 18 + text_y), '444444')
|
||||||
else:
|
# else:
|
||||||
draw_text(v, str(c.x), str(c.y + 18 + text_y), '444444')
|
# draw_text(v, str(c.x), str(c.y + 18 + text_y), '444444')
|
||||||
text_y += 10
|
# text_y += 10
|
||||||
elif tag in ['layer', 'height']:
|
elif tag in ['layer', 'height']:
|
||||||
pass
|
pass
|
||||||
elif tag in ['building:levels']:
|
elif tag in ['building:levels']:
|
||||||
|
@ -461,6 +479,14 @@ def draw_raw_nodes():
|
||||||
def no_draw(key):
|
def no_draw(key):
|
||||||
if key in tags_to_write or key in tags_to_skip:
|
if key in tags_to_write or key in tags_to_skip:
|
||||||
return True
|
return True
|
||||||
|
for prefix in prefix_to_write + prefix_to_skip:
|
||||||
|
if key[:len(prefix) + 1] == prefix + ':':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def to_write(key):
|
||||||
|
if key in tags_to_write:
|
||||||
|
return True
|
||||||
for prefix in prefix_to_write:
|
for prefix in prefix_to_write:
|
||||||
if key[:len(prefix) + 1] == prefix + ':':
|
if key[:len(prefix) + 1] == prefix + ':':
|
||||||
return True
|
return True
|
||||||
|
@ -472,29 +498,47 @@ def draw_nodes():
|
||||||
for node_id in node_map:
|
for node_id in node_map:
|
||||||
node = node_map[node_id]
|
node = node_map[node_id]
|
||||||
flinged = flinger.fling(Geo(node['lat'], node['lon']))
|
flinged = flinger.fling(Geo(node['lat'], node['lon']))
|
||||||
x = `flinged.x`
|
x = flinged.x
|
||||||
y = `flinged.y`
|
y = flinged.y
|
||||||
text_y = 0
|
text_y = 0
|
||||||
if 'tags' in node:
|
if 'tags' in node:
|
||||||
p = node['tags']
|
p = node['tags']
|
||||||
else:
|
else:
|
||||||
p = {}
|
p = {}
|
||||||
fill = '444444'
|
fill = '444444'
|
||||||
if 'colour' in p:
|
processed = set([])
|
||||||
if p['colour'] == 'blue':
|
|
||||||
|
if 'colour' in p or 'color' in p:
|
||||||
|
k = 'color' if 'color' in p else 'colour'
|
||||||
|
v = p[k]
|
||||||
|
processed.add(k)
|
||||||
|
if v == 'blue':
|
||||||
fill='2233AA'
|
fill='2233AA'
|
||||||
radius=3
|
elif v == 'lightblue':
|
||||||
|
fill='2288CC'
|
||||||
|
elif v == 'red':
|
||||||
|
fill='CC0000'
|
||||||
|
elif v == 'violet':
|
||||||
|
fill='75507B'
|
||||||
|
elif v == 'green':
|
||||||
|
fill='4E9A06'
|
||||||
|
elif v == 'yellow':
|
||||||
|
fill='EDD400'
|
||||||
|
else:
|
||||||
|
processed.remove(k)
|
||||||
|
|
||||||
|
shapes = []
|
||||||
|
|
||||||
if p == {}:
|
if p == {}:
|
||||||
pass
|
pass
|
||||||
elif 'amenity' in p:
|
elif 'amenity' in p:
|
||||||
k = 'amenity'
|
k = 'amenity'
|
||||||
v = p['amenity']
|
v = p['amenity']
|
||||||
processed = set([k])
|
processed.add(k)
|
||||||
if v in ['bench', 'bicycle_parking', 'cafe', 'waste_basket',
|
if v in ['bench', 'bicycle_parking', 'cafe', 'waste_basket',
|
||||||
'clinic', 'restaurant', 'pharmacy', 'drinking_water',
|
'clinic', 'restaurant', 'pharmacy', 'drinking_water',
|
||||||
'toilets', 'theatre', 'bar', 'bank', 'pub', 'post_office']:
|
'toilets', 'theatre', 'bar', 'bank', 'pub', 'post_office']:
|
||||||
draw_point_shape(v, x, y, fill)
|
shapes.append(v)
|
||||||
elif v == 'fast_food':
|
elif v == 'fast_food':
|
||||||
shape = 'fast_food'
|
shape = 'fast_food'
|
||||||
if 'operator' in p:
|
if 'operator' in p:
|
||||||
|
@ -505,177 +549,190 @@ def draw_nodes():
|
||||||
if p['operator:en'] == "McDonald's":
|
if p['operator:en'] == "McDonald's":
|
||||||
shape = 'mcdonalds'
|
shape = 'mcdonalds'
|
||||||
processed.add('operator:en')
|
processed.add('operator:en')
|
||||||
draw_point_shape(shape, x, y, fill)
|
shapes.append(shape)
|
||||||
elif v == 'shop':
|
elif v == 'shop':
|
||||||
if 'shop' in p:
|
if 'shop' in p:
|
||||||
if p['shop'] in ['fishing']:
|
if p['shop'] in ['fishing']:
|
||||||
draw_point_shape('shop_' + p['shop'], x, y, fill)
|
draw_point_shape('shop_' + p['shop'], x, y, fill)
|
||||||
elif v == 'fountain':
|
elif v == 'fountain':
|
||||||
draw_point_shape('fountain', x, y, water_border_color)
|
shapes.append('fountain')
|
||||||
|
fill = water_border_color
|
||||||
elif v == 'recycling':
|
elif v == 'recycling':
|
||||||
if not 'recycling_type' in p:
|
if not 'recycling_type' in p:
|
||||||
draw_point_shape('recycling', x, y, fill)
|
shapes.append('recycling')
|
||||||
else:
|
else:
|
||||||
processed.remove(k)
|
processed.remove(k)
|
||||||
for k in p:
|
for k in p:
|
||||||
if 'karaoke' in p:
|
if 'karaoke' in p and p['karaoke'] == 'yes':
|
||||||
if p['karaoke'] == 'yes':
|
draw_point_shape('microphone', flinged.x + 16, y, fill)
|
||||||
draw_point_shape('microphone', flinged.x + 16, y, fill)
|
processed.add('karaoke')
|
||||||
else:
|
elif 'building' in p:
|
||||||
point(k, p[k], x, y, fill, text_y)
|
k = 'building'
|
||||||
elif not no_draw(k) and not (k in processed):
|
v = p['building']
|
||||||
point(k, p[k], x, y, fill, text_y)
|
for k in p:
|
||||||
text_y += 10
|
if 'roof:material' in p and p['roof:material'] == 'metal':
|
||||||
|
draw_point_shape('metal_roof', flinged.x + 16, y, fill)
|
||||||
|
processed.add('roof:material')
|
||||||
|
elif 'railway' in p:
|
||||||
|
k = 'railway'
|
||||||
|
v = p['railway']
|
||||||
|
processed.add(k)
|
||||||
|
if v == 'subway_entrance':
|
||||||
|
shapes.append('train')
|
||||||
|
else:
|
||||||
|
processed.remove(k)
|
||||||
|
for k in p:
|
||||||
|
if 'roof:material' in p and p['roof:material'] == 'metal':
|
||||||
|
draw_point_shape('metal_roof', flinged.x + 16, y, fill)
|
||||||
|
processed.add('roof:material')
|
||||||
elif 'natural' in p:
|
elif 'natural' in p:
|
||||||
k = 'natural'
|
k = 'natural'
|
||||||
v = p['natural']
|
v = p['natural']
|
||||||
processed = set([k])
|
processed.add(k)
|
||||||
if v == 'tree':
|
if v == 'tree':
|
||||||
shape = 'tree'
|
shape = 'tree'
|
||||||
if 'leaf_type' in p and p['leaf_type'] in ['broadleaved', 'needleleaved']:
|
if 'leaf_type' in p and p['leaf_type'] in ['broadleaved', 'needleleaved']:
|
||||||
shape = p['leaf_type']
|
shape = p['leaf_type']
|
||||||
processed.add(p['leaf_type'])
|
processed.add('leaf_type')
|
||||||
if 'denotation' in p and p['denotation'] == 'urban':
|
if 'type' in p and p['type'] == 'conifer':
|
||||||
draw_point_shape([shape, 'urban_tree_pot'], x, y, wood_color)
|
shape = 'needleleaved'
|
||||||
processed.add('denotation')
|
processed.add('type')
|
||||||
|
if 'denotation' in p:
|
||||||
|
if p['denotation'] == 'urban':
|
||||||
|
draw_point_shape([shape, 'urban_tree_pot'], x, y, wood_color)
|
||||||
|
processed.add('denotation')
|
||||||
|
elif p['denotation'] == 'avenue':
|
||||||
|
draw_point_shape([shape, 'avenue_tree'], x, y, wood_color)
|
||||||
|
processed.add('denotation')
|
||||||
elif v == 'cave_entrance':
|
elif v == 'cave_entrance':
|
||||||
draw_point_shape('cave', x, y, fill)
|
shapes.append('cave')
|
||||||
elif v == 'bush':
|
elif v == 'bush':
|
||||||
draw_point_shape('bush', x, y, wood_color)
|
shapes.append('bush')
|
||||||
|
fill = wood_color
|
||||||
else:
|
else:
|
||||||
processed.remove(k)
|
processed.remove(k)
|
||||||
for k in p:
|
|
||||||
if not no_draw(k) and not (k in processed):
|
|
||||||
point(k, p[k], x, y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif 'entrance' in p:
|
elif 'entrance' in p:
|
||||||
k = 'entrance'
|
k = 'entrance'
|
||||||
v = p['entrance']
|
v = p['entrance']
|
||||||
processed = set([k])
|
processed.add(k)
|
||||||
if v == 'yes':
|
if v == 'yes':
|
||||||
draw_point_shape('entrance', x, y, fill)
|
shapes.append('entrance')
|
||||||
|
elif v == 'main':
|
||||||
|
shapes.append('main_entrance')
|
||||||
elif v == 'staircase':
|
elif v == 'staircase':
|
||||||
draw_point_shape('staircase', x, y, fill)
|
shapes.append('staircase')
|
||||||
else:
|
else:
|
||||||
processed.remove(k)
|
processed.remove(k)
|
||||||
for k in p:
|
|
||||||
if not no_draw(k) and not (k in processed):
|
|
||||||
point(k, p[k], x, y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif 'highway' in p:
|
elif 'highway' in p:
|
||||||
k = 'highway'
|
k = 'highway'
|
||||||
v = p['highway']
|
v = p['highway']
|
||||||
processed = set([k])
|
processed.add(k)
|
||||||
if v == 'crossing':
|
if v == 'crossing':
|
||||||
shape = 'crossing'
|
shape = 'crossing'
|
||||||
if 'crossing' in p:
|
if 'crossing' in p:
|
||||||
if p['crossing'] == 'zebra':
|
if p['crossing'] == 'zebra':
|
||||||
shape = 'zebra'
|
shape = 'zebra'
|
||||||
|
processed.add('crossing')
|
||||||
|
elif p['crossing'] == 'uncontrolled':
|
||||||
|
draw_point_shape('no_traffic_signals', x + 16, y, fill)
|
||||||
|
processed.add('crossing')
|
||||||
|
elif p['crossing'] == 'traffic_signals':
|
||||||
|
draw_point_shape('traffic_signals', x + 16, y, fill)
|
||||||
|
processed.add('crossing')
|
||||||
elif 'crossing_ref' in p:
|
elif 'crossing_ref' in p:
|
||||||
if p['crossing_ref'] == 'zebra':
|
if p['crossing_ref'] == 'zebra':
|
||||||
shape = 'zebra'
|
shape = 'zebra'
|
||||||
draw_point_shape(shape, x, y, fill)
|
processed.add('crossing_ref')
|
||||||
|
shapes.append(shape)
|
||||||
|
elif v == 'traffic_signals':
|
||||||
|
shapes.append('traffic_signals')
|
||||||
elif v == 'street_lamp':
|
elif v == 'street_lamp':
|
||||||
draw_point_shape('street_lamp', x, y, fill)
|
shapes.append('street_lamp')
|
||||||
else:
|
else:
|
||||||
processed.remove(k)
|
processed.remove(k)
|
||||||
for k in p:
|
elif 'historic' in p:
|
||||||
if not no_draw(k) and not (k in processed):
|
k = 'historic'
|
||||||
point(k, p[k], x, y, fill, text_y)
|
v = p['historic']
|
||||||
text_y += 10
|
processed.add(k)
|
||||||
else:
|
if v == 'memorial':
|
||||||
for k in p:
|
shape = v
|
||||||
if not no_draw(k):
|
if v in p:
|
||||||
point(k, p[k], x, y, fill, text_y)
|
if p[v] == 'statue':
|
||||||
text_y += 10
|
shape = p[v]
|
||||||
|
processed.add(v)
|
||||||
|
elif p[v] == 'plaque':
|
||||||
for k in []:
|
shape = p[v]
|
||||||
v = p[k]
|
processed.add(v)
|
||||||
if k == 'amenity':
|
shapes.append(shape)
|
||||||
if v in ['bench', 'bicycle_parking', 'cafe', 'waste_basket',
|
elif v == 'tomb':
|
||||||
'restaurant', 'pharmacy', 'drinking_water', 'toilets',
|
shape = v
|
||||||
'fast_food', 'theatre']:
|
if v in p:
|
||||||
draw_point_shape(v, x, y, fill)
|
if p[v] == 'mausoleum':
|
||||||
elif k == 'artwork_type':
|
shape = p[v]
|
||||||
if v == 'statue':
|
processed.add(v)
|
||||||
draw_point_shape('monument', x, y, fill)
|
shapes.append(shape)
|
||||||
if v == 'sculpture':
|
|
||||||
draw_point_shape('monument', x, y, fill)
|
|
||||||
else:
|
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif k == 'barrier':
|
|
||||||
if v == 'lift_gate':
|
|
||||||
draw_point_shape('liftgate', x, y, fill)
|
|
||||||
elif k in ['crossing', 'crossing_ref']:
|
|
||||||
if v == 'zebra':
|
|
||||||
draw_point_shape('crossing', x, y, fill)
|
|
||||||
elif k == 'entrance':
|
|
||||||
draw_point_shape('entrance', x, y, fill)
|
|
||||||
elif k == 'highway':
|
|
||||||
if v == 'street_lamp':
|
|
||||||
draw_point_shape('street_lamp', x, y, fill)
|
|
||||||
elif v == 'bus_stop':
|
|
||||||
draw_point_shape('bus_stop', x, y, fill)
|
|
||||||
elif v == 'traffic_signals':
|
|
||||||
draw_point_shape('traffic_signal', x, y, fill)
|
|
||||||
elif v == 'crossing':
|
|
||||||
if not ('crossing' in p):
|
|
||||||
draw_point_shape('crossing', x, y, fill)
|
|
||||||
else:
|
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif k == 'man_made':
|
|
||||||
if v == 'pole':
|
|
||||||
draw_point_shape('pole', x, y, fill)
|
|
||||||
elif v == 'flagpole':
|
|
||||||
draw_point_shape('flagpole', x, y, fill)
|
|
||||||
else:
|
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif k == 'recycling_type':
|
|
||||||
if v == 'centre':
|
|
||||||
draw_point_shape('recycling', x, y, fill)
|
|
||||||
else:
|
|
||||||
draw_point_shape('recycling', x, y, fill)
|
|
||||||
elif k == 'shop':
|
|
||||||
if v == 'florist':
|
|
||||||
draw_point_shape('florist', x, y, fill)
|
|
||||||
elif v in ['clothes', 'shoes', 'gift']:
|
|
||||||
draw_point_shape('shop_' + v, x, y, fill)
|
|
||||||
else:
|
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif k == 'traffic_calming':
|
|
||||||
if v == 'bump':
|
|
||||||
draw_point_shape('bump', x, y, fill)
|
|
||||||
else:
|
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
|
||||||
text_y += 10
|
|
||||||
elif k == 'emergency':
|
|
||||||
if v == 'fire_hydrant':
|
|
||||||
draw_point_shape(v, x, y, fill)
|
|
||||||
elif k == 'historic':
|
|
||||||
if v == 'memorial':
|
|
||||||
draw_point_shape('monument', x, y, fill)
|
|
||||||
elif k == 'tourism':
|
|
||||||
if v == 'artwork':
|
|
||||||
if not ('artwork_type' in p):
|
|
||||||
draw_point_shape('monument', x, y, fill)
|
|
||||||
if v == 'attraction':
|
|
||||||
draw_point_shape('monument', x, y, fill)
|
|
||||||
elif k in undraw or ('name' in k):
|
|
||||||
if k == 'route_ref':
|
|
||||||
v = v.replace(';', ' ')
|
|
||||||
draw_text(v, x, str(flinged.y + 18 + text_y), fill)
|
|
||||||
text_y += 10
|
|
||||||
elif k in ['layer', 'level', 'source', 'note', 'description']:
|
|
||||||
pass # NOTHING TO DRAW
|
|
||||||
else:
|
else:
|
||||||
point(k, v, flinged.x, flinged.y, fill, text_y)
|
processed.remove(k)
|
||||||
|
elif 'barrier' in p:
|
||||||
|
k = 'barrier'
|
||||||
|
v = p['barrier']
|
||||||
|
processed.add(k)
|
||||||
|
if v == 'gate':
|
||||||
|
shapes.append('gate')
|
||||||
|
elif v == 'lift_gate':
|
||||||
|
shapes.append('lift_gate')
|
||||||
|
elif v == 'turnstile':
|
||||||
|
shapes.append('turnstile')
|
||||||
|
else:
|
||||||
|
processed.remove(k)
|
||||||
|
elif 'man_made' in p:
|
||||||
|
k = 'man_made'
|
||||||
|
v = p['man_made']
|
||||||
|
processed.add(k)
|
||||||
|
if v == 'pole':
|
||||||
|
shapes.append('pole')
|
||||||
|
elif v == 'flagpole':
|
||||||
|
shapes.append('flagpole')
|
||||||
|
else:
|
||||||
|
processed.remove(k)
|
||||||
|
elif 'tourism' in p:
|
||||||
|
k = 'tourism'
|
||||||
|
v = p['tourism']
|
||||||
|
processed.add(k)
|
||||||
|
if v == 'attraction':
|
||||||
|
shape = v
|
||||||
|
if v in p:
|
||||||
|
if p[v] == 'amusement_ride':
|
||||||
|
shape = p[v]
|
||||||
|
processed.add(v)
|
||||||
|
shapes.append(shape)
|
||||||
|
else:
|
||||||
|
processed.remove(k)
|
||||||
|
|
||||||
|
for k in []: # p:
|
||||||
|
if to_write(k):
|
||||||
|
draw_text(k + ': ' + p[k], x, y + 18 + text_y, '444444')
|
||||||
text_y += 10
|
text_y += 10
|
||||||
|
|
||||||
|
for k in p:
|
||||||
|
if k == 'foot' and p[k] == 'yes':
|
||||||
|
shapes.append('foot')
|
||||||
|
processed.add(k)
|
||||||
|
elif k == 'bicycle' and p[k] == 'yes':
|
||||||
|
shapes.append('bicycle')
|
||||||
|
processed.add(k)
|
||||||
|
elif k == 'internet_access' and p[k] == 'wlan':
|
||||||
|
shapes.append('wlan')
|
||||||
|
processed.add(k)
|
||||||
|
elif not no_draw(k) and not k in processed:
|
||||||
|
point(k, p[k], x, y, fill, text_y)
|
||||||
|
text_y += 10
|
||||||
|
|
||||||
|
xxx = -(len(shapes) - 1) * 8
|
||||||
|
for shape in shapes:
|
||||||
|
draw_point_shape(shape, x + xxx, y, fill)
|
||||||
|
xxx += 16
|
||||||
|
|
||||||
print 'Done.'
|
print 'Done.'
|
||||||
|
|
||||||
#draw_raw_nodes()
|
#draw_raw_nodes()
|
||||||
|
@ -699,7 +756,8 @@ output_file.end()
|
||||||
print '\nMissing tags:\n'
|
print '\nMissing tags:\n'
|
||||||
top_missed_tags = reversed(sorted(missed_tags.keys(), key=lambda x: -missed_tags[x]))
|
top_missed_tags = reversed(sorted(missed_tags.keys(), key=lambda x: -missed_tags[x]))
|
||||||
for tag in top_missed_tags:
|
for tag in top_missed_tags:
|
||||||
print tag + ' (' + str(missed_tags[tag]) + ')'
|
if tag[:4] == 'node':
|
||||||
|
print tag + ' (' + str(missed_tags[tag]) + ')'
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
|
@ -125,12 +125,12 @@ def parse_osm_file(file_name, silent=False):
|
||||||
elif line[:5] in [' <way', '\t<way']:
|
elif line[:5] in [' <way', '\t<way']:
|
||||||
if line[-3] == '/':
|
if line[-3] == '/':
|
||||||
way = parse_way(line[6:-3])
|
way = parse_way(line[6:-3])
|
||||||
node_map[node['id']] = node
|
way_map[node['id']] = way
|
||||||
else:
|
else:
|
||||||
element = parse_way(line[6:-2])
|
element = parse_way(line[6:-2])
|
||||||
element['tags'] = {}
|
element['tags'] = {}
|
||||||
element['nodes'] = []
|
element['nodes'] = []
|
||||||
elif line == [' </way>\n', '\t</way>\n']:
|
elif line in [' </way>\n', '\t</way>\n']:
|
||||||
way_map[element['id']] = element
|
way_map[element['id']] = element
|
||||||
|
|
||||||
# Relation parsing.
|
# Relation parsing.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue