Convert this grid reference into a string using a standard six-figure
grid reference including the two-character designation for the 100km
square. e.g. TG514131.
public toSixFigureString ( ) |
echo "Converted to Lat/Long: " . $ll1->toString(); ?> </p> <p> Using WGS84 (convert an OSGB grid reference to a latitude and longitude using the WGS84 datum): <pre>$os1w = new OSRef(651409.903, 313177.270); echo "OS Grid Reference: " . $os1w->toString() . " - " . $os1w->toSixFigureString() . "<br />"; $l1w = $os1w->toLatLng(); $l1w->OSGB36ToWGS84(); echo "Converted to Lat/Long: " . $ll1w->toString();</pre> <?php $os1w = new OSRef(651409.903, 313177.27); echo "OS Grid Reference: " . $os1w->toString() . " - " . $os1w->toSixFigureString() . "<br />"; $ll1w = $os1w->toLatLng(); $ll1w->OSGB36ToWGS84(); echo "Converted to Lat/Long: " . $ll1w->toString(); ?> </p> <h2>Convert Latitude/Longitude to OS Grid Reference</h2> <p> Note that the OSGB-Latitude/Longitude conversions use the OSGB36 datum by default. The majority of applications use the WGS84 datum, for which the appropriate conversions need to be added. See the examples below to see the difference between the two data. </p> <p>
public function testToSixFigureString2() { $OSRef = new OSRef(439145, 274187); $expected = 'SP391741'; self::assertEquals($expected, $OSRef->toSixFigureString()); }