Fixed #25836 -- Added support for MakeLine aggregate on SpatiaLite.

This commit is contained in:
Sergey Fedoseev 2015-12-01 08:08:41 +05:00 committed by Tim Graham
parent d3b488f5bd
commit 0825f77f76
5 changed files with 12 additions and 9 deletions

View File

@ -39,6 +39,7 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
intersection = 'Intersection'
kml = 'AsKML'
length = 'GLength' # OpenGis defines Length, but this conflicts with an SQLite reserved keyword
makeline = 'MakeLine'
num_geom = 'NumGeometries'
num_points = 'NumPoints'
point_on_surface = 'PointOnSurface'
@ -80,6 +81,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
'distance_lte': SpatialOperator(func='Distance', op='<='),
}
disallowed_aggregates = (aggregates.Extent3D,)
@cached_property
def function_names(self):
return {
@ -114,11 +117,6 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 3.0.0 and above.')
return version
@cached_property
def disallowed_aggregates(self):
disallowed = (aggregates.Extent3D, aggregates.MakeLine)
return disallowed
def convert_extent(self, box, srid):
"""
Convert the polygon data received from Spatialite to min/max values.

View File

@ -348,7 +348,7 @@ Aggregate PostGIS Oracle SpatiaLite
:class:`Collect` X X
:class:`Extent` X X X
:class:`Extent3D` X
:class:`MakeLine` X
:class:`MakeLine` X X
:class:`Union` X X X
======================= ======= ====== ==========

View File

@ -1297,11 +1297,15 @@ Example::
.. class:: MakeLine(geo_field)
*Availability*: PostGIS
*Availability*: PostGIS, SpatiaLite
Returns a ``LineString`` constructed from the point field geometries in the
``QuerySet``. Currently, ordering the queryset has no effect.
.. versionchanged:: 1.10
SpatiaLite support was added.
Example::
>>> print(City.objects.filter(name__in=('Houston', 'Dallas')

View File

@ -79,6 +79,9 @@ Minor features
:attr:`~django.contrib.gis.gdal.GDALBand.mean`
and :attr:`~django.contrib.gis.gdal.GDALBand.std` attributes.
* Added support for the :class:`~django.contrib.gis.db.models.MakeLine`
aggregate on SpatiaLite.
:mod:`django.contrib.messages`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -652,8 +652,6 @@ class GeoQuerySetTest(TestCase):
Testing the `MakeLine` aggregate.
"""
if not connection.features.supports_make_line_aggr:
# Only PostGIS has support for the MakeLine aggregate. For other
# backends, test that NotImplementedError is raised
self.assertRaises(
NotImplementedError,
City.objects.all().aggregate, MakeLine('point')