Dove's Guide for Church Bell Ringers

PHP code for generating ov2 binary files

During the course of developing the Dove website, I received several requests to make location data available for import into TomTom software by providing .ov2 binary POI files. TomTom already distribute an executable to perform an ASCII to binary conversion for creating these files but I wanted to generate the binary file directly, without the end-user having to perform a conversion.

Below is a PHP class to create such files, along with sufficient additional code to provide a working example. Please feel free to reuse this code, whilst retaining a credit to me.


= new ov2file();
$poiFile->filename "MyPOIs.ov2";

$poiFile->add_POI(51.51387, -0.09940"London, S Paul's Cath");
$poiFile->add_POI(51.51758, -0.10645"London, Holborn");
$poiFile->add_POI(51.51872, -0.09920"London, Smithfield");


// ov2file
  // (c) 2006 Sid Baldwin
  // Created on 06-Feb-2006
var $content "";
$filename "default.ov2";
add_POI($lat,$long,$text) {
$this -> content .= "\x02";
$this -> content .= pack("I"14 strlen($text));
$this -> content .= pack("i"round($long*100000));
$this -> content .= pack("i"round($lat*100000));
$this -> content .= $text;
$this -> content .= "\x00";

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename={$filename}");
header("Content-Transfer-Encoding: binary");


Sid Baldwin, Feb 2006