Fixed #34572 -- Added support for GDAL 3.7.

Co-authored-by: Michael Howitz <mh@gocept.com>
This commit is contained in:
Mariusz Felisiak 2023-06-30 06:03:08 +02:00 committed by GitHub
parent a40b0103bc
commit 953f29f700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 18 deletions

View File

@ -22,6 +22,7 @@ if lib_path:
elif os.name == "nt": elif os.name == "nt":
# Windows NT shared libraries # Windows NT shared libraries
lib_names = [ lib_names = [
"gdal307",
"gdal306", "gdal306",
"gdal305", "gdal305",
"gdal304", "gdal304",
@ -36,6 +37,7 @@ elif os.name == "posix":
lib_names = [ lib_names = [
"gdal", "gdal",
"GDAL", "GDAL",
"gdal3.7.0",
"gdal3.6.0", "gdal3.6.0",
"gdal3.5.0", "gdal3.5.0",
"gdal3.4.0", "gdal3.4.0",

View File

@ -1844,8 +1844,8 @@ Key Default Usage
converted to the correct string format upon creation. converted to the correct string format upon creation.
The following example uses some of the options available for the The following example uses some of the options available for the
`GTiff driver`__. The result is a compressed signed byte raster with an `GTiff driver`__. The result is a compressed raster with an internal tiling
internal tiling scheme. The internal tiles have a block size of 23 by 23: scheme. The internal tiles have a block size of 23 by 23:
.. code-block:: pycon .. code-block:: pycon
@ -1859,7 +1859,6 @@ Key Default Usage
... "nr_of_bands": 1, ... "nr_of_bands": 1,
... "papsz_options": { ... "papsz_options": {
... "compress": "packbits", ... "compress": "packbits",
... "pixeltype": "signedbyte",
... "tiled": "yes", ... "tiled": "yes",
... "blockxsize": 23, ... "blockxsize": 23,
... "blockysize": 23, ... "blockysize": 23,

View File

@ -5,16 +5,16 @@ Installing Geospatial libraries
GeoDjango uses and/or provides interfaces for the following open source GeoDjango uses and/or provides interfaces for the following open source
geospatial libraries: geospatial libraries:
======================== ==================================== ================================ ====================================== ======================== ==================================== ================================ ===========================================
Program Description Required Supported Versions Program Description Required Supported Versions
======================== ==================================== ================================ ====================================== ======================== ==================================== ================================ ===========================================
:doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.11, 3.10, 3.9, 3.8 :doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.11, 3.10, 3.9, 3.8
`PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x `PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x
:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.4 :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.4
:doc:`GeoIP <../geoip2>` IP-based geolocation library No 2 :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.3, 3.2, 3.1, 3.0, 2.5 `PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.3, 3.2, 3.1, 3.0, 2.5
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3 `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3
======================== ==================================== ================================ ====================================== ======================== ==================================== ================================ ===========================================
Note that older or more recent versions of these libraries *may* also work Note that older or more recent versions of these libraries *may* also work
totally fine with GeoDjango. Your mileage may vary. totally fine with GeoDjango. Your mileage may vary.
@ -33,6 +33,7 @@ totally fine with GeoDjango. Your mileage may vary.
GDAL 3.4.0 2021-11-04 GDAL 3.4.0 2021-11-04
GDAL 3.5.0 2022-05-13 GDAL 3.5.0 2022-05-13
GDAL 3.6.0 2022-11-03 GDAL 3.6.0 2022-11-03
GDAL 3.7.0 2023-05-10
PostGIS 2.5.0 2018-09-23 PostGIS 2.5.0 2018-09-23
PostGIS 3.0.0 2019-10-20 PostGIS 3.0.0 2019-10-20
PostGIS 3.1.0 2020-12-18 PostGIS 3.1.0 2020-12-18

View File

@ -179,6 +179,8 @@ Minor features
* :ref:`GIS aggregates <gis-aggregation-functions>` now support the ``filter`` * :ref:`GIS aggregates <gis-aggregation-functions>` now support the ``filter``
argument. argument.
* Added support for GDAL 3.7.
:mod:`django.contrib.messages` :mod:`django.contrib.messages`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -6,7 +6,7 @@ import zipfile
from pathlib import Path from pathlib import Path
from unittest import mock from unittest import mock
from django.contrib.gis.gdal import GDALRaster, SpatialReference from django.contrib.gis.gdal import GDAL_VERSION, GDALRaster, SpatialReference
from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.raster.band import GDALBand from django.contrib.gis.gdal.raster.band import GDALBand
from django.contrib.gis.shortcuts import numpy from django.contrib.gis.shortcuts import numpy
@ -415,9 +415,19 @@ class GDALRasterTests(SimpleTestCase):
# Check physically if compression worked. # Check physically if compression worked.
self.assertLess(os.path.getsize(compressed.name), os.path.getsize(self.rs.name)) self.assertLess(os.path.getsize(compressed.name), os.path.getsize(self.rs.name))
# Create file-based raster with options from scratch. # Create file-based raster with options from scratch.
papsz_options = {
"compress": "packbits",
"blockxsize": 23,
"blockysize": 23,
}
if GDAL_VERSION < (3, 7):
datatype = 1
papsz_options["pixeltype"] = "signedbyte"
else:
datatype = 14
compressed = GDALRaster( compressed = GDALRaster(
{ {
"datatype": 1, "datatype": datatype,
"driver": "tif", "driver": "tif",
"name": rstfile.name, "name": rstfile.name,
"width": 40, "width": 40,
@ -432,12 +442,7 @@ class GDALRasterTests(SimpleTestCase):
"nodata_value": 255, "nodata_value": 255,
} }
], ],
"papsz_options": { "papsz_options": papsz_options,
"compress": "packbits",
"pixeltype": "signedbyte",
"blockxsize": 23,
"blockysize": 23,
},
} }
) )
# Check if options used on creation are stored in metadata. # Check if options used on creation are stored in metadata.
@ -448,8 +453,11 @@ class GDALRasterTests(SimpleTestCase):
compressed.metadata["IMAGE_STRUCTURE"]["COMPRESSION"], compressed.metadata["IMAGE_STRUCTURE"]["COMPRESSION"],
"PACKBITS", "PACKBITS",
) )
self.assertEqual(compressed.bands[0].datatype(), datatype)
if GDAL_VERSION < (3, 7):
self.assertEqual( self.assertEqual(
compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"], "SIGNEDBYTE" compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"],
"SIGNEDBYTE",
) )
self.assertIn("Block=40x23", compressed.info) self.assertIn("Block=40x23", compressed.info)