Rails,距离邮编区域的所有邮编(Rails, all zipcodes within distance from zipcode)

编程入门 行业动态 更新时间:2024-10-22 14:24:46
Rails,距离邮编区域的所有邮编(Rails, all zipcodes within distance from zipcode)

我试图找出:给定一个邮政编码,那个邮政编码的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/

更多推荐

本文发布于:2023-08-05 21:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮编   距离   区域   Rails   distance

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!