diff --git a/icons.html b/icons.html new file mode 100644 index 0000000..63d29c8 --- /dev/null +++ b/icons.html @@ -0,0 +1,17 @@ + + + Icons + + + +

Normal size

+ + + +

Double size

+ +
+ +
+ + diff --git a/icons.svg b/icons.svg index 1e4cb94..95fdecf 100644 --- a/icons.svg +++ b/icons.svg @@ -24,20 +24,20 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="0.35355339" - inkscape:cx="226.29957" - inkscape:cy="490.64693" + inkscape:zoom="22.627417" + inkscape:cx="35.973755" + inkscape:cy="329.30909" inkscape:current-layer="layer1" inkscape:document-units="px" - showgrid="false" - showguides="false" + showgrid="true" + showguides="true" inkscape:guide-bbox="true" inkscape:object-paths="true" inkscape:snap-bbox="true" - inkscape:window-width="1440" - inkscape:window-height="855" - inkscape:window-x="2" - inkscape:window-y="0" + inkscape:window-width="1515" + inkscape:window-height="990" + inkscape:window-x="33" + inkscape:window-y="24" inkscape:window-maximized="0"> + d="m 200,132 c -0.554,0 -1,0.446 -1,1 -0.554,0 -1,0.446 -1,1 l 0,3 c 0,0.554 0.446,1 1,1 0,0.554 0.446,1 1,1 l 0.5625,0 0,3 0.875,0 0,-3 0.5625,0 c 0.554,0 1,-0.446 1,-1 0.554,0 1,-0.446 1,-1 l 0,-3 c 0,-0.554 -0.446,-1 -1,-1 0,-0.554 -0.446,-1 -1,-1 l -2,0 z" /> + d="m 215,132 c -0.554,0 -1,0.446 -1,1 -0.554,0 -1,0.446 -1,1 l 0,3 c 0,0.554 0.446,1 1,1 0,0.554 0.446,1 1,1 l 0.5625,0 0,3 0.875,0 0,-3 0.5625,0 c 0.554,0 1,-0.446 1,-1 0.554,0 1,-0.446 1,-1 l 0,-3 c 0,-0.554 -0.446,-1 -1,-1 0,-0.554 -0.446,-1 -1,-1 l -2,0 z" /> @@ -2234,8 +2234,8 @@ inkscape:label="#rect4597" inkscape:connector-curvature="0" /> @@ -2303,10 +2303,11 @@ rx="0.5" /> + sodipodi:nodetypes="ssssccccccccccsssssssssccssssssssssss" + inkscape:label="#rect3376" /> @@ -2425,7 +2426,7 @@ id="rect4393" width="3" height="1" - x="131" + x="161" y="199" ry="0.5" rx="0.5" /> @@ -2434,7 +2435,7 @@ id="rect4395" width="2" height="5" - x="132" + x="162" y="199" ry="0.5" rx="0.5" /> @@ -2443,7 +2444,7 @@ id="rect4397" width="4" height="1" - x="131" + x="161" y="203" ry="0.5" rx="0.5" /> @@ -2452,7 +2453,7 @@ id="rect4399" width="2" height="2" - x="132" + x="162" y="196" ry="0.5" rx="0.5" /> @@ -2461,7 +2462,7 @@ id="rect4401" width="5" height="2" - x="139" + x="169" y="198" ry="0.5" rx="0.5" /> @@ -2470,7 +2471,7 @@ id="rect4403" width="3" height="9" - x="141" + x="171" y="198" ry="0.5" rx="0.5" /> @@ -2479,7 +2480,7 @@ id="rect4405" width="7" height="2" - x="139" + x="169" y="205" ry="0.5" rx="0.5" /> @@ -2488,14 +2489,14 @@ id="rect4407" width="3" height="3" - x="141" + x="171" y="193" ry="0.5" rx="0.5" /> @@ -2589,5 +2590,170 @@ id="path4465" inkscape:connector-curvature="0" sodipodi:nodetypes="cccc" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mapper.py b/mapper.py index 7312b24..3f75650 100644 --- a/mapper.py +++ b/mapper.py @@ -62,9 +62,9 @@ tags_to_write = set(['operator', 'opening_hours', 'cuisine', 'network', 'websit prefix_to_write = set(['addr', 'contact', 'name', 'operator', 'wikipedia', 'alt_name', 'description', 'old_name', 'inscription', - 'route_ref', 'is_in', 'website', + 'route_ref', 'is_in', 'website', 'ref', # To draw - 'species', 'taxon']) + 'species', 'taxon', 'genus']) tags_to_skip = set(['note', 'layer', 'source', 'building:part', 'fixme', 'comment', 'FIXME', 'source_ref', 'naptan:verified:note']) @@ -622,7 +622,7 @@ if not os.path.isfile(input_file_name): sys.exit(1) node_map, way_map, relation_map = osm_reader.parse_osm_file(input_file_name, - parse_ways=False, parse_relations=False) + parse_ways=True, parse_relations=True) output_file = svg.SVG(open(sys.argv[2], 'w+')) @@ -659,7 +659,7 @@ icons = extract_icon.IconExtractor('icons.svg') #sys.exit(0) #draw_ways() -draw_nodes(show_missed_tags=False, overlap=12, draw=True) +draw_nodes(show_missed_tags=True, overlap=12, draw=True) #draw_ways() #draw_nodes() diff --git a/tags.yml b/tags.yml index c3b6496..f3455e3 100644 --- a/tags.yml +++ b/tags.yml @@ -80,14 +80,14 @@ tags: icon: [kindergarten] - 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: shop, shop: convenience} icon: [shop_convenience] +- tags: {amenity: shop, shop: kiosk} + icon: [kiosk] - tags: {shop: gift} icon: [gift] - tags: {amenity: fountain} @@ -236,5 +236,7 @@ tags: add_icon: [private] - tags: {direction: clockwise} add_icon: [clockwise] +- tags: {direction: contrclockwise} + add_icon: [contrclockwise] - tags: {smoking: 'no'} add_icon: [no_smoking] diff --git a/test.py b/test.py index 0c0410a..0427287 100644 --- a/test.py +++ b/test.py @@ -1,3 +1,7 @@ +""" +Author: Sergey Vartanov (me@enzet.ru). +""" + import copy import extract_icon import sys @@ -9,20 +13,7 @@ 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']: @@ -31,7 +22,8 @@ def get_icon(tags): if not tag in tags: matched = False break - if element['tags'][tag] != '*' and element['tags'][tag] != tags[tag]: + if element['tags'][tag] != '*' and \ + element['tags'][tag] != tags[tag]: matched = False break if matched: @@ -43,12 +35,27 @@ def get_icon(tags): 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 [] +def draw_icon(icon): + output_file.write('\n') + +# Actions + +step = 24 + +width = step * 10 + +extracter = extract_icon.IconExtractor('icons.svg') + +x = step / 2 +y = step / 2 + to_draw = {} for element in scheme['tags']: @@ -58,20 +65,21 @@ for element in scheme['tags']: 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'] + to_draw[','.join([icon] + element['over_icon'])] = [icon] + \ + element['over_icon'] + +icons = [] +height = 24 for icon_key in to_draw.keys(): - icons = to_draw[icon_key] + icons_to_draw = to_draw[icon_key] drawed = False - for icon in icons: + for icon in icons_to_draw: path, xx, yy = extracter.get_path(icon) if path: - output_file.write('\n') + icons.append({'path': path, + 'x': str(x - 8.0 - xx * 16), + 'y': str(y - 8.0 - yy * 16)}); drawed = True else: print '\033[31m' + icon + '\033[0m' @@ -80,5 +88,12 @@ for icon_key in to_draw.keys(): if x > width - 8: x = step / 2 y += step + height += step + +output_file = svg.SVG(open('icon_grid.svg', 'w+')) +output_file.begin(width, height) + +for icon in icons: + draw_icon(icon) output_file.end()