mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-11 16:16:51 +02:00
Total refactoring.
This commit is contained in:
parent
9e7f219b11
commit
a1fca515bd
16 changed files with 48 additions and 41 deletions
|
@ -8,7 +8,7 @@ It is actually not just another map style since it is **not** *a map for users*
|
|||
Map generation
|
||||
--------------
|
||||
|
||||

|
||||

|
||||
|
||||
**Requirements**: Python 2.7.
|
||||
|
||||
|
@ -47,7 +47,7 @@ If tag is drawable it is displayed using icon combination and colors.
|
|||
|
||||
Double size:
|
||||
|
||||

|
||||

|
||||
|
||||
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.
|
||||
|
||||
|
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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<path>[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')
|
|
@ -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<left>[0-9\\.-]*),(?P<bottom>[0-9\\.-]*),' + \
|
||||
'(?P<right>[0-9\\.-]*),(?P<top>[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')
|
23
engine/refresh_files.py
Normal file
23
engine/refresh_files.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
usage = '<from directory> <to directory>'
|
||||
|
||||
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
|
||||
|
|
@ -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('<path d="' + icon['path'] + '" ' + \
|
||||
'style="fill:#444444;stroke:none;' + \
|
||||
|
@ -28,7 +32,7 @@ step = 24
|
|||
|
||||
width = step * 10
|
||||
|
||||
extracter = extract_icon.IconExtractor('icons.svg')
|
||||
extracter = extract_icon.IconExtractor(icons_file_name)
|
||||
|
||||
x = step / 2
|
||||
y = step / 2
|
Before Width: | Height: | Size: 231 KiB After Width: | Height: | Size: 231 KiB |
Loading…
Add table
Add a link
Reference in a new issue