找到位置,最快的方式(邮编,城市,州)定纬度/经度 [英] Fastest way to find the location(zip, city, state) given latitude/longitude

查看:242
本文介绍了找到位置,最快的方式(邮编,城市,州)定纬度/经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要给一个自由(开源的)解决方案的纬度/经度可以返回衣柜城市/州或邮政编码。 MySQL的不是一个选项,重量轻的小型数据库将是最好的,如果可能的。

I need a free(open-source) solution that given the lat/lng can return the closet city/state or zip. mysql is not an option, a small lightweight database would be the best if possible.

更新:无网络服务,拥有5000万IM $ P $,每天即使是最小的插件伤得增加一个服务请求会杀了响应时间pssions。我想preFER没有到要求增加超过200毫秒。

Updates: No web services, with 50 million impressions a day even the smallest addon hurts so adding a service request would kill response time. I would prefer not to add more than 200 milliseconds on to the request.

我有数据库,纬度/经度/ ZIP /城市/州的CSV,它只是如何存储和更重要的是如何找回它是最快的。

I have the database, lat/lon/zip/city/state in csv it's just how to store and more importantly how to retrieve it the quickest.

推荐答案

蛮力:pre-加载所有的数据到一个数组中。计算你的当前点和每个点之间的距离在阵列中(有一个方法来进行这样的计算,使用三角函数的线性代数代替,但我不记得它是什么的副手)找到的最近点。

Brute force: pre-load all of your data into an array. Calculate the distance between your current point and each point in the array (there's a method to do this calculation that uses linear algebra instead of trig functions, but I don't recall what it is offhand) to find the closest point.

请阅读此之前,向下投票:有办法加快蛮力搜索这样的,但我发现,他们通常不值得的麻烦。不仅有我用这个方法之前找到从纬度/经度最近的拉链,我用它在Windows Mobile应用程序(其中处理能力不完全是压倒性的),并仍然实现了亚秒级的搜索时间。只要你避免使用三角函数,这不是一个昂贵的过程。

Please read this before down-voting: there are ways to speed up a brute force search like this, but I've found that they're usually not worth the trouble. Not only have I used this approach before to find nearest zip from latitude/longitude, I've used it in a Windows Mobile application (where the processing power is not exactly overwhelming) and still achieved sub-second search times. As long as you avoid the use of trig functions, this is not an expensive process.

更新:可以加快摊分的压缩数据转换成子区域(象限,例如,像西北,东南等)和保存每个数据点区域ID搜索时间。在搜索的话,你首先要确定你的当前位置是在哪个地区,只有比较​​这些数据点。

Update: you can speed up the search time by apportioning your zip data into sub-regions (quadrants, for example, like northwest, southeast etc.) and saving the region ID with each data point. In the search, then, you first determine what region your current location is in, and compare only to those data points.

要避免边界错误(比如当你的当前位置是该地区的边缘附近,但实际上是最接近的邻近地区的zip),您的区域重叠,应该在一定程度上。这意味着你的一些压缩的记录将被复制,因此您的整体数据集将是一个有点大。

To avoid boundary errors (like when your current location is near the edge of its region but is actually closest to a zip in the neighboring region), your regions should overlap to some extent. This means some of your zip records will be duplicated, so your overall dataset will be a bit larger.

这篇关于找到位置,最快的方式(邮编,城市,州)定纬度/经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆