diff --git a/README.md b/README.md index a38fdfb..dc2d7fa 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It is actually not just another map style since it is **not** *a map for users* Map generation -------------- -![Sample map](map.png) +![Sample map](doc/map.png) **Requirements**: Python 2.7. @@ -47,7 +47,7 @@ If tag is drawable it is displayed using icon combination and colors. Double size: -![Icons](grid.png) +![Icons](doc/grid.png) Feel free to request new icons via issues for whatever you want to see on the map. No matter how frequently the tag is used in OpenStreetMap since final goal is to cover all tags. However, common used tags have priority, other things being equal. diff --git a/colors.yml b/data/colors.yml similarity index 100% rename from colors.yml rename to data/colors.yml diff --git a/tags.yml b/data/tags.yml similarity index 100% rename from tags.yml rename to data/tags.yml diff --git a/grid.png b/doc/grid.png similarity index 100% rename from grid.png rename to doc/grid.png diff --git a/map.png b/doc/map.png similarity index 100% rename from map.png rename to doc/map.png diff --git a/doc/readme.moi b/doc/readme.moi index 3024aa1..8387521 100644 --- a/doc/readme.moi +++ b/doc/readme.moi @@ -6,7 +6,7 @@ It is actually not just another map style since it is \b {not} \i {a map for use \2 {Map generation} {map_generation} -\image {map.png} {Sample map} +\image {doc/map.png} {Sample map} \b {Requirements}: Python 2.7. @@ -38,6 +38,6 @@ If tag is drawable it is displayed using icon combination and colors. Double size: -\image {grid.png} {Icons} +\image {doc/grid.png} {Icons} Feel free to request new icons via issues for whatever you want to see on the map. No matter how frequently the tag is used in OpenStreetMap since final goal is to cover all tags. However, common used tags have priority, other things being equal. diff --git a/extract_icon.py b/engine/extract_icon.py similarity index 100% rename from extract_icon.py rename to engine/extract_icon.py diff --git a/flinger.py b/engine/flinger.py similarity index 99% rename from flinger.py rename to engine/flinger.py index 31bb980..fe3f767 100644 --- a/flinger.py +++ b/engine/flinger.py @@ -7,7 +7,7 @@ Author: Sergey Vartanov (me@enzet.ru) import math import sys -sys.path.append('lib') +sys.path.append('../lib') from vector import Vector diff --git a/mapper.py b/engine/mapper.py similarity index 95% rename from mapper.py rename to engine/mapper.py index bca30e7..3f2ed56 100644 --- a/mapper.py +++ b/engine/mapper.py @@ -22,7 +22,7 @@ import ui from flinger import GeoFlinger, Geo -sys.path.append('lib') +sys.path.append('../lib') import svg from vector import Vector @@ -43,6 +43,11 @@ water_color = 'AACCFF' water_border_color = '6688BB' wood_color = 'B8CC84' +icons_file_name = '../icons/icons.svg' +tags_file_name = '../data/tags.yml' +colors_file_name = '../data/colors.yml' +missed_tags_file_name = '../missed_tags_file_name.yml' + tags_to_write = set(['operator', 'opening_hours', 'cuisine', 'network', 'website', 'website_2', 'STIF:zone', 'opening_hours:url', 'phone', 'branch', 'route_ref', 'brand', 'ref', 'wikipedia', @@ -87,32 +92,6 @@ def get_d_from_file(file_name): # TODO: add to missed icons return 'M 4,4 L 4,10 10,10 10,4 z', 0, 0 - # Old style. - - if os.path.isfile('icons/' + file_name + '.svg'): - file_name = 'icons/' + file_name + '.svg' - size = 16 - elif os.path.isfile('icons/' + file_name + '.16.svg'): - file_name = 'icons/' + file_name + '.16.svg' - size = 16 - elif os.path.isfile('icons/' + file_name + '-12.svg'): - file_name = 'icons/' + file_name + '-12.svg' - size = 12 - elif os.path.isfile('icons/' + file_name + '.12.svg'): - file_name = 'icons/' + file_name + '.12.svg' - size = 12 - elif os.path.isfile('icons/' + file_name + '.10.svg'): - file_name = 'icons/' + file_name + '.10.svg' - size = 10 - else: - print 'Unknown file:', file_name - return 'M 4,4 L 4,10 10,10 10,4 z', 16 - f = open(file_name).read().split('\n') - for line in f: - m = re.match('.* d="(?P[AaMmCcLlZz0-9Ee., -]*)".*', line) - if m: - return m.group('path'), size - def get_min_max(node_map): key = node_map.keys()[0] @@ -570,9 +549,9 @@ missed_tags = {} points = [] icons_to_draw = [] # {shape, x, y, priority} -scheme = yaml.load(open('tags.yml')) +scheme = yaml.load(open(tags_file_name)) scheme['cache'] = {} -w3c_colors = yaml.load(open('colors.yml')) +w3c_colors = yaml.load(open(colors_file_name)) for color_name in w3c_colors: scheme['colors'][color_name] = w3c_colors[color_name] @@ -587,7 +566,7 @@ else: if options['draw_ways']: layers = construct_layers() -icons = extract_icon.IconExtractor('icons.svg') +icons = extract_icon.IconExtractor(icons_file_name) if options['draw_ways']: draw_ways(show_missed_tags=options['show_missed_tags']) @@ -601,7 +580,7 @@ if flinger.space.x == 0: output_file.end() top_missed_tags = sorted(missed_tags.keys(), key=lambda x: -missed_tags[x]) -missed_tags_file = open('missed_tags.yml', 'w+') +missed_tags_file = open(missed_tags_file_name, 'w+') for tag in top_missed_tags: missed_tags_file.write('- {tag: "' + tag + '", count: ' + \ str(missed_tags[tag]) + '}\n') diff --git a/osm_getter.py b/engine/osm_getter.py similarity index 90% rename from osm_getter.py rename to engine/osm_getter.py index a930a8f..1e793cf 100644 --- a/osm_getter.py +++ b/engine/osm_getter.py @@ -13,6 +13,8 @@ if len(sys.argv) < 2: boundary_box = sys.argv[1] +result_file_name = '../map/' + boundary_box + '.xml' + matcher = re.match('(?P[0-9\\.-]*),(?P[0-9\\.-]*),' + \ '(?P[0-9\\.-]*),(?P[0-9\\.-]*)', boundary_box) @@ -40,5 +42,4 @@ else: if right - left > 0.5 or top - bottom > 0.5: error('box too big') content = network.get_content('api.openstreetmap.org/api/0.6/map', - {'bbox': boundary_box}, - 'map/' + boundary_box + '.xml', 'html') + {'bbox': boundary_box}, result_file_name, 'html') diff --git a/osm_reader.py b/engine/osm_reader.py similarity index 100% rename from osm_reader.py rename to engine/osm_reader.py diff --git a/process.py b/engine/process.py similarity index 100% rename from process.py rename to engine/process.py diff --git a/engine/refresh_files.py b/engine/refresh_files.py new file mode 100644 index 0000000..a7c3c64 --- /dev/null +++ b/engine/refresh_files.py @@ -0,0 +1,23 @@ +import os +import sys + +usage = ' ' + +if len(sys.argv) < 3: + print 'Usage: python ' + sys.argv[0] + ' ' + usage + sys.exit(1) + +from_directory = sys.argv[1] +to_directory = sys.argv[2] + +for file_name in os.listdir(from_directory): + print file_name + from_file_time = os.path.getmtime(from_directory + '/' + file_name) + if os.path.isfile(to_directory + '/' + file_name): + to_file_time = os.path.getmtime(to_directory + '/' + file_name) + if from_file_time > to_file_time: + print 'Seems like you have newer version for file ' + file_name + '.' + answer = raw_input('Should I copy it? [y/n] ') + if answer.lower() in ['y', 'yes']: + pass + diff --git a/test.py b/engine/test.py similarity index 92% rename from test.py rename to engine/test.py index a7481f3..4c28325 100644 --- a/test.py +++ b/engine/test.py @@ -9,12 +9,16 @@ import os import sys import yaml -scheme = yaml.load(open('tags.yml')) +tags_file_name = '../data/tags.yml' -sys.path.append('lib') +scheme = yaml.load(open(tags_file_name)) + +sys.path.append('../lib') import svg +icons_file_name = '../icons/icons.svg' + def draw_icon(icon): output_file.write('