Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work with newer python-mapnik #1550

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 1.29.1

### Improvements
- Improved zarr sink metadata handling ([#1508](../../pull/1508))

### Changes
- Work with newer python-mapnik ([#1550](../../pull/1550))

## 1.29.0

### Features
Expand Down
11 changes: 7 additions & 4 deletions sources/mapnik/large_image_source_mapnik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _addStyleToMap(self, m, layerSrs, colorizer=None, band=-1, extent=None,
sym = mapnik.RasterSymbolizer()
if colorizer is not None:
sym.colorizer = colorizer
rule.symbols.append(sym)
getattr(rule, 'symbols', getattr(rule, 'symbolizers', None)).append(sym)
style = mapnik.Style()
style.rules.append(rule)
if composite is not None:
Expand All @@ -286,8 +286,9 @@ def _addStyleToMap(self, m, layerSrs, colorizer=None, band=-1, extent=None,
if hasattr(self, '_netcdf') and isinstance(band, tuple):
gdalband = band[1]
gdalpath = self._netcdf['datasets'][band[0]]['name']
lyr.datasource = mapnik.Gdal(
base=None, file=gdalpath, band=gdalband, extent=extent, nodata=nodata)
params = dict(base=None, file=gdalpath, band=gdalband, extent=extent, nodata=nodata)
params = {k: v for k, v in params.items() if v is not None}
lyr.datasource = mapnik.Gdal(**params)
lyr.styles.append(styleName)
m.layers.append(lyr)

Expand Down Expand Up @@ -387,7 +388,9 @@ def getTile(self, x, y, z, **kwargs):
m.zoom_to_box(mapnik.Box2d(xmin, ymin, xmax, ymax))
img = mapnik.Image(self.tileWidth + overscan * 2, self.tileHeight + overscan * 2)
mapnik.render(m, img)
pilimg = PIL.Image.frombytes('RGBA', (img.width(), img.height()), img.tostring())
pilimg = PIL.Image.frombytes(
'RGBA', (img.width(), img.height()),
getattr(img, 'tostring', getattr(img, 'to_string', None))())
if overscan:
pilimg = pilimg.crop((1, 1, pilimg.width - overscan, pilimg.height - overscan))
return self._outputTile(pilimg, TILE_FORMAT_PIL, x, y, z, applyStyle=False, **kwargs)
Expand Down