Archive for May, 2009

ITM <-> WGS84 (<-> Irish Grid <-> British National Grid) PHP code

Wednesday, May 13th, 2009

With Ireland soon to be moving to ITM (Irish Transverse Mercator) coordinates, over IG (Irish Grid) that has been used since about 1965 in Ireland, many websites – including and will be looking to support ITM coordinates – even if they still use Irish Grid.

So to that end have been looking for PHP code to do the conversion, but thanks to a little bit of inspiration from’s Javascript Ireland Coordinate Converter (an excellent resource in its own right!), realised it would be simple to add to the conversion class we already use. In fact as ITM is based on GRS80 which is effectivly WGS84 the conversion was just a matter of plugging in the constants used by ITM, and the code just worked.

Better yet as Geograph is Open Source (and we got permission to open source the code based on OSGB’s conversion spreadsheet), the code is available for anyone to use as a PHP class. It should be trivial to add support to our Javascript class – which will do shortly!

Grab the class from Geograph SVN (or even better do a SVN checkout!) and put it somewhere safe. (but you will probably want to remove the “extends Conversions” bit from the definition – we use that for convience in Geograph source)

Then can just use it

$conv = new ConversionsLatLong;
list($lat,$lng) = $conv->itm_to_wgs84($e,$n);

But as we already use the same code for Irish Grid, and OSGB36 British National Grid, can also use it for them, and even IG< ->ITM conversion

list($lat,$lng) = $conv->itm_to_wgs84($e,$n);
list($lat,$lng) = $conv->irish_to_wgs84($e,$n,true);
list($lat,$lng) = $conv->osgb_to_wgs84($e,$n);

list($e,$n) = $conv->wgs84_to_itm($lat,$lng);
list($e,$n) = $conv->wgs84_to_irish($lat,$lng,true);

list($e,$n) = $conv->wgs84_to_osgb36($lat,$lng);
//even a short convience function to create a 10 figure grid reference
$gr10 = $conv->osgb36_to_gridref($e,$n);

See it used in anger here and here.

Multi Destination Routing + Altitude Profile

Friday, May 8th, 2009

There is a tool on nearby for taking a multi destination route – and loading it into Google Earth. It was also used to load directions into a “My Map”, but thats basically redundant now, but as the script just converts the directions to a KML file, there are many useful things that can be done with it…

Such as plotting an altitude profile with***, but to make it even easier, have added a button to the page, that links direct to the form on gpsu with the data prefilled as well as the ‘add altitude’ option enabled.

Enjoy! (Oh and let me know if there are any other interesting destinations would like to load the KML file into!)

Multi Destination Routing Toolkit

*** which Adam recently added the functionalty to add alitude automatically – previsoully a problem as the KML files from Google maps dont include altitude