diff --git a/gramps/plugins/lib/maps/constants.py b/gramps/plugins/lib/maps/constants.py index a26382fbdf1..d1e12ba4abf 100644 --- a/gramps/plugins/lib/maps/constants.py +++ b/gramps/plugins/lib/maps/constants.py @@ -63,7 +63,7 @@ YAHOO_STREET = 14 YAHOO_SATELLITE = 15 YAHOO_HYBRID = 16 -PERSONAL = 30 +# PERSONAL = 30 TILES_PATH = { OPENSTREETMAP: "openstreetmap", @@ -82,7 +82,7 @@ YAHOO_STREET: "yahoostreet", YAHOO_SATELLITE: "yahoosat", YAHOO_HYBRID: "yahoohybrid", - PERSONAL: "personal", + # PERSONAL: "personal", } MAP_TITLE = { @@ -102,7 +102,7 @@ YAHOO_STREET: "Yahoo street", YAHOO_SATELLITE: "Yahoo sat", YAHOO_HYBRID: "Yahoo hybrid", - PERSONAL: "Personal map", + # PERSONAL: "Personal map", } MAP_TYPE = { @@ -116,5 +116,5 @@ VIRTUAL_EARTH_STREET: osmgpsmap.MapSource_t.VIRTUAL_EARTH_STREET, VIRTUAL_EARTH_SATELLITE: osmgpsmap.MapSource_t.VIRTUAL_EARTH_SATELLITE, VIRTUAL_EARTH_HYBRID: osmgpsmap.MapSource_t.VIRTUAL_EARTH_HYBRID, - PERSONAL: None, + # PERSONAL: None, } diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 8f733143eaf..5aace195828 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -127,7 +127,7 @@ class GeoGraphyView(OsmGps, NavigationView): ("geography.map_service", constants.OPENSTREETMAP), ("geography.max_places", 5000), ("geography.use-keypad", True), - ("geography.personal-map", ""), + # ("geography.personal-map", ""), ) def __init__(self, title, pdata, dbstate, uistate, bm_type, nav_group): @@ -169,8 +169,8 @@ def __init__(self, title, pdata, dbstate, uistate, bm_type, nav_group): parent=uistate.window, ) - if not config.is_set("geography.personal-map"): - config.set("geography.personal-map", "") + # if not config.is_set("geography.personal-map"): + # config.set("geography.personal-map", "") self.uistate = uistate self.uistate.connect("font-changed", self.font_changed) @@ -1462,34 +1462,35 @@ def map_options(self, configdialog): "geography.use-keypad", extra_callback=self.update_shortcuts, ) - label = configdialog.add_text( - grid, - _( - "If you want to use a specific map provider," - " You can set the following field to the" - " provider's url.\ni.e:\n" - "http://tile.stamen.com/toner/#Z/#X/#Y.png\n" - "http://tile.stamen.com/terrain/#Z/#X/#Y.jpg\n" - "http://tile.stamen.com/watercolor/#Z/#X/#Y.jpg\n" - "http://tile.xn--pnvkarte-m4a.de/tilegen/#Z/#X/#Y.png\n" - ), - 6, - line_wrap=False, - ) - # set the possibility to copy/paste the urls - label.set_selectable(True) - start = label.get_text().find("http") - end = label.get_text().find("http", start + 1) - label.select_region(start, end) - url = configdialog.add_entry( - grid, - _("Personal map"), - 7, - "geography.personal-map", - self.choosen_map, - ) - if config.get("geography.personal-map") != "": - url.set_text(config.get("geography.personal-map")) + # label = configdialog.add_text( + # grid, + # _( + # "If you want to use a specific map provider," + # " You can set the following field to the" + # " provider's url.\ni.e:\n" + # "http://tile.stadiamaps.com/tiles/stamen_toner/#{z}/#{x}/#{y}{r}.png?api_key=YOUR-API-KEY\n" + # "http://tile.stadiamaps.com/tiles/stamen_toner_lite/#{z}/#{x}/#{y}{r}.png?api_key=YOUR-API-KEY\n" + # "http://tile.stadiamaps.com/tiles/stamen_terrain/#{z}/#{x}/#{y}{r}.png?api_key=YOUR-API-KEY\n" + # "http://tile.stadiamaps.com/tiles/stamen_watercolor/#{z}/#{x}/#{y}{r}.jpg?api_key=YOUR-API-KEY\n" + # "http://tile.xn--pnvkarte-m4a.de/tilegen/#Z/#X/#Y.png\n" + # ), + # 6, + # line_wrap=False, + # ) + # # set the possibility to copy/paste the urls + # label.set_selectable(True) + # start = label.get_text().find("http") + # end = label.get_text().find("http", start + 1) + # label.select_region(start, end) + # url = configdialog.add_entry( + # grid, + # _("Personal map"), + # 7, + # "geography.personal-map", + # self.choosen_map, + # ) + # if config.get("geography.personal-map") != "": + # url.set_text(config.get("geography.personal-map")) return _("The map"), grid def choosen_map(self, *obj): @@ -1497,18 +1498,18 @@ def choosen_map(self, *obj): Save the provider map path in the config section. """ map_source = obj[0].get_text() - name = constants.TILES_PATH[constants.PERSONAL] - config.set("geography.personal-map", map_source) - self.clear_map(None, name) + # name = constants.TILES_PATH[constants.PERSONAL] + # config.set("geography.personal-map", map_source) + # self.clear_map(None, name) if map_source == "": config.set("geography.map_service", constants.OPENSTREETMAP) self.change_map(self.osm, config.get("geography.map_service")) self.reload_tiles() return - if map_source != config.get("geography.personal-map"): - config.set("geography.map_service", constants.PERSONAL) - self.change_new_map(name, map_source) - self.reload_tiles() + # if map_source != config.get("geography.personal-map"): + # config.set("geography.map_service", constants.PERSONAL) + # self.change_new_map(name, map_source) + # self.reload_tiles() def set_tilepath(self, *obj): """ diff --git a/gramps/plugins/lib/maps/osmgps.py b/gramps/plugins/lib/maps/osmgps.py index 27c7bfe167f..78fdd251b7d 100644 --- a/gramps/plugins/lib/maps/osmgps.py +++ b/gramps/plugins/lib/maps/osmgps.py @@ -169,15 +169,15 @@ def change_map(self, obj, map_type): """ Change the current map """ - if map_type == constants.PERSONAL: - map_source = config.get("geography.personal-map") - if map_source == "": - return - name = constants.TILES_PATH[map_type] - self.change_new_map(name, map_source) - config.set("geography.map_service", map_type) - self.current_map = map_type - return + # if map_type == constants.PERSONAL: + # map_source = config.get("geography.pers# onal-map") + # if map_source == "": + # return + # name = constants.TILES_PATH[map_type] + # self.change_new_map(name, map_source) + # config.set("geography.map_service", map_type) + # self.current_map = map_type + # return if obj is not None: self.osm.layer_remove_all() self.osm.image_remove_all() @@ -201,10 +201,11 @@ def change_map(self, obj, map_type): if 0: self.osm = DummyMapNoGpsPoint() else: - if map_type == constants.PERSONAL: - self.osm = osmgpsmap.Map(repo_uri=map_source) - else: - self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) + # if map_type == constants.PERSONAL: + # self.osm = osmgpsmap.Map(repo_uri=map_source) + # else: + # self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) + self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) if http_proxy: self.osm.set_property("proxy_uri", http_proxy) self.osm.set_property("tile_cache", tiles_path) @@ -266,10 +267,11 @@ def change_new_map(self, name, map_source): self.osm = DummyMapNoGpsPoint() else: map_type = int(config.get("geography.map_service")) - if map_type == constants.PERSONAL: - self.osm = osmgpsmap.Map(repo_uri=map_source) - else: - self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) + # if map_type == constants.PERSONAL: + # self.osm = osmgpsmap.Map(repo_uri=map_source) + # else: + # self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) + self.osm = osmgpsmap.Map(map_source=constants.MAP_TYPE[map_type]) if http_proxy: self.osm.set_property("proxy_uri", http_proxy) self.osm.set_property("tile_cache", tiles_path) @@ -314,12 +316,14 @@ def reload_tiles(self): pt2 = bbox[1] self.zoom = config.get("geography.zoom") tile_size = float(256) - if map_idx != constants.PERSONAL: - # get the file extension depending on the map provider - img_format = self.osm.source_get_image_format(map_idx) - else: - filename = config.get("geography.personal-map") - img_format = os.path.splitext(filename)[1] + # if map_idx != constants.PERSONAL: + # # get the file extension depending on the map provider + # img_format = self.osm.source_get_image_format(map_idx) + # else: + # filename = config.get("geography.personal-map") + # img_format = os.path.splitext(filename)[1] + # get the file extension depending on the map provider + img_format = self.osm.source_get_image_format(map_idx) # calculate the number of images to download in rows and columns pt1_x = floor(lon2pixel(self.zoom, pt1.rlon, tile_size) / tile_size) pt1_y = floor(lat2pixel(self.zoom, pt1.rlat, tile_size) / tile_size) diff --git a/gramps/plugins/mapservices/openstreetmap.py b/gramps/plugins/mapservices/openstreetmap.py index 668adf7ccbf..29262cb0fea 100644 --- a/gramps/plugins/mapservices/openstreetmap.py +++ b/gramps/plugins/mapservices/openstreetmap.py @@ -62,6 +62,6 @@ def calc_url(self): return titledescr = place_displayer.display(self.database, place) - self.url = "http://nominatim.openstreetmap.org/" "search.php?q=%s" % "+".join( + self.url = "http://nominatim.openstreetmap.org/" "search?q=%s" % "+".join( titledescr.split() ) diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index cce2a9067a3..aee75275346 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -1983,8 +1983,10 @@ def __init__(self, name, dbase): self.__stamenopts = None self.__googleopts = None self.__googlemapkey = None + self.__stamenmapkey = None self.__olv = None self.googlemapkeyhelp = None + self.stamenmapkeyhelp = None self.__ancestortree = None self.__css = None self.__gallery = None @@ -2681,6 +2683,30 @@ def __add_place_map_options(self, menu): ) ) addopt("stamenopts", self.__stamenopts) + self.__stamenmapkey = StringOption(_("Stamen maps API key"), "") + self.__stamenmapkey.set_help( + _( + "The API key used for the Stamen maps.\n" + "This key is mandatory and must be valid" + ) + ) + if not config.is_set("paths.stamen-get-api-key"): + # The following will be used to change the URL if it changes without + # creating a patch. We will only need to change gramps.ini + config.register( + "paths.stamen-get-api-key", + "https://stadiamaps.com/stamen/onboarding", + ) + keyvalue = config.get("paths.stamen-get-api-key") + self.stamenmapkeyhelp = StringOption(_("How to get the API key"), keyvalue) + self.stamenmapkeyhelp.connect("value-changed", self.url_changed) + keytooltip = _( + "Copy and paste this value in your browser." + "\nThe Stamen maps service must be selected." + ) + self.stamenmapkeyhelp.set_help(keytooltip) + addopt("stamenmapkey", self.__stamenmapkey) + addopt("stamenmapkeyhelp", self.stamenmapkeyhelp) self.__placemap_options() @@ -3022,6 +3048,12 @@ def __placemap_options(self): else: self.__googlemapkey.set_available(False) self.googlemapkeyhelp.set_available(False) + if (place_active or family_active) and mapservice_opts == "StamenMap": + self.__stamenmapkey.set_available(True) + self.stamenmapkeyhelp.set_available(True) + else: + self.__stamenmapkey.set_available(False) + self.stamenmapkeyhelp.set_available(False) def url_changed(self): """