KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I just got GeoDjango up and running on my development machine. Problem is that I can't get a distance query to work correctly. No matter what SRID I use, the distance results are totally off. Here's 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's Restaurant>, <Place: CVS/pharmacy>, <Place: Shaky Alibi>, <Place: Sephora>, <Place: Trader Joe's>] The problem is that these places are much further than 1m away from point . I tried playing around with it, but haven't had much luck. Here's an example with another 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's Restaurant>, <Place: CVS/pharmacy>, <Place: Shaky Alibi>, <Place: Sephora>, <Place: Trader Joe's>] I have a feeling I'm just choosing the wrong SRIDs, but not a single one that I've run into online has worked, or given any response that is even moderately useful. Any help is greatly appreciated!
Tags (comma-separated)
Save Edits
Cancel