如何使用 Java 代码找到两个 ZipCode 之间的距离? [英] How to find the distance between two ZipCodes using Java Code?
问题描述
我的要求类似于这个问题,除了我被禁止使用纬度和经度值的事实.我想计算两个邮政编码之间的 步行" 距离.后来我还需要查询谁在 X 公里内?"
My requirements are similar to this question, except the fact that I am prohibited to use the latitude and longitude values. I want to caluclate the "walking" distance between two zipcodes. Later I would also require to query "who is within X kms ?"
我不确定它是否可以实现.真的有可能找到两个给定邮政编码之间的距离吗?我不想要仅适用于美国/英国邮政编码的答案.我需要一个适用于世界上任何两个邮政编码的通用解决方案.
I am not sure whether it is achievable or not. Is it really possible to find the distance between two given zipcodes ? I don't want the answers which will work only for US/UK zip codes. I need a generic solution which will work for any two zipcodes of the world.
如果计算距离而不使用Langitude &经度是不可能的,那么我可以获得给定 ZIPCODE 的经度/经度值吗?(惊人)但是如何?
If the calculation of distance without using Langitude & longitude is not possible then can I get the Langitude / longitude values of a given ZIPCODE ? (amazing) but How ?
任何教程/示例都会有很大帮助..因为我正在从事商业项目,所以不能使用 Google 地图 API.所以请不要推荐任何其他许可服务.
Any tutorial / example will be of great help..Since I am working on a commercial project cant use the Google Maps API. So please don't suggest any other licensed services.
提前致谢,
更新这个问题的答案之一表明使用 MySQL 或 Postgress...这对我有用吗..?
UPDATE one of the answers of this question suggests the use of MySQL or Postgress... Will that work for me..?
推荐答案
我遵循了两步流程...
I followed a two step process...
- 首先,我将用户的邮政编码作为输入,然后使用免费提供的 API 之一找到纬度和经度值,
- 获得纬度、经度对后,我就可以轻松使用@Bohemian 建议的功能...
但是,有时我发现 google 和 Yahoo API 是此恕我直言的最佳方式,因此我将其集成到我的项目中.如果有人感兴趣,我可以在这里粘贴代码.
However after sometimes I found that google and Yahoo APIs are the best possible way for this IMHO, so I integrated that in my project. If any one interested I can paste the code for that here.
这篇关于如何使用 Java 代码找到两个 ZipCode 之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!