English 中文(简体)
Geospatial library for the iPhone
原标题:

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.

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.

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.)

My question is:

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

  2. 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.

最佳回答

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

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.

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

问题回答

Ok, it took me some time but now I think that I m properly able to build the static libs or GEOS for iPhone (x86 and ARM for both the simulator and the real device) : libgeos.a and libgeos_c.a : the implementation and its api.

You can get the binaires there (for GEOS version 3.1.1, this is not the very last one) : http://bit.ly/aTKsI6

(there are some other binaries there, the rest is for spatialite)

The job has been mostly achieved by understanding the way cross compilation is done via .sh scripts. This blog is a must see for that : http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签