| 1 | <?php |
||
| 4 | class Coordinate |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * Latitude in radians |
||
| 8 | * |
||
| 9 | * @var float |
||
| 10 | */ |
||
| 11 | private $_latitude; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Longitude in radians |
||
| 15 | * |
||
| 16 | * @var float |
||
| 17 | */ |
||
| 18 | private $_longitude; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Initialize a coordinate. |
||
| 22 | * |
||
| 23 | * @param float $latitude The latitude in radians |
||
| 24 | * @param float $longitude The longitude in radians |
||
| 25 | */ |
||
| 26 | public function __construct($latitude, $longitude) |
||
| 27 | { |
||
| 28 | $this->_latitude = $latitude; |
||
| 29 | $this->_longitude = $longitude; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Convert the latitude to radians. |
||
| 34 | * |
||
| 35 | * @return float The latitude in radians. |
||
| 36 | */ |
||
| 37 | public function latitudeInRadians() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Convert the longitude to radians. |
||
| 44 | * |
||
| 45 | * @return float The longitude in radians. |
||
| 46 | */ |
||
| 47 | public function longitudeInRadians() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Convert the latitude to degrees. |
||
| 54 | * |
||
| 55 | * @return float The latitude in degrees. |
||
| 56 | */ |
||
| 57 | public function latitudeInDegrees() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Convert the longitude to degrees. |
||
| 64 | * |
||
| 65 | * @return float The longitude in degrees. |
||
| 66 | */ |
||
| 67 | public function longitudeInDegrees() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Return the latitude and longitude in degrees as a string. |
||
| 74 | * |
||
| 75 | * @return string A string representation of the coordinate. |
||
| 76 | */ |
||
| 77 | public function __toString() |
||
| 81 | } |
||
| 82 |