使用Php 5和MySQL进行GPS半径搜索 [英] GPS radius search with Php 5 and MySQL
本文介绍了使用Php 5和MySQL进行GPS半径搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个PlaceID | PlaceName | Lat | Lon
作为我的数据库结构.
I have a PlaceID | PlaceName | Lat | Lon
as my database structure.
假设我当前的经纬度为
$lat = "37.331862";
$lon = "-122.029937";
我想找到半径100英尺的地方.可能允许用户选择.
I want to find places that are in a 100 feet radius. Might allow the user to choose.
推荐答案
您可能有兴趣查看以下演示文稿:
You may be interested in checking out the following presentation:
- Geo/Spatial Search with MySQL1 by Alexander Rubin
作者介绍了如何在MySQL中使用 Haversine公式来按接近度和限制进行排序您的搜索到定义的范围.他还介绍了如何使用纬度和经度列上的传统索引来避免对此类查询进行全表扫描.
The author describes how you can use the Haversine Formula in MySQL to order by proximity and limit your searches to a defined range. He also describes how to avoid a full table scan for such queries, using traditional indexes on the latitude and longitude columns.
1 PDF版本
这篇关于使用Php 5和MySQL进行GPS半径搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文