Skip to content

Commit

Permalink
Fixed dimensionality of Feature and Tile types
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 25, 2016
1 parent b3fccbf commit 72a6a7b
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions geoviews/element/geo.py
Expand Up @@ -46,6 +46,8 @@ class _Element(Element2D):
coordinate system of the data. Inferred automatically
when _Element wraps cartopy Feature object.""")

kdims = param.List(default=[Dimension('Longitude'), Dimension('Latitude')])

def __init__(self, data, **kwargs):
crs = None
crs_data = data.data if isinstance(data, Dataset) else data
Expand Down Expand Up @@ -75,24 +77,36 @@ def clone(self, data=None, shared_data=True, new_type=None,
*args, **overrides)


class Feature(_Element):
class _GeoFeature(_Element):
"""
Baseclass for geographic types without their own data.
"""

_auxiliary_component = True

def dimension_values(self, dim):
"""
_GeoFeature types do not contain actual data.
"""
return []


class Feature(_GeoFeature):
"""
A Feature represents a geographical feature
specified as a cartopy Feature type.
"""

group = param.String(default='Feature')

_auxiliary_component = True

def __init__(self, data, **params):
if not isinstance(data, cFeature):
raise TypeError('%s data has to be an cartopy Feature type'
% type(data).__name__)
super(Feature, self).__init__(data, **params)


class WMTS(_Element):
class WMTS(_GeoFeature):
"""
The WMTS Element represents a Web Map Tile Service
specified as a tuple of the API URL and
Expand All @@ -102,25 +116,21 @@ class WMTS(_Element):

layer = param.String(doc="The layer on the tile service")

_auxiliary_component = True

def __init__(self, data, **params):
if not isinstance(data, util.basestring):
raise TypeError('%s data has to be a tile service URL'
% type(data).__name__)
super(WMTS, self).__init__(data, **params)


class Tiles(_Element):
class Tiles(_GeoFeature):
"""
Tiles represents an image tile source to dynamically
load data from depending on the zoom level.
"""

group = param.String(default='Tiles')

_auxiliary_component = True

def __init__(self, data, **params):
if not isinstance(data, cGoogleTiles):
raise TypeError('%s data has to be a cartopy GoogleTiles type'
Expand All @@ -134,8 +144,6 @@ class Points(_Element, Dataset):
an associated cartopy coordinate-reference system.
"""

kdims = param.List(default=['longitude', 'latitude'])

group = param.String(default='Points')


Expand All @@ -146,8 +154,6 @@ class LineContours(_Element, Dataset):
into one or more line contours.
"""

kdims = param.List(default=[Dimension('x'), Dimension('y')])

vdims = param.List(default=[Dimension('z')], bounds=(1, 1))

group = param.String(default='LineContours')
Expand All @@ -169,8 +175,6 @@ class Image(_Element, Dataset):
some associated coordinates.
"""

kdims = param.List(default=[Dimension('x'), Dimension('y')])

vdims = param.List(default=[Dimension('z')], bounds=(1, 1))

group = param.String(default='Image')
Expand Down

0 comments on commit 72a6a7b

Please sign in to comment.