如何找到两个地址之间的距离?(Java 服务器端) [英] How to find distance between two addresses? (Java server side)

查看:19
本文介绍了如何找到两个地址之间的距离?(Java 服务器端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个社交"地理感知应用程序,而百万美元的问题是我如何列出一组我的位置"X 英里范围内"的项目,因为有数百万个应用程序这样做那个,我惊讶地发现只有谷歌地图 API 有一个免费的网络服务,更糟糕的是,它只有在谷歌地图中使用时才受支持.那么我必须开发自己的距离计算器吗?是否有任何免费/付费服务可以让我至少将地址转换为 XY 坐标?

I have a "social" geographic aware application I'm developing, and the million dollar question is how do I list a set of items that are "within X miles" of "my location" since there are million applications that do that, I was surprised to find that only Google Maps API has a free web service for that, and worse, it is only supported if used within a Google Map. So do I have to develop my own distance calculator? is there any free / paid service that will allow me to at least transform an address to a XY coordinate?

我确定有行业标准解决方案(免费或商业),但我还没有找到

I'm sure there is an industry standard solution (either free or commercial) but I'm yet to find it

推荐答案

其实Google确实有网络服务你可以在服务器端使用来实现这一点.

Actually, Google does have web services you can use on the server side to achieve this.

首先,您需要使用 地理编码 API 来翻译地址成纬度/经度坐标对.然后,您可以使用您认为合适的那些(即,如果您要存储这些,则针对您自己的数据库)

First you'll want to use the Geocoding API to translate addresses into latitude/longitude coordinate pairs. You can then use those however you see fit (i.e. against your own database if you are storing those)

如果您要查找的附近项目是 Google 可能已经知道的世界上的实际地点,您可以尝试 Google 的新 Places API 可以为您提供一定范围内的结果.

If the nearby items you want to find are actual places in the world that Google probably already knows about, you can try Google's new Places API which can give you results within a certain radius.

您应该注意,从纬度/经度坐标到距离的转换确实需要一些数学运算,但我认为最好在本地(在您的应用程序运行的服务器上)完成,而不是外包给某个外部服务器,因为它是只有数学.谷歌搜索产生了 this.

You should note that the translation from latitude/longitude coordinates to distances does require some math, but I think it is best done locally (on the server your application is running on) rather than being farmed out to some external server since it's only math. Googling produced this.

这篇关于如何找到两个地址之间的距离?(Java 服务器端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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