|
Revision 7641, 0.9 kB
(checked in by jbronn, 4 months ago)
|
gis: Refactor of the GeoQuerySet; new features include:
(1) Creation of internal API that eases generation of GeoQuerySet methods.
(2) GeoQuerySet.distance now returns Distance objects instead of floats.
(3) Added the new GeoQuerySet methods: area, centroid, difference, envelope, intersection, length, make_line, mem_size, num_geom, num_points, perimeter, point_on_surface, scale, svg, sym_difference, translate, union.
(4) The model_att keyword may be used to customize the attribute that GeoQuerySet methods attach output to.
(5) Geographic distance lookups and GeoQuerySet.distance calls now use ST_distance_sphere by default (performance benefits far outweigh small loss in accuracy); ST_distance_spheroid may still be used by specifying an option.
(6) GeoQuerySet methods may now operate accross ForeignKey? relations specified via the field_name keyword (but this does not work on Oracle).
(7) Area now has the same units of measure as Distance.
Backward Incompatibilites:
- The aggregate union method is now known as unionagg.
- The field_name keyword used for GeoQuerySet methods may no longer be specified via positional arguments.
- Distance objects returned instead of floats from GeoQuerySet.distance.
- ST_Distance_sphere used by default for geographic distance calculations.
|
| Line | |
|---|
| 1 |
""" |
|---|
| 2 |
This module provides the backend for spatial SQL construction with Django. |
|---|
| 3 |
|
|---|
| 4 |
Specifically, this module will import the correct routines and modules |
|---|
| 5 |
needed for GeoDjango to interface with the spatial database. |
|---|
| 6 |
""" |
|---|
| 7 |
from django.conf import settings |
|---|
| 8 |
from django.contrib.gis.db.backend.util import gqn |
|---|
| 9 |
|
|---|
| 10 |
# Retrieving the necessary settings from the backend. |
|---|
| 11 |
if settings.DATABASE_ENGINE == 'postgresql_psycopg2': |
|---|
| 12 |
from django.contrib.gis.db.backend.postgis import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 13 |
elif settings.DATABASE_ENGINE == 'oracle': |
|---|
| 14 |
from django.contrib.gis.db.backend.oracle import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 15 |
elif settings.DATABASE_ENGINE == 'mysql': |
|---|
| 16 |
from django.contrib.gis.db.backend.mysql import create_spatial_db, get_geo_where_clause, SpatialBackend |
|---|
| 17 |
else: |
|---|
| 18 |
raise NotImplementedError('No Geographic Backend exists for %s' % settings.DATABASE_ENGINE) |
|---|