1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #32670 -- Allowed GDALRasters to use any GDAL virtual filesystem.

This commit is contained in:
Jordi Castells
2021-04-14 16:07:36 +02:00
committed by Mariusz Felisiak
parent 028f10fac6
commit 205c36b58f
6 changed files with 91 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import os
import shutil
import struct
import tempfile
import zipfile
from unittest import mock
from django.contrib.gis.gdal import GDALRaster, SpatialReference
@@ -229,6 +230,17 @@ class GDALRasterTests(SimpleTestCase):
# The vsi buffer is None for rasters that are not vsi based.
self.assertIsNone(self.rs.vsi_buffer)
def test_vsi_vsizip_filesystem(self):
rst_zipfile = tempfile.NamedTemporaryFile(suffix='.zip')
with zipfile.ZipFile(rst_zipfile, mode='w') as zf:
zf.write(self.rs_path, 'raster.tif')
rst_path = '/vsizip/' + os.path.join(rst_zipfile.name, 'raster.tif')
rst = GDALRaster(rst_path)
self.assertEqual(rst.driver.name, self.rs.driver.name)
self.assertEqual(rst.name, rst_path)
self.assertIs(rst.is_vsi_based, True)
self.assertIsNone(rst.vsi_buffer)
def test_offset_size_and_shape_on_raster_creation(self):
rast = GDALRaster({
'datatype': 1,