获取n英里半径内的所有邮政编码 [英] Getting all zip codes within an n mile radius

查看:115
本文介绍了获取n英里半径内的所有邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得如下功能的最佳方法是什么?

def getNearest(zipCode, miles):

也就是说,给定一个邮政编码(07024)和一个半径,是否返回该半径内的所有邮政编码?

解决方案

SourceForge上有一个项目可以对此提供帮助:

http://sourceforge.net/projects/zips/

它为您提供了一个包含邮政编码及其纬度/经度的数据库,以及有关如何计算两组坐标之间距离的编码示例.也许有更好的方法,但是您可以让函数检索邮政编码及其坐标,然后逐步浏览列表中的每个邮政编码,如果该邮政编码在指定的英里数之内,则将其添加到列表中. /p>

What's the best way to get a function like the following to work:

def getNearest(zipCode, miles):

That is, given a zipcode (07024) and a radius, return all zipcodes which are within that radius?

解决方案

There is a project on SourceForge that could assist with this:

http://sourceforge.net/projects/zips/

It gives you a database with zip codes and their latitude / longitude, as well as coding examples of how to calculate the distance between two sets of coordinates. There is probably a better way to do it, but you could have your function retrieve the zipcode and its coordinates, and then step through each zipcode in the list and add the zipcode to a list if it falls within the number of miles specified.

这篇关于获取n英里半径内的所有邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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