fixed geocode, issue 855, thanks niphllod
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.00.0 (2012-06-17 23:35:00) dev
|
Version 2.00.0 (2012-06-17 23:36:32) dev
|
||||||
|
|||||||
+2
-3
@@ -3567,13 +3567,12 @@ def fetch(url, data=None, headers=None,
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
regex_geocode = \
|
regex_geocode = \
|
||||||
re.compile('\<coordinates\>(?P<la>[^,]*),(?P<lo>[^,]*).*?\</coordinates\>')
|
re.compile(r"""<geometry>[\W]*?<location>[\W]*?<lat>(?P<la>[^<]*)</lat>[\W]*?<lng>(?P<lo>[^<]*)</lng>[\W]*?</location>""")
|
||||||
|
|
||||||
|
|
||||||
def geocode(address):
|
def geocode(address):
|
||||||
try:
|
try:
|
||||||
a = urllib.quote(address)
|
a = urllib.quote(address)
|
||||||
txt = fetch('http://maps.google.com/maps/geo?q=%s&output=xml'
|
txt = fetch('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=%s'
|
||||||
% a)
|
% a)
|
||||||
item = regex_geocode.search(txt)
|
item = regex_geocode.search(txt)
|
||||||
(la, lo) = (float(item.group('la')), float(item.group('lo')))
|
(la, lo) = (float(item.group('la')), float(item.group('lo')))
|
||||||
|
|||||||
Reference in New Issue
Block a user