diff options
| author | Daniel Wiesmann <daniel.wiesmann@gmail.com> | 2017-06-08 15:51:19 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-08 12:44:26 -0400 |
| commit | fe5e34a2954afdeaabbee80c762735acdd29a948 (patch) | |
| tree | fbc10f91b7d17f2410cd4c80793d228a5dd7d613 /django | |
| parent | 0c3c37a376bac149fe7e7e4b2696f8fb7990e2ab (diff) | |
Fixed #28288 -- Allowed passing papsz options to GDALRaster initialization.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/gdal/raster/source.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py index 609c9d6b46..e871fe4cf5 100644 --- a/django/contrib/gis/gdal/raster/source.py +++ b/django/contrib/gis/gdal/raster/source.py @@ -1,6 +1,6 @@ import json import os -from ctypes import addressof, byref, c_double, c_void_p +from ctypes import addressof, byref, c_char_p, c_double, c_void_p from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException @@ -92,6 +92,16 @@ class GDALRaster(GDALRasterBase): if 'srid' not in ds_input: raise GDALException('Specify srid for JSON or dict input.') + # Create null terminated gdal options array. + papsz_options = [] + for key, val in ds_input.get('papsz_options', {}).items(): + option = '{}={}'.format(key, val) + papsz_options.append(option.upper().encode()) + papsz_options.append(None) + + # Convert papszlist to ctypes array. + papsz_options = (c_char_p * len(papsz_options))(*papsz_options) + # Create GDAL Raster self._ptr = capi.create_ds( driver._ptr, @@ -100,7 +110,7 @@ class GDALRaster(GDALRasterBase): ds_input['height'], ds_input.get('nr_of_bands', len(ds_input.get('bands', []))), ds_input.get('datatype', 6), - None + byref(papsz_options), ) # Set band data if provided |
