From b9e2355eb07938829a1a31ed7b60e5f72d4b92e3 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 20 Jan 2020 00:01:08 +0500 Subject: [PATCH] Fixed #31196 -- Added support for PostGIS 3. --- django/contrib/gis/db/models/functions.py | 14 ++++++++------ docs/ref/contrib/gis/functions.txt | 4 ++++ docs/ref/contrib/gis/install/geolibs.txt | 3 ++- docs/releases/3.1.txt | 5 +++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py index de4ee3d6bd..debd859390 100644 --- a/django/contrib/gis/db/models/functions.py +++ b/django/contrib/gis/db/models/functions.py @@ -190,12 +190,14 @@ class AsGML(GeoFunc): return super(AsGML, clone).as_sql(compiler, connection, **extra_context) -class AsKML(AsGML): - def as_sqlite(self, compiler, connection, **extra_context): - # No version parameter - clone = self.copy() - clone.set_source_expressions(self.get_source_expressions()[1:]) - return clone.as_sql(compiler, connection, **extra_context) +class AsKML(GeoFunc): + output_field = TextField() + + def __init__(self, expression, precision=8, **extra): + expressions = [expression] + if precision is not None: + expressions.append(self._handle_param(precision, 'precision', int)) + super().__init__(*expressions, **extra) class AsSVG(GeoFunc): diff --git a/docs/ref/contrib/gis/functions.txt b/docs/ref/contrib/gis/functions.txt index 347b22b3e2..b9507139f2 100644 --- a/docs/ref/contrib/gis/functions.txt +++ b/docs/ref/contrib/gis/functions.txt @@ -144,6 +144,10 @@ Keyword Argument Description __ https://developers.google.com/kml/documentation/ +.. versionchanged:: 3.1 + + The undocumented ``version`` parameter was removed. + ``AsSVG`` ========= diff --git a/docs/ref/contrib/gis/install/geolibs.txt b/docs/ref/contrib/gis/install/geolibs.txt index 8f63139e60..b0878a9e4c 100644 --- a/docs/ref/contrib/gis/install/geolibs.txt +++ b/docs/ref/contrib/gis/install/geolibs.txt @@ -12,7 +12,7 @@ Program Description Required `PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 5.2, 5.1, 5.0, 4.x :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 2.4, 2.3, 2.2, 2.1, 2.0 :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2 -`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 2.5, 2.4, 2.3, 2.2 +`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.0, 2.5, 2.4, 2.3, 2.2 `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3 ======================== ==================================== ================================ =================================== @@ -33,6 +33,7 @@ totally fine with GeoDjango. Your mileage may vary. PostGIS 2.3.0 2016-09-26 PostGIS 2.4.0 2017-09-30 PostGIS 2.5.0 2018-09-23 + PostGIS 3.0.0 2019-10-20 SpatiaLite 4.3.0 2015-09-07 .. note:: diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt index 85f4ca2d99..07f316a701 100644 --- a/docs/releases/3.1.txt +++ b/docs/releases/3.1.txt @@ -116,6 +116,8 @@ Minor features * Added the :class:`~django.contrib.gis.db.models.functions.AsWKB` and :class:`~django.contrib.gis.db.models.functions.AsWKT` functions. +* Added support for PostGIS 3. + :mod:`django.contrib.humanize` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -629,6 +631,9 @@ Miscellaneous argument to be a string or bytes. Other types should be explicitly cast to one of these. +* The undocumented ``version`` parameter to the + :class:`~django.contrib.gis.db.models.functions.AsKML` function is removed. + .. _deprecated-features-3.1: Features deprecated in 3.1