Browse Source

Fixed #31196 -- Added support for PostGIS 3.

Sergey Fedoseev 5 years ago
parent
commit
b9e2355eb0

+ 8 - 6
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):

+ 4 - 0
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``
 =========
 

+ 2 - 1
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::

+ 5 - 0
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