TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Calculate Latitude/Longitude Distances in MySQL with the Haversine Function

16 点作者 heyjonboy超过 14 年前

7 条评论

thibaut_barrere超过 14 年前
Anecdote on Haversine: in 1.6, MongoDB's built-in "geonear" was using non-spherical indexing, but I needed to get more accurate results in a project, so I queried 3 times more records and used Haversine afterward to sort records again, client-side. Here's the ruby code:<p><a href="http://gist.github.com/559482" rel="nofollow">http://gist.github.com/559482</a><p>Since then, MongoDB 1.7 has been released with spherical sort support (<a href="http://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-TheEarthisRoundbutMapsareFlat" rel="nofollow">http://www.mongodb.org/display/DOCS/Geospatial+Indexing#Geos...</a>)
bravo_sierra超过 14 年前
Why in the world would you use this when MySQL has almost proper geospatial support? It's far more efficient and less incorrect.<p>I swear - next time I'm going to get a R-Tree novelty account.
评论 #1841946 未加载
评论 #1842197 未加载
akharris超过 14 年前
One of those things you never think about when reading a map or driving in a car, but it's the explanation behind why you fly all the way up past nova scotia when on a plane to europe.
philfreo超过 14 年前
Sphinx (<a href="http://sphinxsearch.com/" rel="nofollow">http://sphinxsearch.com/</a>) is really good at geo/spatial searches on MySQL data<p>Example: <a href="http://www.god-object.com/2009/10/20/geospatial-search-using-sphinx-search-and-php/" rel="nofollow">http://www.god-object.com/2009/10/20/geospatial-search-using...</a>
评论 #1842210 未加载
wazoox超过 14 年前
&#60;rant&#62;I've got a better idea: use postgis and get rid of mysql and its quirks.<p>Yep, I just reinstalled an old app yesterday, and for some unfathomable reason it loses communication with mysql at some point (it worked perfectly for what, 6 years?). Gosh, I hate mysql.&#60;/rant&#62;
评论 #1842207 未加载
ljegou超过 14 年前
Beware, coordinates are not always expressed in the same referencial (geoid, ellipsoid, etc.).
lzimm超过 14 年前
wont that completely negate the value of the indices that lat/lon may/may not sit on and result in a complete tablescan?
评论 #1841866 未加载
评论 #1841948 未加载
评论 #1842191 未加载