Databases with ordinary indexes are rather bad with finding something nearby.
Thus some DB engines implemented rtree indexes (Look for example at http://www.sqlite.org/rtree.html ) or similiar kind of indexes allowing to locate objects within a certain latitude / longitude range.witt much less effort as if you had one normal laitude index and one normal longitude index. If you have a huge set of lcoations. You can reduce the search effort considerable by first limiting the search space by identifying all objects within a certain lattude / longitude range oand only afterwards calculating the exact distance for the object in this 'rectanguler ' sub region. As I'm a django newbie and as I don't know the db engines that well I'm not sure whether your database engine supports r-indexes (or alike) and whether there are any recommendations of how to write a django query, such, taht it benefits from such special spactial indexes. On 08/11/2011 05:09 PM, Thomas Weholt wrote: > I got a model with longitude and latitude and want to be able to find > other objects nearby a selected object. Can this be done using the > django orm? What is the best approach to do this in a django project? > > I found a answer on Stackoverflow, but doesn't work with sqlite. Doing > it in SQL is ok and probably the best solution performance wise, but > if it has to be done in python I'll do that too. > > Ref question on stackoverflow: > http://stackoverflow.com/questions/4610717/django-determining-if-geographic-coordinates-are-inside-of-an-circle > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.