Main screen of SnapTrip
I love traveling. When I am not traveling, I like to spend time on inspirational travel picture websites or social media to find my next destination. Every time I see an amazing photo I want to know where it is and how much it will cost me to go there on holidays. Until now, I did not find any easy way to find the location of a picture and have an idea of how much it costs to travel there.
What will be simpler than just taking a photo and instantaneously have a list of trip offers including flight tickets and hotel rooms from my current location to the desired one?
What it does
With SnapTrip you can easily get different Trip offers (including flights and hotel rooms) from where you are to an amazing destination you saw on social media.
SnapTrip is an Android application that allows you to take a photo of a famous place (monument or landmark) you saw on social media or any locations with destination pictures. The app will automatically locate your position, find where the destination picture is and build for you different trip packages to go there.
Let's imagine you live in Madrid and you saw a photo of the Statue of Liberty on Facebook. You can start your mobile app SnapTrip, take a photo of the photo (yes yes), wait for a couple of seconds and see how much it will cost you to travel to New-York, stay at the hotel a couple of nights and come back!
How I built it
I decided to build the Android application using Kotlin (as I wanted to learn a new programing language).
To find coordinates from a location name I used the Bing Maps API (Find a Location by Query).
For all travel-related data, I used the Amadeus for Developers Self-Service APIs. I had to write a Kotlin wrapper of their Java SDK to manage asynchronous & multi-threads calls in Android.
The application has been developed using Android SDK version 28.
Everything starts by taking a photo of a monument with SnapTrip. The app will find the coordinates of your current location (by localizing your phone). It will then use the Cognitive Vision API to find the name of the monument/landmark.
The Cognitive Vision API does not return the coordinates of the place. For this I combined the response of the vision API with the Bing Maps API to retrieve the coordinates based on the location name.
When I have both geo-locations, I’m using the Nearest Relevant Airports from Amadeus to retrieve the IATA codes of the closest airports (from the user thanks to the phone location and the monument's place thanks to the Microsoft APIs).
Then comes a bit of internal logic, the Flight Search API works with airport IATA codes, but the Hotel Search API requires the city IATA codes (for example the city code of Paris is PAR but the airport codes are CDG (Charles De Gaulle) and ORY (Orly)). The Nearest Relevant Airports API only returns airport IATA codes. To get city codes I used the Airport & City Search API.
With the airports IATA codes, I search for flights at different dates to find the best offers from all available airlines. Out of the result, I sort to keep only the flights with a maximum of one stop (layover). Then, I search for the best hotel offers at the destination with rooms available during the dates matching the flights. By combining both, I build different trip packages that I will show to the user.
Challenges I ran into
As first: learning Kotlin. I have some experience with Java but I wanted to learn a new language and Kotlin was on top of my list. I cannot say that I know how to develop with Kotlin now, but I learned a lot!
The integration of the Cognitive Vision API went smoothly thanks to the library, the main problem was to manage the parallel threads and the asynchronous calls required by Android (it was something new for me). Recognizing the picture's was only the first step, I needed then to get the coordinates of the place to find the closest airport. The Azure Cognitive Vision API does not return the coordinates. I had to use the Bing Maps API that returns coordinates based on a name of a location.
Then for all travel data, I developed a Kotlin wrapper on top of the Java SDK of Amadeus for Developers (to manage asynchronous and multi-thread calls).
Amadeus Self-Service APIs comes with limitations in the test environment (limitation of data, limitation on the API call parallelization you can do and limitation on the response time of the API) but it offers access to all their APIs free of charge, which is perfect for prototyping. I tried to optimize as much as I could the response time by parallelizing the flight and hotel searches, it can still be a bit slow (a few seconds). You can sometimes face a "network rate limit is exceeded" error, that seems to come from their API management platform, please try again if it is the case.
The last step was to combine the data to build the trip package including hotels and flights. My knowledge of Android and UI development is quite limited, it was a challenge to build the list of trip packages with all the important information keeping a nice and user-friendly UI.
Accomplishments that I'm proud of
I am proud to have an up and running Android app written in Kotlin. I am really happy to have learned more about image recognition and to have been able to combine many different technologies and libraries.
And I am proud to now have an app that helps me to quickly and easily know how much it cost to travel to many different places. This will inspire me for my next trips!
What I learned
- Kotlin programing language
- Azure Cognitive APIs - I am really impressed by how the AI API is able to recognize the locations!
- Bing Maps API
- Android framework
What's next for SnapTrip
I want to keep improving the app:
In the next version of SnapTrip, you will be able to select a trip package to get more details about the hotel and the flight suggested. I would like to include the sentiment analysis of hotels, so the user will know if the hotel suggested is the best of her/his interest.
By using Avuxi technology, I will be able to add information about points of interest to see what are the most interesting things to do at the destination.
I would like to ingrate the content of the startup GeoSure, that helps to better understand safety in different districts of a city. Thanks to this, I would be able to find better the best location for the hotel and ensure the safety of the traveler.
Amadeus just released an API to do flight booking, the next step will be to integrate it to be able to book the flights directly from the app. They plan to deliver the hotel booking by the end of the year: this will allow the users to book the full trip directly in SnapTrip!
SnapTrip will continue to evolve with time, this will give me a good opportunity to keep learning Kotlin and trying to integrate different other technologies! :)