Talk:Geographic coordinate conversion

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Maps (Rated C-class, High-importance)
WikiProject icon This article is within the scope of WikiProject Maps, a collaborative effort to improve the coverage of Maps and Cartography on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
Checklist icon
 High  This article has been rated as High-importance on the project's importance scale.
 
This article had an importance automatically assigned to it. Once it has been checked by a human, please remove |autoi=yes.
WikiProject Geographical coordinates
WikiProject icon Geographic coordinate conversion is of interest to WikiProject Geographical coordinates, which encourages the use of geographical coordinates in Wikipedia. If you would like to participate, please visit the project page, where you can join the project and see a list of open tasks.
 

Conversion code[edit]

The PHP code is too simple. For instance, given the input value "12.999992", the output is "12° 60.000". This is a classical rounding problem. Here are two Perl subroutines which get it right. The second uses Perl's automatic conversion between numbers and strings, a feature not available in all languages. I don't know PHP well enough to write it, but the Perl code below should be understandable by most programmers. –Peter J. Acklam 10:24, 22 Apr 2005 (UTC)

 sub pretty_coord {
     my $coord = abs shift;            # decimal degrees
     my $deg = int $coord;             # compute degrees
     my $min = 60 * ($coord - $deg);   # compute minutes
     if ($min >= 59.9995) {            # if value will be rounded to 60.000
         $min = 0;                     #   set it to zero
         $deg ++;                      #   and increment degrees
     }
     return sprintf("%0.0f° %06.3f", $deg, $min);
 };


 sub pretty_coord {
     my $coord = abs shift;            # decimal degrees
     my $deg = int $coord;             # compute degrees
     my $min = 60 * ($coord - $deg);   # compute minutes
     $min = sprintf '%.3f', $min;      # round to three digits
     if ($min == 60) {                 # if result is 60
         $min = 0;                     #   set it to zero
         $deg ++;                      #   and increment degrees
     }
     return sprintf("%0.0f° %06.3f", $deg, $min);
 };
I've added a new PHP function which I use as part of my website engine. Works well and is more robust & easier to follow than the original "pretty_coord()" example –Andrew N. Thu, 10 Aug 2006 05:04:42 +1000 (UTC)
Is it more robust? It converts "12.5832" into "12:34:60", which should have been "12:35:00". It seems that your code is suffering from the exact same problem as the other code examples. –Peter J. Acklam 11:25, 8 May 2007 (UTC)

Legal ranges[edit]

What are the ranges of degrees, minutes and seconds that are allowed to use? And also what are the allowed number systems for the numbers? What do you think about these values:
23° -45' 22.1"
-23° -45' -22.1"
-(23° 45' 22.1")
23° 61' 61"
23° 45.7' 22.1"

--80.122.38.210 05:28, 20 July 2006 (UTC)

WGS84-centric[edit]

This article pretends, that the world has only WGS84-coordinates. That's not true, there are others like Gauss-Krüger coordinate system, so the name of the article or the article should be changed. --141.52.232.84 (talk) 09:22, 8 October 2008 (UTC)

Complete rewrite[edit]

With this article slated for deletion and all the good howto information exported to Wikiversity, I decided to completely rewrite the article. The conversion between degrees-minutes-seconds and decimal degrees has been condensed into a short section, while all the other types of conversions of geographic coordinates, such as conversions among datums, has been added. It is still incomplete in many places (e.g., the datum conversion methods could be filled out with more formulas and application examples), but is hopefully a good start on this notable subject based on reliable sources. --Mark viking (talk) 22:16, 5 March 2014 (UTC)