给定 GPS 坐标,我如何找到附近的地标或兴趣点? [英] Given GPS coordinates, how do I find nearby landmarks or points-of-interest?

查看:14
本文介绍了给定 GPS 坐标,我如何找到附近的地标或兴趣点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚买了一部 Google Nexus One 智能手机,我想写一个小的 Android 应用程序来娱乐.假设我可以获得当前的 GPS 坐标,那么我如何以编程方式在某个半径范围内找到附近的地标或兴趣点?是否有 API 可以获取 GPS 地理标记的地标,例如在 Google 地球的数据库中?

I just bought a Google Nexus One smartphone, and I want to write a small Android application for fun. Suppose I can get my current GPS coordinates, so then how can I programmatically find nearby landmarks or points-of-interest within some radius? Is there an API to get GPS geo-tagged landmarks, like in Google Earth's database?

例如,如果我在芝加哥市中心,我的程序会将我指向该城市的所有旅游"景点.

For example, if I'm in downtown Chicago, my program would point me to all the "tourist" things to visit in that city.

理想情况下,它都可以在我的智能手机上运行,​​但如果有必要,我可以让智能手机查询网络服务器,然后它会运行更多查询.

Ideally, it would all run on my smartphone, but if necessary, I can have the smartphone query a webserver, which would then run more queries.

推荐答案

取决于您从哪里获取地标数据.如果您想进行网络查询,您可以使用上述方法之一运行.

Depends where you're getting your landmark data from. If you want to do a web query, you could run with one of the things above.

或者 - 如果您有自己的数据,您可以将其与 lat 和 lon 值一起存储在数据库中,然后为查询形成边界矩形.这个问题告诉你如何计算一个围绕你当前点的给定半径的边界框(它将是一个框,所以它会比一个圆更大......

Alternatively - if you have your own data, you can stash it in the db with lat and lon values and then form bounding rectangle for a query. This Question tells you how to calculate a bounding box that covers a given radius around your current point (it will be a box, so it will be bigger than a circle....

如何计算边界给定纬度/经度位置的框?

使用边界框,您现在可以从您的数据库中进行查询 where lat <maxlat 和 lat >minlat 和 lon >minlon 和 lon <maxlon 将在框中为您提供所有感兴趣的点.

Using the bounding box, you can now do a query from your db where lat < maxlat and lat > minlat and lon > minlon and lon < maxlon which will give you all your points of interest within the box.

然后,使用 Android api 中的 Location 类,您可以使用它来计算每个点击的方位角和距离,然后您可以例如按您所在位置的半径排序.

Then, using the Location class in the Android api, you can get it to calculate the bearing and distance to each of the hits and then you could for instance, sort by radius from your position.

这篇关于给定 GPS 坐标,我如何找到附近的地标或兴趣点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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