diff --git a/metadata.txt b/metadata.txt index 3600228..09b4555 100644 --- a/metadata.txt +++ b/metadata.txt @@ -10,9 +10,9 @@ description=Reader (short VT reader) which reads Vector Tiles from various prede about=Plugin which reads vector tiles according to Mapbox' Vector Tiles specification as QGIS layers in a group. Styled vector tiles are typically used as high quality base maps. Sources can be an internet server, an MBTiles file or a directory of files. If an Mapbox GL JSON style is configured, the style is (partially) converted to QGIS styles. The plugin has connections already configured for the following providers: * OpenMapTiles.com with OSM Bright MB GL style (default) - * Mapcat.com with Mapcat style + * Nextzen.org This Python plugin uses prebuilt C++ binaries for performance reasons. -version=2.0.7 +version=2.1.0 author=Martin Boos email=geometalab@gmail.com @@ -22,6 +22,8 @@ email=geometalab@gmail.com # Uncomment the following line and add your changelog: changelog= + ---2.1.0--- + * New predefined connection 'Nextzen.org' added ---2.0.7--- * Bugfix: Make sure response of webrequest is str and not bytes if url is for a json file ---2.0.6--- @@ -117,50 +119,6 @@ changelog= * UI changed: file can be opened directly without adding as connection * Experimental flag removed * Bugfixes & improvements - ---0.14.0--- - * Tile loading behaviour improved - * Bugfixes & improvements - ---0.13.1--- - * Bugfix: Too many tiles may be loaded under some circumstances - ---0.13.0--- - * Export functionality added - * Bugfixes & stability improvements - ---0.12.0--- - * Decoding performance improved: all available CPU cores will be used - * Feature merging improved: only merge features of the same class - ---0.11.0--- - * Buttons added to reset options to predefined defaults - * Feature merging fixed - * Tiles will be loaded in the middle of the current extent, not at the borders - * Expected number of tiles for current extent is shown in connections dialog - * Predefined OMT style improved - ---0.10.0--- - * Plugin uses QGIS proxies if configured - * Bugfixes - * Error handling improved - ---0.9.0--- - * Bugfixes - * Loading performance improved - * Caching implemented - * Mask layer can be loaded - ---0.8.0--- - * Files connections now be handled with the former server connections dialog - * Reload feature added - * Bugfixes and stability improvements - ---0.7.1--- - * Bugfixes - ---0.7.0--- - * Predefined server connection included - * Loading performance improved - * Styling improved - ---0.6.1--- - * Server connections improved - ---0.6.0--- - * Server connections CRS handling improved - ---0.5.0--- - * Stability improved - * Server connections added - * Loading of tiles can be cancelled # Tags are comma separated with spaces allowed tags=vector tiles, tiles, mbtiles, mapbox, vector, basemap diff --git a/ui/dialogs.py b/ui/dialogs.py index 84f972d..9b53d0a 100644 --- a/ui/dialogs.py +++ b/ui/dialogs.py @@ -111,11 +111,11 @@ class ConnectionsDialog(QDialog, Ui_DlgConnections): "style": "https://api.mapcat.com/api/mapinit/vector?api_key={token}", "token": "VmKNOOCry7SE4c8FyacQ1KxojeWzY1W2aFS0TADq" }, - # _NEXTZEN: { - # "name": _NEXTZEN, - # "url": "https://tile.nextzen.org/tilezen/vector/v1/512/all/tilejson.mvt.json?api_key={token}", - # "token": "80xAN5o0QuyFrcPVVIieTA" - # } + _NEXTZEN: { + "name": _NEXTZEN, + "url": "https://tile.nextzen.org/tilezen/vector/v1/512/all/tilejson.mvt.json?api_key={token}", + "token": "80xAN5o0QuyFrcPVVIieTA" + } } _CONNECTIONS_TAB = "selected_connections_tab" diff --git a/util/network_helper.py b/util/network_helper.py index 38015b6..436baab 100644 --- a/util/network_helper.py +++ b/util/network_helper.py @@ -1,5 +1,6 @@ from .log_helper import warn, info, remove_key from .vtr_2to3 import * +from time import sleep def url_exists(url): @@ -52,6 +53,7 @@ def load_tiles_async(urls_with_col_and_row, on_progress_changed=None, cancelling all_results = [] cancelling = False while not all_finished: + sleep(0.075) cancelling = cancelling_func and cancelling_func() if cancelling: break @@ -63,7 +65,7 @@ def load_tiles_async(urls_with_col_and_row, on_progress_changed=None, cancelling finished_tiles.add(tile_coord) error = reply.error() if error: - info("Error during network request: {}, {}", error, reply.url()) + warn("Error during network request: {}, {}", error, remove_key(reply.url().toDisplayString())) else: content = reply.readAll().data() results.append((tile_coord, content)) diff --git a/util/tile_source.py b/util/tile_source.py index 33886a9..f2af4ab 100644 --- a/util/tile_source.py +++ b/util/tile_source.py @@ -161,6 +161,9 @@ def crs(self): def load_tiles(self, zoom_level, tiles_to_load, max_tiles=None): self._cancelling = False base_url = self.json.tiles()[0] + if "{s}" in base_url: + info("Special treatment for Nextzen url...") + urls = [] if max_tiles and len(tiles_to_load) > max_tiles: tiles_to_load = get_tiles_from_center(max_tiles, tiles_to_load, should_cancel_func=lambda: self._cancelling) @@ -170,14 +173,17 @@ def load_tiles(self, zoom_level, tiles_to_load, max_tiles=None): api_key = "" if "api_key" in list(parameters.keys()): api_key = parameters["api_key"][0] - for t in tiles_to_load: + nextzen_servers = ["a", "b", "c", "d"] + for i, t in enumerate(tiles_to_load): col = t[0] row = t[1] load_url = base_url\ .replace("{z}", str(int(zoom_level)))\ .replace("{x}", str(int(col)))\ .replace("{y}", str(int(row)))\ - .replace("{api_key}", str(api_key)) + .replace("{api_key}", str(api_key))\ + .replace("{s}", nextzen_servers[divmod(i, len(nextzen_servers))[1]]) # nextzen server placeholder + load_url += "?api_key={}".format(api_key) urls.append((load_url, col, row)) self.max_progress_changed.emit(len(urls))