geometalab / Vector-Tiles-Reader-QGIS-Plugin

Vector Tiles Reader QGIS-Plugin - QGIS Python plugin which reads Mapbox Vector Tiles from a server, a local MBTiles file or a directory
http://plugins.qgis.org/plugins/vector_tiles_reader/
GNU General Public License v2.0
148 stars 30 forks source link

QgsCsException occurs when plugin dialog first opened #254

Open tomchadwin opened 4 years ago

tomchadwin commented 4 years ago
Traceback (most recent call last):
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 356, in _on_zoom_change
    self._update_nr_of_tiles(zoom)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 359, in _update_nr_of_tiles
    bounds = self._get_visible_extent_as_tile_bounds(zoom=zoom)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 662, in _get_visible_extent_as_tile_bounds
    tile_bounds = get_tile_bounds(zoom, extent=bounds, scheme=scheme, source_crs=str(source_crs))
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\tile_helper.py", line 213, in get_tile_bounds
    xy_max = latlon_to_tile(zoom=zoom, lat=lat_max, lng=lng_max, source_crs=source_crs, scheme=scheme)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\tile_helper.py", line 142, in latlon_to_tile
    lng, lat = convert_coordinate(source_crs=source_crs, target_crs="epsg:3857", lat=lat, lng=lng)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\tile_helper.py", line 162, in convert_coordinate
    x, y = xform.transform(QgsPointXY(lng, lat))
_core.QgsCsException: forward transform of
(-1.582293, 1.782405)
PROJ:  +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 +to  +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
Error: latitude or longitude exceeded limits

Canvas was EPSG:4326, and I was zoomed a long way out above Canada. Sorry not to have more precise details.

QGIS 3.8.3 VTR 3.1.0

mnboos commented 4 years ago

Thanks for the ticket Tom. What kind of source did you use?

tomchadwin commented 4 years ago

A server.

tomchadwin commented 4 years ago

Slightly different error, triggered by the same conditions - canvas is zoomed way out to world level:

ValueError: cannot convert float NaN to integer 
Traceback (most recent call last):
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 356, in _on_zoom_change
    self._update_nr_of_tiles(zoom)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 359, in _update_nr_of_tiles
    bounds = self._get_visible_extent_as_tile_bounds(zoom=zoom)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\vtr_plugin.py", line 662, in _get_visible_extent_as_tile_bounds
    tile_bounds = get_tile_bounds(zoom, extent=bounds, scheme=scheme, source_crs=str(source_crs))
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\tile_helper.py", line 212, in get_tile_bounds
    xy_min = latlon_to_tile(zoom=zoom, lat=lat_min, lng=lng_min, source_crs=source_crs, scheme=scheme)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\tile_helper.py", line 145, in latlon_to_tile
    col, row = gm.MetersToTile(mx=lng, my=lat, zoom=zoom)  # GlobalMercator returns in TMS scheme here
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\global_map_tiles.py", line 227, in MetersToTile
    return self.PixelsToTile(px, py)
  File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\plugin\util\global_map_tiles.py", line 213, in PixelsToTile
    tx = int(math.ceil(px / float(self.tileSize)) - 1)
ValueError: cannot convert float NaN to integer

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.8.3-Zanzibar Zanzibar, 685d8b15d2 

Occurs as soon as VTR button clicked and dialog appears. To clarify, no VTR layers are on the canvas, just a SHP.