Skip to content

Commit

Permalink
Fixed #34572 -- Added support for GDAL 3.7.
Browse files Browse the repository at this point in the history
Co-Authored-By: Michael Howitz <mh@gocept.com>
  • Loading branch information
felixxm and Michael Howitz committed Jun 30, 2023
1 parent a40b010 commit 25cb27d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
2 changes: 2 additions & 0 deletions django/contrib/gis/gdal/libgdal.py
Expand Up @@ -22,6 +22,7 @@
elif os.name == "nt":
# Windows NT shared libraries
lib_names = [
"gdal307",
"gdal306",
"gdal305",
"gdal304",
Expand All @@ -36,6 +37,7 @@
lib_names = [
"gdal",
"GDAL",
"gdal3.7.0",
"gdal3.6.0",
"gdal3.5.0",
"gdal3.4.0",
Expand Down
5 changes: 2 additions & 3 deletions docs/ref/contrib/gis/gdal.txt
Expand Up @@ -1844,8 +1844,8 @@ Key Default Usage
converted to the correct string format upon creation.

The following example uses some of the options available for the
`GTiff driver`__. The result is a compressed signed byte raster with an
internal tiling scheme. The internal tiles have a block size of 23 by 23:
`GTiff driver`__. The result is a compressed raster with an internal tiling
scheme. The internal tiles have a block size of 23 by 23:

.. code-block:: pycon

Expand All @@ -1859,7 +1859,6 @@ Key Default Usage
... "nr_of_bands": 1,
... "papsz_options": {
... "compress": "packbits",
... "pixeltype": "signedbyte",
... "tiled": "yes",
... "blockxsize": 23,
... "blockysize": 23,
Expand Down
9 changes: 5 additions & 4 deletions docs/ref/contrib/gis/install/geolibs.txt
Expand Up @@ -5,16 +5,16 @@ Installing Geospatial libraries
GeoDjango uses and/or provides interfaces for the following open source
geospatial libraries:

======================== ==================================== ================================ ======================================
======================== ==================================== ================================ ===========================================
Program Description Required Supported Versions
======================== ==================================== ================================ ======================================
======================== ==================================== ================================ ===========================================
: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
: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
`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
======================== ==================================== ================================ ======================================
======================== ==================================== ================================ ===========================================

Note that older or more recent versions of these libraries *may* also work
totally fine with GeoDjango. Your mileage may vary.
Expand All @@ -33,6 +33,7 @@ totally fine with GeoDjango. Your mileage may vary.
GDAL 3.4.0 2021-11-04
GDAL 3.5.0 2022-05-13
GDAL 3.6.0 2022-11-03
GDAL 3.7.0 2023-05-10
PostGIS 2.5.0 2018-09-23
PostGIS 3.0.0 2019-10-20
PostGIS 3.1.0 2020-12-18
Expand Down
2 changes: 2 additions & 0 deletions docs/releases/5.0.txt
Expand Up @@ -179,6 +179,8 @@ Minor features
* :ref:`GIS aggregates <gis-aggregation-functions>` now support the ``filter``
argument.

* Added support for GDAL 3.7.

:mod:`django.contrib.messages`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
30 changes: 19 additions & 11 deletions tests/gis_tests/gdal_tests/test_raster.py
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
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.raster.band import GDALBand
from django.contrib.gis.shortcuts import numpy
Expand Down Expand Up @@ -415,9 +415,19 @@ def test_compressed_file_based_raster_creation(self):
# Check physically if compression worked.
self.assertLess(os.path.getsize(compressed.name), os.path.getsize(self.rs.name))
# 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(
{
"datatype": 1,
"datatype": datatype,
"driver": "tif",
"name": rstfile.name,
"width": 40,
Expand All @@ -432,12 +442,7 @@ def test_compressed_file_based_raster_creation(self):
"nodata_value": 255,
}
],
"papsz_options": {
"compress": "packbits",
"pixeltype": "signedbyte",
"blockxsize": 23,
"blockysize": 23,
},
"papsz_options": papsz_options,
}
)
# Check if options used on creation are stored in metadata.
Expand All @@ -448,9 +453,12 @@ def test_compressed_file_based_raster_creation(self):
compressed.metadata["IMAGE_STRUCTURE"]["COMPRESSION"],
"PACKBITS",
)
self.assertEqual(
compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"], "SIGNEDBYTE"
)
self.assertEqual(compressed.bands[0].datatype(), datatype)
if GDAL_VERSION < (3, 7):
self.assertEqual(
compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"],
"SIGNEDBYTE",
)
self.assertIn("Block=40x23", compressed.info)

def test_raster_warp(self):
Expand Down

0 comments on commit 25cb27d

Please sign in to comment.