Fixed #30156 -- Dropped support for SpatiaLite 4.1 and 4.2.

This commit is contained in:
Tim Graham 2019-02-04 12:03:12 -05:00
parent 4763c97191
commit d47498c5df
5 changed files with 17 additions and 31 deletions

View File

@ -1,6 +1,6 @@
"""
SQL functions reference lists:
https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html
https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html
"""
from django.contrib.gis.db.backends.base.operations import (
BaseSpatialOperations,
@ -9,7 +9,7 @@ from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.db.models import aggregates
from django.contrib.gis.geos.geometry import GEOSGeometry, GEOSGeometryBase
from django.contrib.gis.geos.prototypes.io import wkb_r, wkt_r
from django.contrib.gis.geos.prototypes.io import wkb_r
from django.contrib.gis.measure import Distance
from django.core.exceptions import ImproperlyConfigured
from django.db.backends.sqlite3.operations import DatabaseOperations
@ -64,9 +64,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
disallowed_aggregates = (aggregates.Extent3D,)
@cached_property
def select(self):
return 'CAST (AsEWKB(%s) AS BLOB)' if self.spatial_version >= (4, 3, 0) else 'AsText(%s)'
select = 'CAST (AsEWKB(%s) AS BLOB)'
function_names = {
'ForcePolygonCW': 'ST_ForceLHR',
@ -98,8 +96,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
self.connection.settings_dict['NAME'],
)
) from exc
if version < (4, 1, 0):
raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.1.0 and above.')
if version < (4, 3, 0):
raise ImproperlyConfigured('GeoDjango supports SpatiaLite 4.3.0 and above.')
return version
def convert_extent(self, box):
@ -199,21 +197,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
def get_geometry_converter(self, expression):
geom_class = expression.output_field.geom_class
if self.spatial_version >= (4, 3, 0):
read = wkb_r().read
read = wkb_r().read
def converter(value, expression, connection):
return None if value is None else GEOSGeometryBase(read(value), geom_class)
else:
read = wkt_r().read
srid = expression.output_field.srid
if srid == -1:
srid = None
def converter(value, expression, connection):
if value is not None:
geom = GEOSGeometryBase(read(value), geom_class)
if srid:
geom.srid = srid
return geom
def converter(value, expression, connection):
return None if value is None else GEOSGeometryBase(read(value), geom_class)
return converter

View File

@ -34,12 +34,10 @@ class ATan2(NumericOutputFieldMixin, Func):
arity = 2
def as_sqlite(self, compiler, connection, **extra_context):
if not getattr(connection.ops, 'spatialite', False) or not (
(4, 3, 0) <= connection.ops.spatial_version < (5, 0, 0)
):
if not getattr(connection.ops, 'spatialite', False) or connection.ops.spatial_version >= (5, 0, 0):
return self.as_sql(compiler, connection)
# This function is usually ATan2(y, x), returning the inverse tangent
# of y / x, but it's ATan2(x, y) on SpatiaLite >= 4.3.0, < 5.0.0.
# of y / x, but it's ATan2(x, y) on SpatiaLite < 5.0.0.
# Cast integers to float to avoid inconsistent/buggy behavior if the
# arguments are mixed between integer and float or decimal.
# https://www.gaia-gis.it/fossil/libspatialite/tktview?name=0f72cca3a2

View File

@ -13,7 +13,7 @@ Program Description Required
:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 2.3, 2.2, 2.1, 2.0, 1.11
: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, 2.1
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3, 4.2, 4.1
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3
======================== ==================================== ================================ ===================================
Note that older or more recent versions of these libraries *may* also work
@ -35,8 +35,6 @@ 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
SpatiaLite 4.1.0 2013-06-04
SpatiaLite 4.2.0 2014-07-25
SpatiaLite 4.3.0 2015-09-07
.. note::

View File

@ -61,7 +61,7 @@ Database Library Requirements Supported Versions Notes
PostgreSQL GEOS, GDAL, PROJ.4, PostGIS 9.4+ Requires PostGIS.
MySQL GEOS, GDAL 5.6+ Not OGC-compliant; :ref:`limited functionality <mysql-spatial-limitations>`.
Oracle GEOS, GDAL 12.1+ XE not supported.
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.8.3+ Requires SpatiaLite 4.1+
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.8.3+ Requires SpatiaLite 4.3+
================== ============================== ================== =========================================
See also `this comparison matrix`__ on the OSGeo Wiki for

View File

@ -222,6 +222,11 @@ backends.
``can_return_ids_from_bulk_insert`` are renamed to
``can_return_columns_from_insert`` and ``can_return_rows_from_bulk_insert``.
:mod:`django.contrib.gis`
-------------------------
* Support for SpatiaLite 4.1 and 4.2 is removed.
Miscellaneous
-------------