Index: trunk/extensions/Maps/Maps_CoordinateParser.php |
— | — | @@ -203,14 +203,18 @@ |
204 | 204 | case Maps_COORDS_FLOAT: |
205 | 205 | return $coordinate; |
206 | 206 | case Maps_COORDS_DMS: |
207 | | - $degrees = floor( $coordinate ); |
| 207 | + $isNegative = $coordinate < 0; |
| 208 | + |
| 209 | + $degrees = $isNegative ? ceil( $coordinate ) : floor( $coordinate ); |
208 | 210 | $minutes = ( $coordinate - $degrees ) * 60; |
209 | | - $seconds = ( $minutes - floor( $minutes ) ) * 60; |
210 | | - return $degrees . Maps_GEO_DEG . ' ' . floor( $minutes ) . Maps_GEO_MIN . ' ' . round( $seconds ) . Maps_GEO_SEC; |
| 211 | + $seconds = ( $minutes - ( $isNegative ? ceil( $minutes ) : floor( $minutes ) ) ) * 60; |
| 212 | + |
| 213 | + return $degrees . Maps_GEO_DEG . ' ' . ( $isNegative ? ceil( $minutes ) : floor( $minutes ) ) . Maps_GEO_MIN . ' ' . round( $seconds ) . Maps_GEO_SEC; |
211 | 214 | case Maps_COORDS_DD: |
212 | 215 | return $coordinate . Maps_GEO_DEG; |
213 | 216 | case Maps_COORDS_DM: |
214 | | - return round( $coordinate ) . Maps_GEO_DEG . ' ' . ( $coordinate - floor( $coordinate ) ) * 60 . Maps_GEO_MIN; |
| 217 | + $isNegative = $coordinate < 0; |
| 218 | + return round( $coordinate ) . Maps_GEO_DEG . ' ' . ( $coordinate - ( $isNegative ? ceil( $coordinate ) : floor( $coordinate ) ) ) * 60 . Maps_GEO_MIN; |
215 | 219 | default: |
216 | 220 | throw new Exception( __METHOD__ . " does not support formatting of coordinates to the $targetFormat notation." ); |
217 | 221 | } |
— | — | @@ -347,7 +351,7 @@ |
348 | 352 | // If there is no direction indicator, the coordinate is already non-directional and no work is required. |
349 | 353 | if ( in_array( $lastChar, self::$mDirections ) ) { |
350 | 354 | $coordinate = substr( $coordinate, 0, -1 ); |
351 | | - if ( ( $lastChar == "S" ) or ( $lastChar == "W" ) ) { |
| 355 | + if ( ( $lastChar == 'S' ) or ( $lastChar == 'W' ) ) { |
352 | 356 | $coordinate = '-' . trim( $coordinate ); |
353 | 357 | } |
354 | 358 | } |
— | — | @@ -384,7 +388,7 @@ |
385 | 389 | private static function setDirectionalAngle( $coordinate, $isLat ) { |
386 | 390 | self::initializeDirectionLabels(); |
387 | 391 | |
388 | | - $isNegative = substr( $coordinate, 0, 1 ) == '-'; |
| 392 | + $isNegative = $coordinate{0} == '-'; |
389 | 393 | if ( $isNegative ) $coordinate = substr( $coordinate, 1 ); |
390 | 394 | |
391 | 395 | if ( $isLat ) { |
— | — | @@ -406,7 +410,7 @@ |
407 | 411 | * FIXME: fix innacuracy |
408 | 412 | */ |
409 | 413 | private static function parseDMSCoordinate( $coordinate ) { |
410 | | - $isNegative = substr( $coordinate, 0, 1 ) == '-'; |
| 414 | + $isNegative = $coordinate{0} == '-'; |
411 | 415 | if ( $isNegative ) $coordinate = substr( $coordinate, 1 ); |
412 | 416 | |
413 | 417 | $degreePosition = strpos( $coordinate, Maps_GEO_DEG ); |
— | — | @@ -449,7 +453,7 @@ |
450 | 454 | * TODO: fix innacuracy |
451 | 455 | */ |
452 | 456 | private static function parseDMCoordinate( $coordinate ) { |
453 | | - $isNegative = substr( $coordinate, 0, 1 ) == '-'; |
| 457 | + $isNegative = $coordinate{0} == '-'; |
454 | 458 | if ( $isNegative ) $coordinate = substr( $coordinate, 1 ); |
455 | 459 | |
456 | 460 | list( $degrees, $minutes ) = explode( Maps_GEO_DEG, $coordinate ); |