1 | <?php |
||
45 | class GeoUri extends Uri |
||
46 | { |
||
47 | /** |
||
48 | * Geo schema |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | const SCHEME_GEO = 'geo'; |
||
53 | /** |
||
54 | * Regular expression for matching the Geo coordinates |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | const GEO_REGEX = '(?P<latitude>-?\d+(?:\.\d+)?),(?P<longitude>-?\d+(?:\.\d+)?)(?:,(?P<altitude>-?\d+(?:\.\d+)?))?'; |
||
59 | /** |
||
60 | * Latitude |
||
61 | * |
||
62 | * @var float |
||
63 | */ |
||
64 | protected $latitude; |
||
65 | /** |
||
66 | * Longitude |
||
67 | * |
||
68 | * @var float |
||
69 | */ |
||
70 | protected $longitude; |
||
71 | /** |
||
72 | * Altitude |
||
73 | * |
||
74 | * @var float |
||
75 | */ |
||
76 | protected $altitude; |
||
77 | |||
78 | /** |
||
79 | * Constructor |
||
80 | * |
||
81 | * @param string $uri Geo URI |
||
82 | * @throws InvalidArgumentException If the Geo URI doesn't suffice RFC 5870 |
||
83 | */ |
||
84 | 4 | public function __construct($uri) |
|
100 | |||
101 | /** |
||
102 | * Return the latitude |
||
103 | * |
||
104 | * @return float latitude |
||
105 | */ |
||
106 | 1 | public function getLatitude() |
|
110 | |||
111 | /** |
||
112 | * Return the longitude |
||
113 | * |
||
114 | * @return float Longitude |
||
115 | */ |
||
116 | 1 | public function getLongitude() |
|
120 | |||
121 | /** |
||
122 | * Return the altitude |
||
123 | * |
||
124 | * @return float Altitude |
||
125 | */ |
||
126 | 1 | public function getAltitude() |
|
130 | |||
131 | /** |
||
132 | * Serialize the Geo URI |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 1 | public function __toString() |
|
144 | } |
||
145 |