Skip to content

Instantly share code, notes, and snippets.

@MarkBaker
MarkBaker / gpxTracker.md
Last active August 29, 2015 14:27
Cat-Tracker - A PHP Generator-based Reader for reading GPX trackpoint files

This is a simple reader class for gpx files retrieved from the G-Paws Cat Tracker that allows you to loop over the trackpoints read from that file, returning lat/lon as attributes of a simple stdClass object as the returned "key" from the Reader, and ele/time as attributes of a simple stdClass object as the returned "value"

The Reader class

class gpxReader
{

    public function __construct($fileName)
    {
@MarkBaker
MarkBaker / UK Postcode Parse
Last active August 29, 2015 14:06
UK Postcode Parsing
function parsePostcode2($postcode) {
$postcode = preg_replace('/\s*/','',strtoupper($postcode));
$sector = substr($postcode,0,-2);
$outcode = $district = substr($sector,0,-1);
list($area) = sscanf($district,'%[A-Z]');
$incode = substr($postcode,-3);
return array(