Solving Puzzle Geocaches Programmatically

November 1st 2019 Geocaching GPS

Puzzle geocaches often require some calculations to determine the final coordinates. That's particularly common in GeoArt trails. Although some of these trails can be quite long, I had always solved them manually. Until I encountered the Pirate Cruise trails near Split in Croatia, that is. Almost 500 caches requiring geodetic calculations were too many to do by hand. I decided to find a way to automate the calculations.

GSAK (Geocaching Swiss Army Knife) was an obvious first choice for me since I'm already using it for planning and logging almost all of my geocache finds. Importing all the geocaches from these trails was easy enough with its built-in tool:

Importing Pirate Cruise geocaches into GSAK

I configured the following filter:

  • Cache types: Mystery
  • Country: Croatia
  • Name contains: Pirate Cruise

Although it's very likely that I could calculate the final coordinates with a custom macro, I wanted to use tools I'm more familiar with to minimize the effort required. To make geocache details available to any external tool, I exported them into a GPX file first.

Exporting geocaches from GSAK as GPX

Before continuing, I also made sure that I'll be able to import back the final coordinates once I calculate them. The Import Corrected Coordinates macro was exactly the right tool for the job.

I decided to implement my tool as a .NET Core console application. The processing consisted of three steps:

  • Load the cache data by parsing the GPX file as an XML document and extracting the calculation inputs from the description.
  • Perform the geodetic calculations using the Geo geospatial library.
  • Export the calculated final coordinates into a CSV file.

I published the project on GitHub in case someone else might find it useful.

With final coordinates imported back into GSAK, I was ready to download them to my GPS device.

To make planning easier and to visually check that the calculations were correct, I also wanted to upload the corrected coordinates back to the Geocaching site to render them on the map. There's a macro for that as well: Transfer Corrected Coordinates 2 Online Cache Page.

Actual locations of Pirate Cruise geocaches

Automating the calculations turned out really well and saved me quite some time. With all the necessary tools already at my disposal, I'm more likely to automate other calculations in the future as well.

Get notified when a new blog post is published (usually every Friday):

If you're looking for online one-on-one mentorship on a related topic, you can find me on Codementor.
If you need a team of experienced software engineers to help you with a project, contact us at Razum.
Creative Commons License