Updated version.
svn: r11847
This commit is contained in:
parent
78feddd292
commit
1e8ec7eb2d
@ -37,13 +37,21 @@ from gettext import gettext as _
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gen.plug import PluginManager
|
from gen.plug import PluginManager
|
||||||
from libmapservice import MapService
|
from libmapservice import MapService
|
||||||
from QuestionDialog import WarningDialog, QuestionDialog2
|
from QuestionDialog import WarningDialog
|
||||||
|
|
||||||
# Make upper case of translaed country so string search works later
|
# Make upper case of translaed country so string search works later
|
||||||
MAP_NAMES_SWEDEN = _("Sweden").upper() + " SVERIGE SWEDEN" + \
|
MAP_NAMES_SWEDEN = [_("Sweden").upper(),
|
||||||
" SUEDOIS ROUTSI SCHWEDEN"
|
"SVERIGE",
|
||||||
MAP_NAMES_DENMARK = _("Denmark").upper() + " DANMARK DENMARK" + \
|
"SWEDEN",
|
||||||
" DANOIS TANSKA DÄNEMARK"
|
"SUEDOIS",
|
||||||
|
"ROUTSI",
|
||||||
|
"SCHWEDEN", ]
|
||||||
|
MAP_NAMES_DENMARK = [_("Denmark").upper(),
|
||||||
|
"DANMARK",
|
||||||
|
"DENMARK",
|
||||||
|
"DANOIS",
|
||||||
|
"TANSKA",
|
||||||
|
"DÄNEMARK", ]
|
||||||
|
|
||||||
|
|
||||||
def _strip_leading_comma(descr):
|
def _strip_leading_comma(descr):
|
||||||
@ -110,9 +118,9 @@ class EniroSVMapService(MapService):
|
|||||||
path = ""
|
path = ""
|
||||||
# First see if we are in or near Sweden or Denmark
|
# First see if we are in or near Sweden or Denmark
|
||||||
# Change country to upper case
|
# Change country to upper case
|
||||||
country = place.get_main_location().get_country().upper()
|
country = place.get_main_location().get_country().upper().strip()
|
||||||
country_given = country in MAP_NAMES_SWEDEN or \
|
country_given = (country in MAP_NAMES_SWEDEN or \
|
||||||
country in MAP_NAMES_DENMARK
|
country in MAP_NAMES_DENMARK) and (country != "")
|
||||||
# if no country given, check if we might be in the vicinity defined by
|
# if no country given, check if we might be in the vicinity defined by
|
||||||
# 54 33' 0" < lat < 66 9' 0", 54.55 and 69.05
|
# 54 33' 0" < lat < 66 9' 0", 54.55 and 69.05
|
||||||
# 8 3' 0" < long < 24 9' 0", 8.05 and 24.15
|
# 8 3' 0" < long < 24 9' 0", 8.05 and 24.15
|
||||||
@ -126,14 +134,11 @@ class EniroSVMapService(MapService):
|
|||||||
if (54.55 < latitude < 69.05) and (8.05 < longitude < 24.15):
|
if (54.55 < latitude < 69.05) and (8.05 < longitude < 24.15):
|
||||||
coord_ok = True
|
coord_ok = True
|
||||||
else:
|
else:
|
||||||
dlgan = QuestionDialog2(_("Coordinates outside Sweden/Denmark"),
|
msg2 = _("Latitude not within %s to %s\n") + \
|
||||||
_("Try another map service?"),
|
_("Longitude not within %s to %s")
|
||||||
_("Yes"),
|
msg2 = msg2 % (54.55, 69.05, 8.05, 24.15)
|
||||||
_("No"))
|
WarningDialog(_("Eniro map not available"), msg2 )
|
||||||
if dlgan.run():
|
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
coord_ok = True
|
|
||||||
# Now check if country is defined
|
# Now check if country is defined
|
||||||
if not (country_given or coord_ok):
|
if not (country_given or coord_ok):
|
||||||
WarningDialog(_("Eniro map not available"),
|
WarningDialog(_("Eniro map not available"),
|
||||||
@ -144,10 +149,14 @@ class EniroSVMapService(MapService):
|
|||||||
place_title = _build_title(place)
|
place_title = _build_title(place)
|
||||||
place_city = _build_city(place)
|
place_city = _build_city(place)
|
||||||
x_coord, y_coord = self._lat_lon(place, format="RT90")
|
x_coord, y_coord = self._lat_lon(place, format="RT90")
|
||||||
|
# Set zoom level to 5 if Sweden/Denmark, others 3
|
||||||
|
zoom = 5
|
||||||
|
if not country_given:
|
||||||
|
zoom = 3
|
||||||
path = "http://www.eniro.se/partner.fcgi?pis=1&x=%s&y=%s" \
|
path = "http://www.eniro.se/partner.fcgi?pis=1&x=%s&y=%s" \
|
||||||
"&zoom_level=5&map_size=0&title=%s&city=%s&partner=gramps"
|
"&zoom_level=%i&map_size=0&title=%s&city=%s&partner=gramps"
|
||||||
# Note x and y are swapped!
|
# Note x and y are swapped!
|
||||||
path = path % (y_coord , x_coord, place_title, place_city)
|
path = path % (y_coord , x_coord, zoom, place_title, place_city)
|
||||||
self.url = path.replace(" ","%20")
|
self.url = path.replace(" ","%20")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -160,12 +169,12 @@ class EniroSVMapService(MapService):
|
|||||||
self.url = path.replace(" ","%20")
|
self.url = path.replace(" ","%20")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
WarningDialog(_("Eniro map not available"),
|
WarningDialog(_("Eniro map not available"), \
|
||||||
_("Coordinates needed in Denmark") )
|
_("Coordinates needed in Denmark") )
|
||||||
self.url = ""
|
self.url = ""
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
WarningDialog(_("Eniro map not available for %s") % country,
|
WarningDialog(_("Eniro map not available for %s") % country, \
|
||||||
_("Only for Sweden and Denmark") )
|
_("Only for Sweden and Denmark") )
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user