views:

23

answers:

0

In Django documentation, I read this (http://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#id7):

On every distance lookup but dwithin, an optional third element, 'spheroid', may be included to tell GeoDjango to use the more accurate spheroid distance calculation functions on fields with a geodetic coordinate system (e.g., ST_Distance_Spheroid would be used instead of ST_Distance_Sphere).

But when I try to execute a distance lookup with 'distance_lte' on a Postgis 1.5 database, the query is executed with "ST_Distance" instead of "ST_Distance_sphere". Why ? Did I forget something ?

stations = Station.objects.filter(point__distance_lte=(pnt, D(km=10))).count()
from django.db import connection
print connection.queries

Which prints this :

[{'time': '0.144', 'sql': 'SELECT "spatial_ref_sys"."srid", "spatial_ref_sys"."auth_name", "spatial_ref_sys"."auth_srid", "spatial_ref_sys"."srtext", "spatial_ref_sys"."proj4text" FROM "spatial_ref_sys" WHERE "spatial_ref_sys"."srid" = 900913 '}, {'time': '0.903', 'sql': 'SELECT COUNT(*) FROM "prices_station" WHERE ST_Distance("prices_station"."point", ST_GeomFromEWKB(E\'\\\\001\\\\001\\\\000\\\\000 1\\\\277\\\\015\\\\000\\\\270\\\\036\\\\205\\\\353Q\\\\270\\\\372\\\\277H\\\\341z\\\\024\\\\256\\\\007H@\'::bytea)) <= 10000.0'}]

Thanks