如何使用Java代码找到两个ZipCodes之间的距离? [英] How to find the distance between two ZipCodes using Java Code?
问题描述
我的要求类似于此问题,除了我被禁止使用纬度和经度值这一事实。我想调整两个zipcodes之间的行走距离。后来我还要求查询谁在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 Maps 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.
提前致谢,
UPDATE
的答案之一这个问题建议使用 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建议的功能...
但有时我发现谷歌和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代码找到两个ZipCodes之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!