python - Getting near objects. Django + Badoo -
i have following situation.
i keep track of user's longitude , latitude using ios. send longitude , latitude coordinates django server.
how can use these longitude , latitude coordinates determine objects near?
basically how can use these coordinates determine list of other users near user?
assuming backend object has lat , longitude, here's useful snippet making proximity query:
objects = objectmodel.objects.exclude(lat__isnull=true).exclude(lng__isnull=true).extra( where=["3956 * 2 * asin(sqrt(power(sin((%(lat)s - abs(lat)) * pi()/180 / 2), 2) + cos(%(lat)s * pi()/180 ) * cos(abs(lat) * pi()/180) * power(sin((%(lng)s - lng) * pi()/180 / 2), 2) )) < 50" % {'lat': lat, 'lng': lng}], ) similar question: determine longitudes , latitudes within range
Comments
Post a Comment