Distance
class Distance implements DistanceInterface
Properties
protected CoordinatesInterface | $from | The origin coordinate. |
|
protected CoordinatesInterface | $to | The destination coordinate. |
|
protected string | $unit | The user unit. |
|
protected array | $data |
Methods
Get the origin coordinate
Get the destination coordinate
Set the user unit
Get the user unit
No description
No description
Returns the approximate flat distance between two coordinates using Pythagoras’ theorem which is not very accurate.
Returns the approximate distance between two coordinates using the spherical trigonometry called Great Circle Distance.
Returns the approximate sea level great circle (Earth) distance between two coordinates using the Haversine formula which is accurate to around 0.3%.
Returns geodetic distance between between two coordinates using Vincenty inverse formula for ellipsoids which is accurate to within 0.5mm.
Converts results in meters to user's unit (if any).
Details
at line 39
DistanceInterface
setFrom(CoordinatesInterface $from)
Set the origin coordinate
at line 49
CoordinatesInterface
getFrom()
Get the origin coordinate
at line 57
DistanceInterface
setTo(CoordinatesInterface $to)
Set the destination coordinate
at line 67
CoordinatesInterface
getTo()
Get the destination coordinate
at line 75
DistanceInterface
in(string $unit)
Set the user unit
at line 82
string
getUnit()
Get the user unit
at line 93
DistanceInterface
withData(string $name, mixed $value)
No description
at line 106
mixed
getData(string $name, mixed|null $default = null)
No description
at line 123
float
flat()
Returns the approximate flat distance between two coordinates using Pythagoras’ theorem which is not very accurate.
at line 148
float
greatCircle()
Returns the approximate distance between two coordinates using the spherical trigonometry called Great Circle Distance.
at line 174
haversine()
Returns the approximate sea level great circle (Earth) distance between two coordinates using the Haversine formula which is accurate to around 0.3%.
at line 199
float
vincenty()
Returns geodetic distance between between two coordinates using Vincenty inverse formula for ellipsoids which is accurate to within 0.5mm.
at line 267
float
convertToUserUnit(float $meters)
Converts results in meters to user's unit (if any).
The default returned value is in meters.