Step 2 - Producing active and unfound caches

The next step is to produce what I call my active file - a GPX of all caches in New Zealand that I haven't found, haven't placed, and the caches are currently active.

Thanks to the power of GPSBabel, this takes only one command - although it is long, and can seem a little confusing.

gpsbabel -i gpx -f caches-nz.gpx -f caches-world-found.gpx \
  -f caches-world-found.gpx -f caches-nz-placed.gpx \
  -f caches-nz-placed.gpx -f caches-nz-unavailable.gpx \
  -f caches-nz-unavailable.gpx -x duplicate,shortname,all \
  -o gpx -F caches-nz-active.gpx
echo "Produced: Caches Active/Unfound (NZ)"

What does this do?

Firstly, we feed it the file containing all caches in New Zealand. Next comes the first bit of a little magic. We then feed GPSBabel two copies of each of the GPX files containing the caches we want to remove - namely those I have found (caches-world-found.gpx), those I have placed (caches-nz-placed.gpx) and finally those that are unavailable (caches-nz-unavailable.gpx).

So now, GPS Babel has all the geocache waypoints in New Zealand, and many of them more than once - and this is the key. Those caches I have placed will be there three times (caches-nz.gpx and caches-nz-placed.gpx x2). In this particular case we could actually get by with only adding caches-nz-placed.gpx once as it is a direct subset of caches-nz.gpx. My world finds is the file that throws a spanner in the works - as it adds some unique geocaches that are not in caches-nz.gpx. These would show up in my active file which I don't want. By adding the files twice - we ensure that no unique waypoints from those files are added to my active list of NZ caches.

Now, how does the magic occur? This is all it takes.

-x duplicate,shortname,all

This runs all the waypoints through a filter, and only outputs those that appear once. As all my finds, my hides and the unavailable caches were added twice - they are all removed.

Hey presto - I've got a caches-nz-active.gpx file that now has only caches I've yet to find in New Zealand. The problem now, is that it is one very big file - as I write this today it is just over 9.3Mb. I don't need all these files, so next it is time to use some of the spatial filtering that GPSBabel provides.