【问题标题】:django geocoder to find near by coordinatesdjango地理编码器通过坐标查找附近
【发布时间】:2017-07-24 20:37:40
【问题描述】:

我正在使用地理编码器,我有坐标数据库,我想使用地理编码器获取 5 公里半径内的坐标。在rails中我可以这样做:

 Venue.near([40.71, -100.23], 20)    # venues within 20 miles of a point 

如何使用 django 地理编码器做到这一点????

【问题讨论】:

    标签: django google-geocoder


    【解决方案1】:

    您可以使用此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)))
    

    【讨论】:

    • 我没有使用 postgis,我将 lat、long 存储在单独的列中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多