Distance calculations

PHPCoord can calculate the distance between two Points via the calculateDistance() method.

public function calculateDistance(
    Point $to,
): Length
  • The distance between two ProjectedPoints is calculated via Pythagoras

  • The distance between two GeographicPoints or two GeocentricPoints is calculated via Vincenty’s formula

  • The distance between two VerticalPoints is calculated as simple difference

Example

$from = GeographicPoint::create(...);
$to = GeographicPoint::create(...);
$distance = $from->calculateDistance($to);