Improved test for valid country.

svn: r12407
This commit is contained in:
Peter Landgren 2009-04-08 12:36:47 +00:00
parent 5acd0f70c8
commit fc9759c177

View File

@ -18,7 +18,8 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
#
""" """
Eniro Sweden (Denmark) map service plugin. Opens place in kartor.eniro.se Eniro Sweden (Denmark) map service plugin. Opens place in kartor.eniro.se
""" """
@ -120,8 +121,13 @@ class EniroSVMapService(MapService):
# Change country to upper case # Change country to upper case
country = place.get_main_location().get_country().upper().strip() 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) and (country != "") country in MAP_NAMES_DENMARK)
# if no country given, check if we might be in the vicinity defined by # Now check if country is defined
if not country_given:
WarningDialog(_("Eniro map not available for %s") % country, \
_("Only for Sweden and Denmark") )
return
# Chech if we are 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
latitude, longitude = self._lat_lon(place) latitude, longitude = self._lat_lon(place)
@ -139,8 +145,7 @@ class EniroSVMapService(MapService):
msg2 = msg2 % (54.55, 69.05, 8.05, 24.15) msg2 = msg2 % (54.55, 69.05, 8.05, 24.15)
WarningDialog(_("Eniro map not available"), msg2 ) WarningDialog(_("Eniro map not available"), msg2 )
return return
# Now check if country is defined if not coord_ok:
if not (country_given or coord_ok):
WarningDialog(_("Eniro map not available"), WarningDialog(_("Eniro map not available"),
_("Latitude and longitude,\n" \ _("Latitude and longitude,\n" \
"or street and city needed") ) "or street and city needed") )
@ -149,10 +154,8 @@ 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 # Set zoom level to 5 if Sweden/Denmark
zoom = 5 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=%i&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!
@ -173,9 +176,6 @@ class EniroSVMapService(MapService):
_("Coordinates needed in Denmark") ) _("Coordinates needed in Denmark") )
self.url = "" self.url = ""
return return
else:
WarningDialog(_("Eniro map not available for %s") % country, \
_("Only for Sweden and Denmark") )
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -187,7 +187,7 @@ PluginManager.get_instance().register_mapservice(
mapservice = EniroSVMapService(), mapservice = EniroSVMapService(),
translated_name = _("EniroMaps"), translated_name = _("EniroMaps"),
status = _("Stable"), status = _("Stable"),
tooltip= _("Opens on kartor.eniro.se"), tooltip= _("Opens 'kartor.eniro.se' for places in Denmark and Sweden"),
author_name="Peter Landgren", author_name="Peter Landgren",
author_email="peter.talken@telia.com" author_email="peter.talken@telia.com"
) )