Skip to content

Commit

Permalink
Merge pull request #310 from girder/mapnik-only-one-path-call
Browse files Browse the repository at this point in the history
Only call getLargeImagePath once in the mapnik tilesource.
  • Loading branch information
manthey committed Oct 5, 2018
2 parents aeb98cd + ed8e2f9 commit 4f3ae29
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions server/tilesource/mapniksource.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class MapnikTileSource(FileTileSource):
def __init__(self, path, projection=None, style=None, unitsPerPixel=None, **kwargs):
super(MapnikTileSource, self).__init__(path, **kwargs)
self._bounds = {}
self.dataset = gdal.Open(self._getLargeImagePath())
self._path = self._getLargeImagePath()
self.dataset = gdal.Open(self._path)
self.tileSize = 256
self.tileWidth = self.tileSize
self.tileHeight = self.tileSize
Expand Down Expand Up @@ -415,13 +416,9 @@ def addStyle(self, m, layerSrs, extent):
lyr = mapnik.Layer('layer')
lyr.srs = layerSrs
if extent:
lyr.datasource = mapnik.Gdal(
base='', file=self._getLargeImagePath(),
band=band, extent=extent)
lyr.datasource = mapnik.Gdal(base=None, file=self._path, band=band, extent=extent)
else:
lyr.datasource = mapnik.Gdal(
base='', file=self._getLargeImagePath(),
band=band)
lyr.datasource = mapnik.Gdal(base=None, file=self._path, band=band)
lyr.styles.append('Raster Style')
m.layers.append(lyr)

Expand Down

0 comments on commit 4f3ae29

Please sign in to comment.