Search airport by city name

I recently came across a case where I have an airport list (my data), city list (input data) and I have to map them.

The thing is not all the airport and city have similar name. They can be very different like Vieux Fort city and Hewanorra International Airport (UVF). I need to come up with a small service that take city name as input and output their possible nearby airports.

What I did was

  • I use Google Maps Reverse Geocoding API to find the city’s longitude and latitude and cache it. Since Google Maps has a limit of 10 requests per second and 2,500 request daily. Without caching it, my app would crash within seconds. I used redis here.

  • Since this is one time thing, I will try to use the free tier of Google Maps API if possible without having to pay. I might take a look at using proxy for removing that free tier cap.

  • I will have to find distance between that input city and all the airports. Doing this would be super slow so you would want to consider all the city in that country only.

Few things to note here:

  • redis is awesome cache solution. Since I already use redis for caching, and it can do geo proximity calculation, I wonder why not.

  • Google Maps API is not very reliable. Occasionally, you will see many dumb data which played havoc to my service. Hence I’m only using this as last resort if I can’t map using other method.