コード例 #1
0
 def get_aggregation(self, using):
     # Remove any aggregates marked for reduction from the subquery
     # and move them to the outer AggregateQuery.
     connection = connections[using]
     for alias, aggregate in self.aggregate_select.items():
         if isinstance(aggregate, gis_aggregates.GeoAggregate):
             if not getattr(aggregate, 'is_extent',
                            False) or connection.ops.oracle:
                 self.extra_select_fields[alias] = GeomField()
     return super(GeoQuery, self).get_aggregation(using)
コード例 #2
0
ファイル: query.py プロジェクト: meliascosta/juegosdemente
 def convert_values(self, value, field):
     """
     Using the same routines that Oracle does we can convert our
     extra selection objects into Geometry and Distance objects.
     TODO: Make converted objects 'lazy' for less overhead.
     """
     if SpatialBackend.oracle:
         # Running through Oracle's first.
         value = super(GeoQuery,
                       self).convert_values(value, field or GeomField())
     if isinstance(field, DistanceField):
         # Using the field's distance attribute, can instantiate
         # `Distance` with the right context.
         value = Distance(**{field.distance_att: value})
     elif isinstance(field, AreaField):
         value = Area(**{field.area_att: value})
     elif isinstance(field, GeomField):
         value = SpatialBackend.Geometry(value)
     return value