The LatLngDistance function takes two latitudes/longitudes and calculates the surface distance between the two in kilometres:
$lld1 = new LatLng(40.718119, -73.995667); // New York echo "New York Lat/Long: " . $lld1->toString() . "<br />"; $lld2 = new LatLng(51.499981, -0.125313); // London $d = $lld1->distance($lld2); echo "Surface Distance between New York and London: " . $d . "km";New York Lat/Long: (, )
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.
Using OSGB36 (convert an OSGB grid reference to a latitude and longitude using the OSGB36 datum):
$os1 = new OSRef(651409.903, 313177.270); echo "OS Grid Reference: " . $os1->toString() . " - " . $os1->toSixFigureString() . "<br />"; $ll1 = $os1->toLatLng(); echo "Converted to Lat/Long: " . $ll1->toString();OS Grid Reference: (, ) - SV000000