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); echo 'Midpoint: ', $midpoint->getLatitude()->toDMS(3), ' ', $midpoint->getLongitude()->toDMS(3), PHP_EOL;
include '../classes/Bootstrap.php'; $latTokyo = 35.681841; $longTokyo = 139.758797; $latSeattle = 47.601533; $longSeattle = -122.328644; $height = 0.0; $latLongTokyo = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($latTokyo, $longTokyo, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); $latLongSeattle = new \Geodetic\LatLong(new \Geodetic\LatLong\CoordinateValues($latSeattle, $longSeattle, \Geodetic\Angle::DEGREES, $height, \Geodetic\Distance::METRES)); echo 'Tokyo', PHP_EOL; echo ' Latitude: ', $latLongTokyo->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Longitude: ', $latLongTokyo->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Height: ', $latLongTokyo->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; echo PHP_EOL; echo 'Seattle', PHP_EOL; echo ' Latitude: ', $latLongSeattle->getLatitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Longitude: ', $latLongSeattle->getLongitude()->getValue(), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; echo ' Height: ', $latLongSeattle->getHeight()->getValue(), ' ', \Geodetic\Distance::METRES, PHP_EOL; $haversineDistance = $latLongTokyo->getDistanceHaversine($latLongSeattle); $vincentyEllipsoid = new \Geodetic\ReferenceEllipsoid(\Geodetic\ReferenceEllipsoid::WGS_84); $vincentyDistance = $latLongTokyo->getDistanceVincenty($latLongSeattle, $vincentyEllipsoid); echo PHP_EOL; echo 'Distance between Tokyo and Seattle', 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 = $latLongTokyo->getInitialBearing($latLongSeattle); echo 'Initial Bearing: ', round($initialBearing->getValue(\Geodetic\Angle::DEGREES), 3), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; $finalBearing = $latLongTokyo->getFinalBearing($latLongSeattle); echo 'Final Bearing: ', round($finalBearing->getValue(\Geodetic\Angle::DEGREES), 3), ' ', \Geodetic\Angle::DEGREES, PHP_EOL; $midpoint = $latLongTokyo->getMidpoint($latLongSeattle); echo 'Midpoint: ', $midpoint->getLatitude()->toDMS(2), ' ', $midpoint->getLongitude()->toDMS(2), PHP_EOL;