适用于iPhone的地理空间库 [英] Geospatial library for the iPhone

查看:124
本文介绍了适用于iPhone的地理空间库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑通过打包一系列兴趣点(POI)来创建一个可以脱机工作的位置感知iPhone应用程序。该应用程序将从 CoreLocation 中读取用户的当前位置,并按照与用户当前位置的接近顺序生成POI列表。

I'm thinking about creating a location-aware iPhone app that could work offline by coming packaged with a list of points of interest (POIs). The app would read the user's current location from CoreLocation and produce a list of the POIs in order of proximity to the user's current location.

我需要两个基本的地理空间功能才能让这个应用程序开始运行。第一个是测试点(用户的当前位置)是否位于某些地理空间边界内的函数。第二个函数可以给出两个纬度/经度点之间的距离。我会使用第二个函数来根据用户当前位置的接近程度对POI列表进行排序。

I need two basic geospatial functions to get this application off the ground. The first is a function that tests if a point (the user's current location) lies within certain geospatial boundaries. The second is a function that can give me the distance between two lat/lon points. I would use the second function to sort the list of POIs by proximity to the user's current location.

我知道这个问题区域已经很好了,并且有开源选项。主要候选人(我所知道的)是 GEOS C ++库。我想象的方法是使用它来将GEOS编译为静态库(并将其作为项目依赖项链接,就像包含 three20 库。)

I understand that this problem area is well traveled and there are open-source options. The leading candidate (that I know of) is the GEOS C++ library. The way I imagine I would use this is by compiling GEOS as a static library (and linking as a project dependency, as you do to include the three20 library.)

我的问题是:


  1. 将两个必要功能纳入我的应用程序的最佳方法是什么。

  1. What is the best way to get the two necessary functions into my application.

如果问题1的最佳答案是将GEOS编译为一个静态库,并将其链接到我的项目,任何人之前做过这一点的人是否可以提供一些指示?我是编译,静态库构建等的新手。我希望看到一些示例代码或教程,介绍如何编译GEOS并将其包含在项目中,并使用一些简单的示例。

If the best answer to question 1 is compiling GEOS as a static library and linking it to my project, could anyone who has done this before offer some pointers? I'm a novice at compilation, static library building, etc. I would love to see some example code or tutorials on how to get GEOS compiled and included in a project with a trivial example usage.


推荐答案

对于点之间的距离,请参阅 CLLocation 's getDistanceFrom:方法。

For distance between points, see CLLocation's getDistanceFrom: method.

我不确定你的地理空间边界是什么意思,但如果你的意思是你有定义位置的矩形,您可以将其转换为 CGRect ,将所有点的纬度和经度分别偏移90和180,以确保您没有负数,将 CLLocation 对象转换为 CGPoint s,然后使用 CGRectContainsPoint 确定您的位置是否在该矩形内。

I'm not sure what you mean by geospatial boundaries, but if you mean you have a rectangle defining a location, you can convert it to a CGRect, offset the latitude and longitude of all of your points by 90 and 180 respectively to make sure you don't have negative numbers, convert your CLLocation objects to CGPoints, then use CGRectContainsPoint to figure out if your location is within that rectangle.

所有描述的功能都是标准iPhone SDK的一部分。

All of the described functions are part of the standard iPhone SDK.

这篇关于适用于iPhone的地理空间库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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