Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find nearest airport using iOS

Tags:

iphone

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

like image 909
TheLearner Avatar asked Dec 05 '25 12:12

TheLearner


2 Answers

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:

like image 173
Claus Broch Avatar answered Dec 08 '25 04:12

Claus Broch


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.

like image 45
Dan Ray Avatar answered Dec 08 '25 04:12

Dan Ray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!