diff --git a/.travis.yml b/.travis.yml index 6686a1ca..42976a33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ virtualenv: before_install: - sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable - sudo apt-get update -qq - - sudo apt-get install -qq postgis gdal-bin libgdal-dev libgdal1 libgdal1-dev libpq-dev memcached python-pip python-mapnik + - sudo apt-get install -qq postgis gdal-bin libgdal-dev libgdal1 libgdal1-dev libpq-dev memcached python-pip - sudo apt-get install -qq python-nose python-imaging python-memcache python-gdal python-coverage python-werkzeug - ogrinfo --version - ogrinfo --formats diff --git a/TileStache/Goodies/VecTiles/client.py b/TileStache/Goodies/VecTiles/client.py index c17eadba..cd49475a 100644 --- a/TileStache/Goodies/VecTiles/client.py +++ b/TileStache/Goodies/VecTiles/client.py @@ -38,10 +38,15 @@ from gzip import GzipFile import logging -import mapnik from . import mvt, geojson +try: + from mapnik import PythonDatasource, Box2d +except ImportError: + # can still build documentation + PythonDatasource = object + # earth's diameter in meters diameter = 2 * pi * 6378137 @@ -146,7 +151,7 @@ def load_tile_features(lock, host, port, path_fmt, tiles, features): logging.debug('%d features in %s:%d%s' % (len(file_features), host, port, path)) features.extend(file_features) -class Datasource (mapnik.PythonDatasource): +class Datasource (PythonDatasource): ''' Mapnik datasource to read tiled vector data in GeoJSON or MVT formats. Sample usage in Mapnik configuration XML: @@ -180,8 +185,8 @@ def __init__(self, template): self.path = self.path.replace('{X}', '{x}').replace('{x}', '%(x)d') self.path = self.path.replace('{Y}', '{y}').replace('{y}', '%(y)d') - bbox = mapnik.Box2d(-diameter/2, -diameter/2, diameter/2, diameter/2) - mapnik.PythonDatasource.__init__(self, envelope=bbox) + bbox = Box2d(-diameter/2, -diameter/2, diameter/2, diameter/2) + PythonDatasource.__init__(self, envelope=bbox) def features(self, query): ''' @@ -199,4 +204,4 @@ def features(self, query): keys = [set(prop.keys()) for prop in props] keys = reduce(lambda a, b: a & b, keys) - return mapnik.PythonDatasource.wkb_features(keys=keys, features=features) + return PythonDatasource.wkb_features(keys=keys, features=features)