diff --git a/icons.svg b/icons.svg index e2377eb..69e6814 100644 --- a/icons.svg +++ b/icons.svg @@ -13,7 +13,7 @@ height="600px" id="svg2987" version="1.1" - inkscape:version="0.48.5 r10040" + inkscape:version="0.48.3.1 r9886" sodipodi:docname="icons.svg"> @@ -24,20 +24,20 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="32" - inkscape:cx="43.689055" - inkscape:cy="429.90811" + inkscape:zoom="1" + inkscape:cx="306.0879" + inkscape:cy="579.54088" inkscape:current-layer="layer1" inkscape:document-units="px" - showgrid="true" - showguides="true" + showgrid="false" + showguides="false" inkscape:guide-bbox="true" inkscape:object-paths="true" inkscape:snap-bbox="true" inkscape:window-width="1518" inkscape:window-height="1000" inkscape:window-x="28" - inkscape:window-y="21" + inkscape:window-y="22" inkscape:window-maximized="0"> - + + + + + + + + + + + diff --git a/mapper.py b/mapper.py index b593710..ad4c2d0 100644 --- a/mapper.py +++ b/mapper.py @@ -495,6 +495,8 @@ def to_write(key): def draw_nodes(): print 'Draw nodes...' + # yaml.load(open('tags.yml')) + for node_id in node_map: node = node_map[node_id] flinged = flinger.fling(Geo(node['lat'], node['lon'])) @@ -581,10 +583,6 @@ def draw_nodes(): 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: k = 'natural' v = p['natural'] diff --git a/tags.yml b/tags.yml new file mode 100644 index 0000000..c759484 --- /dev/null +++ b/tags.yml @@ -0,0 +1,127 @@ +colors: + + # Color names + + 'blue': '2233AA' + 'lightblue': '2288CC' + 'red': 'CC0000' + 'violet': '75507B' + 'green': '4E9A06' + 'yellow': 'EDD400' + + # Entity + + 'background': 'EEEEEE' + 'grass': 'C8DC94' + 'sand': 'F0E0D0' + 'beach': 'F0E0C0' + 'desert': 'F0E0D0' + 'playground': '884400' + 'parking': 'DDCC99' + 'water': 'AACCFF' + 'water_border': '6688BB' + +tags: +- tags: {amenity: bench} + icon: [bench] +- tags: {amenity: bicycle_parking} + icon: [bicycle_parking] +- tags: {amenity: cafe} + icon: [cafe] +- tags: {amenity: waste_basket} + icon: [waste_basket] +- tags: {amenity: clinic} + icon: [clinic] +- tags: {amenity: restaurant} + icon: [restaurant] +- tags: {amenity: pharmacy} + icon: [pharmacy] +- tags: {amenity: drinking_water} + icon: [drinking_water] +- tags: {amenity: toilets} + icon: [toilets] +- tags: {amenity: theatre} + icon: [theatre] +- tags: {amenity: bar} + icon: [bar] +- tags: {amenity: bank} + icon: [bank] +- tags: {amenity: pub} + icon: [pub] +- tags: {amenity: post_office} + icon: [post_office] +- tags: {amenity: fast_food, 'operator:en': McDonald's} + icon: [mcdonalds] +- tags: {amenity: fast_food} + icon: [fast_food] +- tags: {amenity: shop, shop: fishing} + icon: [fishing] +- tags: {amenity: fountain} + icon: [fontain] + color: water_border +- tags: {amenity: '*', karaoke: yes} + add_icon: [microphone] +- tags: {building: '*', 'roof:material': metal} + icon: [metal_roof] +- tags: {railway: subway_entrance} + icon: [train] +- tags: {natural: tree} + icon: [tree] +- tags: {natural: tree, leaf_type: broadleaved} + icon: [broadleaved] +- tags: {natural: tree, leaf_type: needleleaved} + icon: [needleleaved] +- tags: {natural: tree, type: conifer} + icon: [needleleaved] +- tags: {natural: tree, denotation: urban} + over_icon: [urban_tree_pot] + under_icon: [tree, broadleaved, needleleaved] +- tags: {natural: tree, denotation: avenue_tree} + over_icon: [avenue_tree] + under_icon: [tree, broadleaved, needleleaved] +- tags: {entrance: yes} + icon: [entrance] +- tags: {entrance: main} + icon: [main_entrance] +- tags: {entrance: staircase} + icon: [staircase] +- tags: {highway: crossing} + icon: [crossing] +- tags: {highway: crossing, crossing: uncontrolled} + add_icon: [no_traffic_signals] +- tags: {highway: crossing, crossing: traffic_signals} + add_icon: [traffic_signals] +- tags: {highway: traffic_signals} + icon: [traffic_signals] +- tags: {highway: street_lamp} + icon: [street_lamp] +- tags: {historic: memorial} + icon: [memorial] +- tags: {historic: memorial, memorial: statue} + icon: [statue] +- tags: {historic: memorial, memorial: plaque} + icon: [plaque] +- tags: {historic: tomb} + icon: [tomb] +- tags: {historic: tomb, tomb: mausoleum} + icon: [mausoleum] +- tags: {barrier: gate} + icon: [gate] +- tags: {barrier: lift_gate} + icon: [lift_gate] +- tags: {barrier: turnstile} + icon: [turnstile] +- tags: {man_made: pole} + icon: [pole] +- tags: {man_made: flagpole} + icon: [flagpole] +- tags: {tourism: attraction} + icon: [attraction] +- tags: {tourism: attraction, attraction: amusement_ride} + icon: [amusement_ride] +- tags: {foot: yes} + icon: [foot] +- tags: {bicycle: yes} + icon: [bicycle] +- tags: {internet_access: wlan} + icon: [wlan] diff --git a/test.py b/test.py new file mode 100644 index 0000000..0c0410a --- /dev/null +++ b/test.py @@ -0,0 +1,84 @@ +import copy +import extract_icon +import sys +import yaml + +scheme = yaml.load(open('tags.yml')) + +sys.path.append('lib') + +import svg + +step = 24 + +width = step * 10 + +extracter = extract_icon.IconExtractor('icons.svg') + +output_file = svg.SVG(open('icon_grid.svg', 'w+')) +output_file.begin(width, 1000) + +x = step / 2 +y = step / 2 + +def get_icon(tags): + print '--------------', tags + main_icon = None + extra_icons = [] + for element in scheme['tags']: + matched = True + for tag in element['tags']: + if not tag in tags: + matched = False + break + if element['tags'][tag] != '*' and element['tags'][tag] != tags[tag]: + matched = False + break + if matched: + print 'matched', element + if 'icon' in element: + main_icon = copy.deepcopy(element['icon']) + if 'over_icon' in element: + main_icon += element['over_icon'] + if 'add_icon' in element: + extra_icons += element['add_icon'] + if main_icon: + print '----', [main_icon] + extra_icons + return [main_icon] + extra_icons + else: + print '----', [] + return [] + +to_draw = {} + +for element in scheme['tags']: + if 'icon' in element: + to_draw[','.join(element['icon'])] = element['icon'] + if 'add_icon' in element: + to_draw[','.join(element['add_icon'])] = element['add_icon'] + if 'over_icon' in element: + for icon in element['under_icon']: + to_draw[','.join([icon] + element['over_icon'])] = [icon] + element['over_icon'] + +for icon_key in to_draw.keys(): + icons = to_draw[icon_key] + drawed = False + for icon in icons: + path, xx, yy = extracter.get_path(icon) + if path: + output_file.write('\n') + drawed = True + else: + print '\033[31m' + icon + '\033[0m' + if drawed: + x += step + if x > width - 8: + x = step / 2 + y += step + +output_file.end()