From fc9759c177a2e11966dcab10d6390d346eb6a7a0 Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Wed, 8 Apr 2009 12:36:47 +0000 Subject: [PATCH] Improved test for valid country. svn: r12407 --- src/plugins/mapservices/eniroswedenmap.py | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/mapservices/eniroswedenmap.py b/src/plugins/mapservices/eniroswedenmap.py index e392bf185..eabcaec11 100644 --- a/src/plugins/mapservices/eniroswedenmap.py +++ b/src/plugins/mapservices/eniroswedenmap.py @@ -18,7 +18,8 @@ # along with this program; if not, write to the Free Software # 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 """ @@ -120,8 +121,13 @@ class EniroSVMapService(MapService): # Change country to upper case country = place.get_main_location().get_country().upper().strip() country_given = (country in MAP_NAMES_SWEDEN or \ - country in MAP_NAMES_DENMARK) and (country != "") - # if no country given, check if we might be in the vicinity defined by + country in MAP_NAMES_DENMARK) + # 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 # 8 3' 0" < long < 24 9' 0", 8.05 and 24.15 latitude, longitude = self._lat_lon(place) @@ -139,8 +145,7 @@ class EniroSVMapService(MapService): msg2 = msg2 % (54.55, 69.05, 8.05, 24.15) WarningDialog(_("Eniro map not available"), msg2 ) return - # Now check if country is defined - if not (country_given or coord_ok): + if not coord_ok: WarningDialog(_("Eniro map not available"), _("Latitude and longitude,\n" \ "or street and city needed") ) @@ -149,10 +154,8 @@ class EniroSVMapService(MapService): place_title = _build_title(place) place_city = _build_city(place) 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 - if not country_given: - zoom = 3 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" # Note x and y are swapped! @@ -173,9 +176,6 @@ class EniroSVMapService(MapService): _("Coordinates needed in Denmark") ) self.url = "" 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(), translated_name = _("EniroMaps"), status = _("Stable"), - tooltip= _("Opens on kartor.eniro.se"), + tooltip= _("Opens 'kartor.eniro.se' for places in Denmark and Sweden"), author_name="Peter Landgren", author_email="peter.talken@telia.com" )