tags:

views:

40

answers:

2

I am writing an App that needs to find the closest international airports using the iPads GPS. Is there anyway of doing this easily?

+1  A: 

Do you already have the airport data?

If so, you'll start by creating a CLLocation for each airport. Then you'll sort that list using a comparison method that returns [CLLocation distanceFromLocation:]. That way you can sort your airport list by the closest to the current coordinates.

Dan Ray
+4  A: 

You may use the free services at GeoNames to search for nearby places. These can be filtered to only return airports as in this example:

http://ws.geonames.org/findNearbyJSON?lat=40&lng=9&radius=250&featureClass=S&featureCode=AIRP

This will return all places designated as airports whether they are big or small. You may need to tweak the parameters to better suit your needs.

If you are looking for more filtered/proffesional searches, you may have a look at what companies like FlightStats offer. These services are however not free.

Once you have a list of places (one way or the other) you can the get the distance to these using CoreLocation to calculate this with distanceFromLocation:

Claus Broch
Thanks mate, awesome!
TheLearner