diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-03-03 15:25:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-03-05 09:44:44 +0100 |
| commit | 7e15795bf06d362f20257d2e9db378ba8940dc39 (patch) | |
| tree | 5e058c587b43ca37e7f95cb16891e8d42cacf5be /tests | |
| parent | 769cee525222bb155735aba31d6174d73c271f3c (diff) | |
Fixed #30489 -- Fixed RasterField deserialization with pixeltype flags.
Thanks Ivor Bosloper for the original patch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/rasterapp/test_rasterfield.py | 22 |
1 files changed, 21 insertions, 1 deletions
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. |
