From 7e15795bf06d362f20257d2e9db378ba8940dc39 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 3 Mar 2020 15:25:19 +0100 Subject: Fixed #30489 -- Fixed RasterField deserialization with pixeltype flags. Thanks Ivor Bosloper for the original patch. --- tests/gis_tests/rasterapp/test_rasterfield.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/gis_tests/rasterapp/test_rasterfield.py b/tests/gis_tests/rasterapp/test_rasterfield.py index 63a6325135..2a6fe09f6a 100644 --- a/tests/gis_tests/rasterapp/test_rasterfield.py +++ b/tests/gis_tests/rasterapp/test_rasterfield.py @@ -8,7 +8,7 @@ from django.contrib.gis.geos import GEOSGeometry from django.contrib.gis.measure import D from django.contrib.gis.shortcuts import numpy from django.db import connection -from django.db.models import Q +from django.db.models import F, Func, Q from django.test import TransactionTestCase, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext @@ -51,6 +51,26 @@ class RasterFieldTest(TransactionTestCase): qs = RasterModel.objects.all() qs[0].rast.bands[0].data() + def test_deserialize_with_pixeltype_flags(self): + no_data = 3 + rast = GDALRaster({ + 'srid': 4326, + 'origin': [0, 0], + 'scale': [-1, 1], + 'skew': [0, 0], + 'width': 1, + 'height': 1, + 'nr_of_bands': 1, + 'bands': [{'data': [no_data], 'nodata_value': no_data}], + }) + r = RasterModel.objects.create(rast=rast) + RasterModel.objects.filter(pk=r.pk).update( + rast=Func(F('rast'), function='ST_SetBandIsNoData'), + ) + r.refresh_from_db() + self.assertEquals(r.rast.bands[0].data(), [[no_data]]) + self.assertEquals(r.rast.bands[0].nodata_value, no_data) + def test_model_creation(self): """ Test RasterField through a test model. -- cgit v1.3