self.name = None
self.coord = None
- def geocode(self):
+
+ def geocode(self, language='en'):
base_url = 'http://nominatim.openstreetmap.org/search?%s'
params = { 'addressdetails': 1,
'limit': 1,
'format': 'xml',
- 'polygon': 0 }
+ 'polygon': 0,
+ 'accept-language': language}
if self.country:
t = etree.parse('/usr/share/xml/iso-codes/iso_3166.xml')
bbox = (x-r, y-r, x+r, y+r)
draw.ellipse(bbox, outline="red")
+def box(image,box):
+ draw = ImageDraw.Draw(image)
+ draw.rectangle(box, outline="red")
+
def mapimages(coords, zoom=15,size=(TS,TS)):
- minlat = 1000
- maxlat = 0
- minlon = 1000
- maxlon = 0
- for c in coords:
- minlat = min(minlat,c[0])
- maxlat = max(maxlat,c[0])
- minlon = min(minlon,c[1])
- maxlon = max(maxlon,c[1])
+
+ minlat = min(coords,key=attrgetter('latitude'))
+ maxlat = max(coords,key=attrgetter('latitude'))
+ minlon = min(coords,key=attrgetter('longitude'))
+ maxlon = max(coords,key=attrgetter('longitude'))
+
# Find minimal bounding box and expand it 5%
hyp = distance((maxlat,minlon),(minlat,maxlon))
hyp = hyp*0.05
lld = Geodesic.WGS84.Direct(minlat, minlon, 225, hyp)
lrd = Geodesic.WGS84.Direct(minlat, maxlon, 135, hyp)
+ ul = Coord(maxlat,minlon).direct(315, hyp)
+
ul = (uld['lat2'],uld['lon2'])
ur = (urd['lat2'],urd['lon2'])
ll = (lld['lat2'],lld['lon2'])