haversine.php
Table of Contents
Functions
- haversine() : float
- Calculate the great-circle distance between two points on a sphere using the Haversine formula.
Functions
haversine()
Calculate the great-circle distance between two points on a sphere using the Haversine formula.
haversine(float $latitude1, float $longitude1, float $latitude2, float $longitude2[, float $radius = 6371000 ][, int|null $precision = null ]) : float
This is commonly used for distances on Earth. It's faster than the Vincenty formula but less precise.
Parameters
- $latitude1 : float
-
The latitude of the first point in degrees.
- $longitude1 : float
-
The longitude of the first point in degrees.
- $latitude2 : float
-
The latitude of the second point in degrees.
- $longitude2 : float
-
The longitude of the second point in degrees.
- $radius : float = 6371000
-
The radius of the sphere (default is Earth's mean radius: 6,371,000 meters).
- $precision : int|null = null
-
Number of decimal places to round to. If null, returns full precision.
Tags
Return values
float —The distance between the two points in meters.