mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-05 12:21:54 +02:00
Major refactoring.
This commit is contained in:
parent
5c8a49555f
commit
99b88bb341
12 changed files with 393 additions and 57 deletions
48
roentgen/osm_getter.py
Normal file
48
roentgen/osm_getter.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import re
|
||||
import sys
|
||||
|
||||
sys.path.append('../lib')
|
||||
|
||||
import network
|
||||
|
||||
|
||||
usage = '<box coordinates: left,bottom,right,top>'
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: python ' + sys.argv[0] + ' ' + usage)
|
||||
sys.exit(0)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def error(message=None):
|
||||
if message:
|
||||
print('Error: ' + message + '.')
|
||||
else:
|
||||
print('Error.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if not matcher:
|
||||
error('invalid boundary box')
|
||||
else:
|
||||
try:
|
||||
left = float(matcher.group('left'))
|
||||
bottom = float(matcher.group('bottom'))
|
||||
right = float(matcher.group('right'))
|
||||
top = float(matcher.group('top'))
|
||||
except Exception as e:
|
||||
error('parsing boundary box')
|
||||
if left >= right:
|
||||
error('negative horisontal boundary')
|
||||
if bottom >= top:
|
||||
error('negative vertical boundary')
|
||||
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}, result_file_name, 'html')
|
Loading…
Add table
Add a link
Reference in a new issue