<?php include '../classes/Bootstrap.php'; $latLiverpool = 53.40863; $longLiverpool = -2.991746; $height = 0.0; $latLongLiverpool = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($latLiverpool, $longLiverpool, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); echo 'Starting Point: Liverpool', PHP_EOL; echo ' Latitude: ', $latLongLiverpool->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Longitude: ', $latLongLiverpool->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Height: ', $latLongLiverpool->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; $bearing = new \Geodetic\Angle(135, \Geodetic\Angle::DEGREES); $distance = new \Geodetic\Distance(500, \Geodetic\Distance::KILOMETRES); echo 'Initial Bearing: ', $bearing->toDM(0), PHP_EOL; echo 'Distance: ', $distance->getValue(\Geodetic\Distance::KILOMETRES), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; $destination = $latLongLiverpool->getDestination($bearing, $distance); echo PHP_EOL; echo 'FinalDestination: ', $destination->getLatitude()->toDMS(2), ' ', $destination->getLongitude()->toDMS(2), PHP_EOL;
<?php include '../classes/Bootstrap.php'; $lat = 53.408630096933194; $long = -2.991746664047241; $height = 0.0; $latLong = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($lat, $long, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); echo PHP_EOL; echo 'Latitude: ', $latLong->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo 'Longitude: ', $latLong->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo 'Height: ', $latLong->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; echo PHP_EOL, 'Convert to ECEF', PHP_EOL, PHP_EOL; $datum = new \Geodetic\Datum(\Geodetic\Datum::WGS84); $ecef = $latLong->toECEF($datum); // http://www.oc.nps.edu/oc2902w/coord/llhxyz.htm echo 'X: ', $ecef->getX()->getValue(\Geodetic\Distance::KILOMETRES), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; echo 'Y: ', $ecef->getY()->getValue(\Geodetic\Distance::KILOMETRES), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; echo 'Z: ', $ecef->getZ()->getValue(\Geodetic\Distance::KILOMETRES), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; echo PHP_EOL, 'Convert back to Lat/Long', PHP_EOL, PHP_EOL; $newLatLong = $ecef->toLatLong($datum); echo 'Latitude: ', $newLatLong->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo 'Longitude: ', $newLatLong->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo 'Height: ', $newLatLong->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL;
<?php include '../classes/Bootstrap.php'; $latLiverpool = 53.40863; $longLiverpool = -2.991746; $latLondon = 51.516481; $longLondon = -0.128649; $height = 0.0; $latLongLiverpool = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($latLiverpool, $longLiverpool, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); $latLongLondon = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($latLondon, $longLondon, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); echo 'Liverpool', PHP_EOL; echo ' Latitude: ', $latLongLiverpool->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Longitude: ', $latLongLiverpool->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Height: ', $latLongLiverpool->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; echo PHP_EOL; echo 'London', PHP_EOL; echo ' Latitude: ', $latLongLondon->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Longitude: ', $latLongLondon->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Height: ', $latLongLondon->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; $haversineDistance = $latLongLiverpool->getDistanceHaversine($latLongLondon); $vincentyEllipsoid = new \Geodetic\ReferenceEllipsoid(\Geodetic\ReferenceEllipsoid::WGS_84); $vincentyDistance = $latLongLiverpool->getDistanceVincenty($latLongLondon, $vincentyEllipsoid); echo PHP_EOL; echo 'Distance between Liverpool and London', PHP_EOL; echo ' Using Haversine formula: ', round($haversineDistance->getValue(\Geodetic\Distance::KILOMETRES), 4), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; echo ' Using Vincenty formula: ', round($vincentyDistance->getValue(\Geodetic\Distance::KILOMETRES), 4), ' ', \Geodetic\Distance::KILOMETRES, PHP_EOL; $initialBearing = $latLongLiverpool->getInitialBearing($latLongLondon); echo 'Initial Bearing: ', round($initialBearing->getValue(\Geodetic\Angle::DEGREES), 3), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; $finalBearing = $latLongLiverpool->getFinalBearing($latLongLondon); echo 'Final Bearing: ', round($finalBearing->getValue(\Geodetic\Angle::DEGREES), 3), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; $midpoint = $latLongLiverpool->getMidpoint($latLongLondon);