~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/contrib/gis/db/models/aggregates.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.db.models import Aggregate
2
 
from django.contrib.gis.db.backend import SpatialBackend
3
2
from django.contrib.gis.db.models.sql import GeomField
4
3
 
5
 
class GeoAggregate(Aggregate):
6
 
 
7
 
    def add_to_query(self, query, alias, col, source, is_summary):
8
 
        if hasattr(source, 'geom_type'):
9
 
            # Doing additional setup on the Query object for spatial aggregates.
10
 
            aggregate = getattr(query.aggregates_module, self.name)
11
 
            
12
 
            # Adding a conversion class instance and any selection wrapping
13
 
            # SQL (e.g., needed by Oracle).
14
 
            if aggregate.conversion_class is GeomField:
15
 
                query.extra_select_fields[alias] = GeomField()
16
 
                if SpatialBackend.select:
17
 
                    query.custom_select[alias] = SpatialBackend.select
18
 
     
19
 
        super(GeoAggregate, self).add_to_query(query, alias, col, source, is_summary)
20
 
 
21
 
class Collect(GeoAggregate):
 
4
class Collect(Aggregate):
22
5
    name = 'Collect'
23
6
 
24
 
class Extent(GeoAggregate):
 
7
class Extent(Aggregate):
25
8
    name = 'Extent'
26
9
 
27
 
class MakeLine(GeoAggregate):
 
10
class Extent3D(Aggregate):
 
11
    name = 'Extent3D'
 
12
 
 
13
class MakeLine(Aggregate):
28
14
    name = 'MakeLine'
29
15
 
30
 
class Union(GeoAggregate):
 
16
class Union(Aggregate):
31
17
    name = 'Union'