2008-08-06 02:13:06 +08:00
|
|
|
from django.db.models.manager import Manager
|
|
|
|
from django.contrib.gis.db.models.query import GeoQuerySet
|
2009-04-25 04:24:50 +08:00
|
|
|
from django.contrib.gis.db.models.sql.subqueries import insert_query
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
class GeoManager(Manager):
|
|
|
|
"Overrides Manager to return Geographic QuerySets."
|
|
|
|
|
|
|
|
# This manager should be used for queries on related fields
|
|
|
|
# so that geometry columns on Oracle and MySQL are selected
|
|
|
|
# properly.
|
|
|
|
use_for_related_fields = True
|
|
|
|
|
|
|
|
def get_query_set(self):
|
|
|
|
return GeoQuerySet(model=self.model)
|
|
|
|
|
|
|
|
def area(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().area(*args, **kwargs)
|
|
|
|
|
|
|
|
def centroid(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().centroid(*args, **kwargs)
|
|
|
|
|
2009-07-15 10:20:51 +08:00
|
|
|
def collect(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().collect(*args, **kwargs)
|
|
|
|
|
2008-08-06 02:13:06 +08:00
|
|
|
def difference(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().difference(*args, **kwargs)
|
|
|
|
|
|
|
|
def distance(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().distance(*args, **kwargs)
|
|
|
|
|
|
|
|
def envelope(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().envelope(*args, **kwargs)
|
|
|
|
|
|
|
|
def extent(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().extent(*args, **kwargs)
|
|
|
|
|
2009-11-17 02:49:00 +08:00
|
|
|
def extent3d(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().extent3d(*args, **kwargs)
|
|
|
|
|
2009-04-03 00:50:44 +08:00
|
|
|
def geojson(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().geojson(*args, **kwargs)
|
|
|
|
|
2008-08-06 02:13:06 +08:00
|
|
|
def gml(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().gml(*args, **kwargs)
|
|
|
|
|
|
|
|
def intersection(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().intersection(*args, **kwargs)
|
|
|
|
|
|
|
|
def kml(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().kml(*args, **kwargs)
|
|
|
|
|
|
|
|
def length(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().length(*args, **kwargs)
|
|
|
|
|
|
|
|
def make_line(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().make_line(*args, **kwargs)
|
|
|
|
|
|
|
|
def mem_size(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().mem_size(*args, **kwargs)
|
|
|
|
|
|
|
|
def num_geom(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().num_geom(*args, **kwargs)
|
|
|
|
|
|
|
|
def num_points(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().num_points(*args, **kwargs)
|
|
|
|
|
|
|
|
def perimeter(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().perimeter(*args, **kwargs)
|
|
|
|
|
|
|
|
def point_on_surface(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().point_on_surface(*args, **kwargs)
|
|
|
|
|
|
|
|
def scale(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().scale(*args, **kwargs)
|
|
|
|
|
2009-04-03 00:50:44 +08:00
|
|
|
def snap_to_grid(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().snap_to_grid(*args, **kwargs)
|
|
|
|
|
2008-08-06 02:13:06 +08:00
|
|
|
def svg(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().svg(*args, **kwargs)
|
|
|
|
|
|
|
|
def sym_difference(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().sym_difference(*args, **kwargs)
|
|
|
|
|
|
|
|
def transform(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().transform(*args, **kwargs)
|
|
|
|
|
|
|
|
def translate(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().translate(*args, **kwargs)
|
|
|
|
|
|
|
|
def union(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().union(*args, **kwargs)
|
|
|
|
|
|
|
|
def unionagg(self, *args, **kwargs):
|
|
|
|
return self.get_query_set().unionagg(*args, **kwargs)
|
2009-04-25 04:24:50 +08:00
|
|
|
|
|
|
|
def _insert(self, values, **kwargs):
|
|
|
|
return insert_query(self.model, values, **kwargs)
|