Inspiration

We were inspired by navigation apps like Google/Apple Maps and their ability to quickly calculate the optimal path for any trip. We wanted to create our own version at a smaller scale with a dash of Christmas magic.

What it does

Stranded Santa finds the shortest path between two cities by distance given a connected network of the top 40 cities by population and animates the journey along that path. To find the shortest path, we implemented Djikstra's algorithm which finds all of the shortest paths to other cities from the origin city and returns a list for the shortest path from the origin city to the destination. To animate this path, we used the matplotlib library to first plot all of the points/routes then rotate the plot to simulate travelling along the path.

Challenges we ran into

Finding accurate (x, y, z) coordinate data for the Earth's continents/landmasses was surprisingly difficult, so we opted to find all of the coordinates by hand. It was very time consuming, but it worked great and created a roughly accurately sized Earth so paths are true to length.

It was also difficult to properly animate the journey along the path, but we eventually realized that we could use the decimal latitude/longitude coordinates for the cities to guide matplotlib's rotation. So, we calculated every angle of rotation used in the animation depending on which cities it is moving between and fed it to matplotlib frame by frame.

Accomplishments that we're proud of

We're proud of the speed of the program as we initially thought it may be too slow with the number of potential paths to check. However, this turned out not to be a problem with only 40 cities. We also really enjoy the animation as it runs smoothly and adds a lot to the user experience of calculating Santa's route.

What we learned

We learned a lot about using Python libraries--especially matplotlib--and graph algorithms like Djikstra's. It also helped us think more about keeping data organized when dealing with hundreds of points to plot around the globe.

Built With

Share this project:

Updates