This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
66 lines (54 loc) · 2.62 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'''
pyStaticMap 0.01 (https://github.com/csueiras/pystaticmap)
Copyright 2012 Christian A. Sueiras
LARGELY Based on the fantastic work of Gerhard Koch <gerhard.koch AT ymail.com>
http://sourceforge.net/projects/staticmaplite/
-Allows you to generate static maps from OSM data
Depends on:
-Python Image Library (PIL)
-URLib2
#######################################################################################
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#######################################################################################
'''
import sys
from staticmap import StaticMap
if __name__ == "__main__":
maps = [{ 'lat': 40.714728, \
'lon':-73.998672, \
'zoom':14, \
'width':600, \
'height':600, \
'filename': 'new_york.png', \
'markers': [{'lat': 40.714728, 'lon':-73.998672, 'filename': 'accident.png', 'offset_x': -16, 'offset_y': 0}], \
'paths': ( ({'lat': 40.714728, 'lon': -73.998672}, {'lat': 40.714728, 'lon': -73.80234}) ) \
},\
{ 'lat': 27.790491, \
'lon':-81.584473, \
'zoom':7, \
'width':600, \
'height':600, \
'filename': 'florida.png', \
'markers': [{'lat': 27.790491, 'lon':-81.584473, 'filename': 'accident.png', 'offset_x': 0, 'offset_y': 0}],
'paths': () \
}]
output_dir = 'tests'
my_map = StaticMap()
for test_map in maps:
print "Generating... " + test_map['filename']
my_map.setup_map(lat = test_map['lat'], lon = test_map['lon'], zoom = test_map['zoom'], map_width = test_map['width'], map_height = test_map['height'])
for path in test_map['paths']:
my_map.add_path({'lat': 40.714728, 'lon': -73.998672}, {'lat': 40.924728, 'lon': -73.98234})
for marker in test_map['markers']:
my_map.add_marker(marker)
my_map.save_map(output_dir + '/' + test_map['filename'])
print "Generated"
my_map.reset()