【发布时间】:2017-07-24 20:37:40
【问题描述】:
我正在使用地理编码器,我有坐标数据库,我想使用地理编码器获取 5 公里半径内的坐标。在rails中我可以这样做:
Venue.near([40.71, -100.23], 20) # venues within 20 miles of a point
如何使用 django 地理编码器做到这一点????
【问题讨论】:
我正在使用地理编码器,我有坐标数据库,我想使用地理编码器获取 5 公里半径内的坐标。在rails中我可以这样做:
Venue.near([40.71, -100.23], 20) # venues within 20 miles of a point
如何使用 django 地理编码器做到这一点????
【问题讨论】:
您可以使用此How to get the nearest location entries from a database?。 示例:
from django.contrib.gis.measure import D
from django.contrib.gis.geos import *
from myapp.models import MyResult
pnt = fromstr('POINT(48.796777 2.371140 )', srid=4326)
qs = MyResul
t.objects.filter(point__distance_lte=(pnt, D(km=20)))
【讨论】: