As we expect many folk to be playing with the new OS Open datasets we thought we’d share some javascript code that we have been using to convert from WGS84 lat/long coordinates to the British National Grid. We ported this from existing Java code we know is sound. The Javascript version works ok but there are some rounding errors as can be seen from this test, which converts from a lat, lon to National Grid, then back again. Good enough for most mobile apps we think but use at your own risk as its not fully tested.
Some example code to convert your GPS fix to NG coordinates:
var natgrid = new Edina.EPSG_27700() ;
var coords ;
coords = natgrid.toLocalSystem( latt, lont );
document.getElementById('northing').innerHTML="northing: " + coords[0] ;
document.getElementById('easting').innerHTML="easting: " + coords[1] ;
the GIS experts I work with think the rounding error equates to 10cm.
By: benismobile on April 2, 2010
at 2:59 pm
[…] low level functions to cope with this projection. We had to use our own javascript utilities (the coordamatic library) for unit and projection changes to get it working […]
By: touchMapLite framework notes | Geo-Mobile Blog on July 16, 2010
at 10:15 am