diff options
| author | Tim Graham <timograham@gmail.com> | 2019-02-04 12:03:12 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-02-04 13:16:38 -0500 |
| commit | d47498c5df7e8861c19fea22e5b04229b510bc3e (patch) | |
| tree | 9ebfc4ae3cf85d5e375873233ad85a7754044056 /django | |
| parent | 4763c9719135f4de17924d9c8524f1cfe41bc645 (diff) | |
Fixed #30156 -- Dropped support for SpatiaLite 4.1 and 4.2.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/spatialite/operations.py | 31 | ||||
| -rw-r--r-- | django/db/models/functions/math.py | 6 |
2 files changed, 10 insertions, 27 deletions
diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 78dfa5cfb4..bbce44b9df 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -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 - - 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 + read = wkb_r().read - 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 diff --git a/django/db/models/functions/math.py b/django/db/models/functions/math.py index 43cbc17a1e..1a574eb9ab 100644 --- a/django/db/models/functions/math.py +++ b/django/db/models/functions/math.py @@ -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 |
