juj*_*ule 12
如果您不介意非常好的精度,可以在纯SQL中解决此问题.
您可以使用此特定SQL查询在GPS位置周围找到点:
# find point around :
latitude = 46.2037010192871
longitude = 5.20353984832764
query= "SELECT ID, NOM, LAT, LON, 3956 * 2 * ASIN(SQRT(POWER(SIN((%s - LAT) * 0.0174532925 / 2), 2) + COS(%s * 0.0174532925) * COS(LAT * 0.0174532925) * POWER(SIN((%s - LON) * 0.0174532925 / 2), 2) )) as distance from POI having distance < 50 ORDER BY distance ASC " % ( latitude, latitude, longitude)
Run Code Online (Sandbox Code Playgroud)
这将为您提供50公里区域内所有gps记录的记录.
你可以在django中轻松插入:
from django.db import connection
cursor = connection.cursor()
cursor.execute( query )
rows = cursor.fetchall()
Run Code Online (Sandbox Code Playgroud)
或者使用django原始查询
| 归档时间: |
|
| 查看次数: |
2048 次 |
| 最近记录: |