Skip to content

Commit

Permalink
Recognize different MercatorTileSource formats
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 21, 2018
1 parent b0509f1 commit 140e70b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions geoviews/element/geo.py
Expand Up @@ -23,9 +23,9 @@
Cube = None

try:
from bokeh.models import WMTSTileSource
from bokeh.models import MercatorTileSource
except:
WMTSTileSource = None
MercatorTileSource = None

try:
from owslib.wmts import WebMapTileService
Expand Down Expand Up @@ -154,7 +154,7 @@ class WMTS(_GeoFeature):
layer = param.String(doc="The layer on the tile service")

def __init__(self, data, kdims=None, vdims=None, **params):
if ((WMTSTileSource and isinstance(data, WMTSTileSource)) or
if ((MercatorTileSource and isinstance(data, MercatorTileSource)) or
(GoogleTiles and isinstance(data, GoogleTiles))):
data = data.url
elif WebMapTileService and isinstance(data, WebMapTileService):
Expand Down
12 changes: 10 additions & 2 deletions geoviews/plotting/bokeh/__init__.py
Expand Up @@ -2,7 +2,7 @@

import param
import shapely.geometry
from bokeh.models import WMTSTileSource
from bokeh.models import WMTSTileSource, BBoxTileSource, QUADKEYTileSource

from holoviews import Store, Overlay, NdOverlay
from holoviews.core import util
Expand Down Expand Up @@ -43,7 +43,15 @@ def get_data(self, element, ranges, style):
if not isinstance(element.data, util.basestring):
SkipRendering("WMTS element data must be a URL string, "
"bokeh cannot render %r" % element.data)
return {}, {'tile_source': WMTSTileSource(url=element.data)}, style
if '{Q}' in element.data:
tile_source = QUADKEYTileSource
elif all(kw in element.data for kw in ('{XMIN}', '{XMAX}', '{YMIN}', '{YMAX}')):
tile_source = BBoxTileSource
elif all(kw in element.data for kw in ('{X}', '{Y}', '{Z}')):
tile_source = WMTSTileSource
else:
raise ValueError('Tile source URL format not recognized.')
return {}, {'tile_source': tile_source(url=element.data)}, style

def _update_glyph(self, renderer, properties, mapping, glyph):
allowed_properties = glyph.properties()
Expand Down

0 comments on commit 140e70b

Please sign in to comment.