Index: trunk/extensions/Maps/Includes/Maps_CoordinateParser.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | * TODO: it migt be a lot nicer to return the releveant segments from the regexes instead of manually parsing them out. |
23 | 23 | * |
24 | 24 | * @ingroup Maps |
| 25 | + * @since 0.6 |
25 | 26 | * |
26 | 27 | * @author Jeroen De Dauw |
27 | 28 | */ |
— | — | @@ -37,6 +38,8 @@ |
38 | 39 | * If they are, they will be parsed to a set of non-directional floats, that |
39 | 40 | * will be stored in an array with keys 'lat' and 'lon'. |
40 | 41 | * |
| 42 | + * @since 0.6 |
| 43 | + * |
41 | 44 | * @param string $coordinates The coordinates to be parsed. |
42 | 45 | * |
43 | 46 | * @return array or false |
— | — | @@ -87,6 +90,8 @@ |
88 | 91 | * Returns the type of the provided coordinates, or flase if they are invalid. |
89 | 92 | * You can use this as validation function, but be sure to use ===, since 0 can be returned. |
90 | 93 | * |
| 94 | + * @since 0.6 |
| 95 | + * |
91 | 96 | * @param string $coordinates |
92 | 97 | * |
93 | 98 | * @return Integer or false |
— | — | @@ -113,6 +118,8 @@ |
114 | 119 | /** |
115 | 120 | * Returns a boolean indicating if the provided value is a valid set of coordinate. |
116 | 121 | * |
| 122 | + * @since 0.6 |
| 123 | + * |
117 | 124 | * @param string $coordsOrAddress |
118 | 125 | * |
119 | 126 | * @return boolean |
— | — | @@ -134,6 +141,8 @@ |
135 | 142 | * they will be parsed to the given notation, which defaults to |
136 | 143 | * non-directional floats |
137 | 144 | * |
| 145 | + * @since 0.6 |
| 146 | + * |
138 | 147 | * @param array $coordinates The set of coordinates that needs to be formatted. Either an associative |
139 | 148 | * array with lat and lon keys, or a numbered aray with lat on index 0, and lon on index 1. |
140 | 149 | * @param coordinate type $targetFormat The notation to which they should be formatted. Defaults to floats. |
— | — | @@ -153,6 +162,8 @@ |
154 | 163 | * they will be parsed to the given notation, which defaults to |
155 | 164 | * non-directional floats |
156 | 165 | * |
| 166 | + * @since 0.6.2 |
| 167 | + * |
157 | 168 | * @param array $coordinates The set of coordinates that needs to be formatted. Either an associative |
158 | 169 | * array with lat and lon keys, or a numbered aray with lat on index 0, and lon on index 1. |
159 | 170 | * @param coordinate type $targetFormat The notation to which they should be formatted. Defaults to floats. |
— | — | @@ -176,6 +187,8 @@ |
177 | 188 | /** |
178 | 189 | * Returns a normalized version of the provided coordinates. |
179 | 190 | * |
| 191 | + * @since 0.6 |
| 192 | + * |
180 | 193 | * @param string $coordinates |
181 | 194 | * |
182 | 195 | * @return string The normalized version of the provided coordinates. |
— | — | @@ -196,6 +209,8 @@ |
197 | 210 | /** |
198 | 211 | * Returns a string with control characters and characters with ascii values above 126 removed. |
199 | 212 | * |
| 213 | + * @since 0.6.3 |
| 214 | + * |
200 | 215 | * @param string $string Yeah, it's a string, seriously! |
201 | 216 | * |
202 | 217 | * @return string |
— | — | @@ -217,6 +232,8 @@ |
218 | 233 | /** |
219 | 234 | * Formats a single non-directional float coordinate in the given notation. |
220 | 235 | * |
| 236 | + * @since 0.6 |
| 237 | + * |
221 | 238 | * @param string $coordinate The coordinate to be formatted. |
222 | 239 | * @param coordinate type $targetFormat The notation to which they should be formatted. |
223 | 240 | * |
— | — | @@ -258,6 +275,8 @@ |
259 | 276 | /** |
260 | 277 | * Parses a coordinate that's in the provided notation to float representatation. |
261 | 278 | * |
| 279 | + * @since 0.6 |
| 280 | + * |
262 | 281 | * @param string $coordinate The coordinate to be parsed. |
263 | 282 | * @param coordinate type $coordType The notation the coordinate is currently in. |
264 | 283 | * |
— | — | @@ -281,6 +300,8 @@ |
282 | 301 | /** |
283 | 302 | * returns whether the coordinates are in float representataion. |
284 | 303 | * |
| 304 | + * @since 0.6 |
| 305 | + * |
285 | 306 | * @param string $coordinates |
286 | 307 | * |
287 | 308 | * @return boolean |
— | — | @@ -294,6 +315,8 @@ |
295 | 316 | /** |
296 | 317 | * returns whether the coordinates are in DMS representataion. |
297 | 318 | * |
| 319 | + * @since 0.6 |
| 320 | + * |
298 | 321 | * @param string $coordinates |
299 | 322 | * |
300 | 323 | * @return boolean |
— | — | @@ -309,6 +332,8 @@ |
310 | 333 | /** |
311 | 334 | * returns whether the coordinates are in Decimal Degree representataion. |
312 | 335 | * |
| 336 | + * @since 0.6 |
| 337 | + * |
313 | 338 | * @param string $coordinates |
314 | 339 | * |
315 | 340 | * @return boolean |
— | — | @@ -322,6 +347,8 @@ |
323 | 348 | /** |
324 | 349 | * returns whether the coordinates are in Decimal Minute representataion. |
325 | 350 | * |
| 351 | + * @since 0.6 |
| 352 | + * |
326 | 353 | * @param string $coordinates |
327 | 354 | * |
328 | 355 | * @return boolean |
— | — | @@ -335,7 +362,11 @@ |
336 | 363 | /** |
337 | 364 | * Turn i18n labels into English ones, for both validation and ease of handling. |
338 | 365 | * |
| 366 | + * @since 0.6 |
| 367 | + * |
339 | 368 | * @param string $coordinates |
| 369 | + * |
| 370 | + * @return string |
340 | 371 | */ |
341 | 372 | private static function handleI18nLabels( $coordinates ) { |
342 | 373 | self::initializeDirectionLabels(); |
— | — | @@ -344,6 +375,8 @@ |
345 | 376 | |
346 | 377 | /** |
347 | 378 | * Initialize the cache for internationalized direction labels if not done yet. |
| 379 | + * |
| 380 | + * @since 0.6 |
348 | 381 | */ |
349 | 382 | protected static function initializeDirectionLabels() { |
350 | 383 | if ( !self::$mI18nDirections ) { |
— | — | @@ -360,6 +393,8 @@ |
361 | 394 | /** |
362 | 395 | * Turns directional notation (N/E/S/W) of a coordinate set into non-directional notation (+/-). |
363 | 396 | * |
| 397 | + * @since 0.6 |
| 398 | + * |
364 | 399 | * @param array $coordinates |
365 | 400 | * |
366 | 401 | * @return array |
— | — | @@ -374,6 +409,8 @@ |
375 | 410 | /** |
376 | 411 | * Turns directional notation (N/E/S/W) of a single coordinate into non-directional notation (+/-). |
377 | 412 | * |
| 413 | + * @since 0.6 |
| 414 | + * |
378 | 415 | * @param string $coordinate |
379 | 416 | * |
380 | 417 | * @return string |
— | — | @@ -398,6 +435,8 @@ |
399 | 436 | /** |
400 | 437 | * Turns non-directional notation in directional notation when needed. |
401 | 438 | * |
| 439 | + * @since 0.6 |
| 440 | + * |
402 | 441 | * @param array $coordinates The coordinates set to possibly make directional. Needs to be non-directional! |
403 | 442 | * |
404 | 443 | * @return array |
— | — | @@ -416,6 +455,8 @@ |
417 | 456 | /** |
418 | 457 | * Turns non-directional notation in directional notation. |
419 | 458 | * |
| 459 | + * @since 0.6 |
| 460 | + * |
420 | 461 | * @param string $coordinate The coordinate to make directional. Needs to be non-directional! |
421 | 462 | * @param boolean $isLat Should be true for latitudes and false for longitudes. |
422 | 463 | * |
— | — | @@ -439,6 +480,8 @@ |
440 | 481 | /** |
441 | 482 | * Takes a set of coordinates in DMS representataion, and returns them in float representataion. |
442 | 483 | * |
| 484 | + * @since 0.6 |
| 485 | + * |
443 | 486 | * @param string $coordinate |
444 | 487 | * |
445 | 488 | * @return string |
— | — | @@ -469,6 +512,8 @@ |
470 | 513 | /** |
471 | 514 | * Takes a set of coordinates in Decimal Degree representataion, and returns them in float representataion. |
472 | 515 | * |
| 516 | + * @since 0.6 |
| 517 | + * |
473 | 518 | * @param string $coordinate |
474 | 519 | * |
475 | 520 | * @return string |
— | — | @@ -480,6 +525,8 @@ |
481 | 526 | /** |
482 | 527 | * Takes a set of coordinates in Decimal Minute representataion, and returns them in float representataion. |
483 | 528 | * |
| 529 | + * @since 0.6 |
| 530 | + * |
484 | 531 | * @param string $coordinate |
485 | 532 | * |
486 | 533 | * @return string |
— | — | @@ -498,6 +545,13 @@ |
499 | 546 | return $coordinate; |
500 | 547 | } |
501 | 548 | |
| 549 | + /** |
| 550 | + * Gets a regex group that allows only the supported seperators. |
| 551 | + * |
| 552 | + * @since 0.6.2 |
| 553 | + * |
| 554 | + * @return string |
| 555 | + */ |
502 | 556 | protected static function getSeparatorsRegex() { |
503 | 557 | if ( !self::$mSeparatorsRegex ) self::$mSeparatorsRegex = '(' . implode( '|', self::$mSeparators ) . ')'; |
504 | 558 | return self::$mSeparatorsRegex; |
— | — | @@ -506,6 +560,8 @@ |
507 | 561 | /** |
508 | 562 | * Parse a string containing coordinates and return the same value in the specified notation. |
509 | 563 | * |
| 564 | + * @since 0.6 |
| 565 | + * |
510 | 566 | * @param string $coordinates |
511 | 567 | * @param $targetFormat |
512 | 568 | * @param boolean $directional |