SourceForge.net Logo
Current version: 0.9.4 (23.05.2006)
Go straight to the project page to download the XML files and PHP demo code

Share and use geocache data easily!

There are several websites available which allow every geocaching enthusiast the option of adding his own geocache listing for free. However every geocacher is constantly confronted with the problem that he has to visit several websites to find caches by location in general regardless of the website so he either has to focus on one or just a few websites or spend much time. As a geocacher normally wants as many people as possible finding his hidden cache he usually has to list his cache on several websites. That however is not only time-consuming but also leads to the problem of distributed cache logs which is also something that is not normally desired.
That must not be! Technology is here to help us, not to enslave us!
So I have come up with this platform- and website-independent format that is both free and offers a kind of standard as nothing of that kind exists (yet).

The OpenCacheFormat (XML)

The OpenCacheFormat is simply a new XML schema that defines a specific set of XML file format. This means that is is fully operating-system and website-independent and can be incorporated into any website and application. There are no licensing fees, nothing to pay whatsoever. Although there do already exist formats for representing geographical data they are not suited for the specific needs of geocachers like hidden coordinates, descriptions, mystery/puzzle caches, spoliers, hints and more. Complete tag listing with examples

Why should I implement the OCF format?

There are several reasons:
  • It is a free (MIT license) format that can be used for both personal and commercial uses
  • It allows other websites to integrate your cache listings on their website ("mashups") leading to more visitors on your website
  • Whether you only want to offer basic information for syndication or the complete data for a given entry depends on you: OCF supports both
  • Hey, itīs XML and thatīs cool! ;-)

Is integrating OCF support complicated?

Well, that depends on your experience and how much data you want to offer.
The final XML (OCF) code can be as simple as this:
<?xml version="1.0" encoding="UTF-8"?>
<ocf>
<caches>
  <cache>
    <name>CACHE09</name>
    <src>MYGEOCACHINGWEBSITE</src>
    <lang>en</lang>
    <type>traditional</type>
    <size>small</size>
    <title>Traditional Cache 01</title>
    <long>51.03733</long>
    <lat>7.458789</long>
    <url>http://www.mygeocachingwebsite.com/viewcache.php?id=CACHE09</url>
  </cache>
</caches>
</ocf>
This data could then - just as one plain example - be integrated with the Google Maps API to create a custom mashup of geocaches for a specific area.
See an example with all the optional attributes    Complete tag listing with examples

Parsing OCF with PHP4 and PHP5 into an array

I have created some Geocache classes encapsulating the OCF and geocaching data. The files are included in the current release in the examples folder. They can be used as easily as follows:
<?php

require "Geocaching/OCFParser.inc.php";
$parser=new OCFParser();

if($ocf=parser->parse('../../ocf-maximal.xml')) {

	if($ocf["caches"]) {
		echo "Found ".sizeof($ocf["caches"])."caches:\n";
		foreach($ocf["caches"] AS $cache) {
			echo "CACHE\n";
			
			while(list($name, $value) = each($cache)) {
				if($name != "attributes" && $name != "waypoints") {
					echo "$name = $value\r\n";
				}
			}
			
			if(is_array($cache["waypoints"])) {
				foreach($cache["waypoints"] AS $waypoint) {
					var_dump($waypoint);
				}
			}
			
			if(is_array($cache["attributes"])) {
				var_dump($cache["attributes"]);
			}
			
		}
	}
}
?>

Creating a Google mashup

The examples included in the release also include some demo code to display a geocache in combination with the Google Maps API. See it in action here

How can I use it? Is it already in use?

Both new and existing websites are hopefully supporting this format. Imagine the magnitude of websites or applications allowing you to freely submit your cache to multiple geocaching websites or to easily edit and copy or send your cache data to friends. On a website focusing for example on a specific landmark (imagine a castle in Scotland, a hotel in Williamsburg, VA etc.) geocaches nearby could be listed with the distance given and more information about the cache. Logging could then be done on the given geocache homepage so it even makes sense creating new websites to add your cache to. Or imagine a service submitting your cache to multiple geocaching websites.

Contact me here for your comments, questions and suggestions