Second fixed a minor bug.

svn: r13690
This commit is contained in:
Peter Landgren 2009-11-29 19:59:59 +00:00
parent 611a6f2e66
commit d4081db69f

View File

@ -18,8 +18,7 @@
# 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
""" """
@ -36,7 +35,6 @@ from gettext import gettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gen.plug import PluginManager
from libmapservice import MapService from libmapservice import MapService
from QuestionDialog import WarningDialog from QuestionDialog import WarningDialog
@ -121,17 +119,12 @@ 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) country in MAP_NAMES_DENMARK) and (country != "")
# Now check if country is defined # if no country given, check if we might be in the vicinity defined by
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)
if latitude == None or longitude == None: if latitude is None or longitude is None:
coord_ok = False coord_ok = False
else: else:
latitude = float(latitude) latitude = float(latitude)
@ -145,12 +138,15 @@ 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
if coord_ok: if coord_ok:
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 # Set zoom level to 5 if Sweden/Denmark, others 3
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!
@ -174,20 +170,6 @@ class EniroSVMapService(MapService):
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") )
return return
#------------------------------------------------------------------------
#
# Register map service
#
#------------------------------------------------------------------------
PluginManager.get_instance().register_mapservice(
name = 'EniroMaps',
mapservice = EniroSVMapService(),
translated_name = _("EniroMaps"),
status = _("Stable"),
tooltip= _("Opens 'kartor.eniro.se' for places in Denmark and Sweden"),
author_name="Peter Landgren",
author_email="peter.talken@telia.com"
)