我试图找出:给定一个邮政编码,那个邮政编码的X英里范围内的所有邮编都是什么。
我找到了一些我在下面发布的解决方案,但是我想知道是否有专门针对Rails或Ruby的更好的解决方案(换句话说,就是宝石,要点等)。 我发现的Ruby解决方案已有几年了,所以现在看起来可能有更好的解决方案。
理想情况下,我希望只需要一个字符串“11026”并生成字符串作为输出,而不必创建AR模型或处理数据库过于广泛。
Geocoder似乎没有明确这么做...... Geokit也没有这样做 。 我不知道这些宝石是否有简单的解决方法。
类似解决方案
查找邮编指定距离内的所有邮编
I'm trying to find out: given a zipcode, what are all the zipcodes within an X-mile radius of that zipcode.
I've found a few solutions, which I've posted below, but I want to know if there are any better solutions specifically for Rails or Ruby (in other words, a gem, a gist, etc.). The Ruby solutions I've found are a few years old, so it seems like there could be a better solution available now.
Ideally I'd want something that just takes a string "11026" and produces strings as output, without me having to create AR models or deal with the database too extensively.
Geocoder doesn't seem to do this explicitly... neither does Geokit. I don't know if there's a simple work-around for either of these gems.
Similar solutions:
Find all Zipcodes within specified distance of a zipcode
最满意答案
Sql-wise,有人已经在这里问过类似的问题。 有点简单的实施,并会给你足够好的结果来测试你的规格。
否则,如果您可以找到一个每个zip都有纬度/长度的库,从地理邻近的角度来看它很容易。 然后,您应该查找Postgresql邻近搜索。 查找更多信息: http : //www.boutell.com/zipcodes/和http://www.geopostcodes.com/
Sql-wise, someone already asked that similar question here. Kinda simple to implement and would give you good enough results to test your spec.
Otherwise, if you can find a library that has lat/long for each zip, it'd be easy to look at it from a geo-proximity point of view. Then, you should look for Postgresql proximity search. Find more: http://www.boutell.com/zipcodes/ and http://www.geopostcodes.com/
更多推荐
发布评论