r103157 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103156‎ | r103157 | r103158 >
Date:12:51, 15 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
patch by Van de Bugger from bug 32407
Modified paths:
  • /trunk/extensions/Maps/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/Maps/includes/Maps_CoordinateParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/RELEASE-NOTES
@@ -11,6 +11,7 @@
1212 (trunk)
1313
1414 * Fixed display of attribution control for OpenLayers.
 15+* Fixed to big precision of geographic coordinates in decimal minutes format (bug 32407).
1516
1617 === Maps 1.0.4 ===
1718 (2011-10-15)
Index: trunk/extensions/Maps/includes/Maps_CoordinateParser.php
@@ -284,13 +284,15 @@
285285 case Maps_COORDS_DD:
286286 return $coordinate . self::SYMBOL_DEG;
287287 case Maps_COORDS_DM:
288 - $isNegative = $coordinate < 0;
289288 $coordinate = abs( $coordinate );
 289+ $degrees = floor( $coordinate );
290290
291 - $result = floor( $coordinate ) . self::SYMBOL_DEG . ' ' . ( $coordinate - floor( $coordinate ) ) * 60 . self::SYMBOL_MIN;
292 - if ( $isNegative ) $result = '-' . $result;
293 -
294 - return $result;
 291+ return sprintf(
 292+ "%s%d%s %0.3f%s",
 293+ $coordinate < 0 ? '-' : '',
 294+ $degrees, self::SYMBOL_DEG,
 295+ ( $coordinate - $degrees ) * 60, self::SYMBOL_MIN
 296+ );
295297 default:
296298 throw new Exception( __METHOD__ . " does not support formatting of coordinates to the $targetFormat notation." );
297299 }