I just got GeoDjango on my development machine. The problem is that I cannot get the distance request to work correctly. No matter which SRID I use, the distance results are completely disabled. Here is an example.
>>> from django.contrib.gis.measure import D >>> from app.models import Place >>> from django.contrib.gis.geos import Point >>> qs = Place.objects.all() >>> point = Point(-118, 34) >>> qs.filter(coordinates__distance_lte=(point, D(m=1))) [<Place: 7-Eleven>, <Place: Arthur Murray Dance Studio>, <Place: Costco>, <Place: AMC Century City 15>, <Place: 24 Hour Fitness>, <Place: Ralphs>, <Place: Houston Restaurant>, <Place: CVS/pharmacy>, <Place: Shaky Alibi>, <Place: Sephora>, <Place: Trader Joe's>]
The problem is that these places are much farther than 1 m from the point .
I tried to play with him, but I had no luck. Here is an example with a different SRID.
>>> qs = Place.objects.all().transform(3786) >>> point = Point(-118, 34, srid=3786) >>> qs.filter(coordinates__distance_lte=(point, D(m=1))) [<Place: 7-Eleven>, <Place: Arthur Murray Dance Studio>, <Place: Costco>, <Place: AMC Century City 15>, <Place: 24 Hour Fitness>, <Place: Ralphs>, <Place: Houston Restaurant>, <Place: CVS/pharmacy>, <Place: Shaky Alibi>, <Place: Sephora>, <Place: Trader Joe's>]
I have the feeling that I’m just choosing the wrong SRIDs, but not one of them that I worked with on the Internet, didn’t work or didn’t answer a single answer, which is even moderately useful.
Any help is much appreciated!