Jump to content

DMS to WGS84


MiCR0

Recommended Posts

I am trying to work out how to convert DMS to WGS84

 

I have the coordinate in mysql like

 

latitude                    longitude

52°39'03.1 N            0°40'36.1 E

52°46'45.2 N            0°06'59.9 W

 

Any help would be great thanks.

Link to comment
Share on other sites

I have found how to do this in perl

 

  foreach (@{$r->{data}{array}}) {
    if (length($_->{latitude})) {
      print "  <item rdf:about=\"$_->{objectno}\">\n";
      print "    <title>$_->{objectno} - $_->{objectname}</title>\n";
      print "    <description>$_->{postext}</description>\n";
      print "    <georss:point>";
      if ($_->{latitude} =~ /(\d+).*?(\d+).*?(\d+\.\d*)\s+([sN])/) {
        my $latitude = $1+$2/60+$3/3600;
        $latitude *= -1 if ($4 eq 'S');
        print $latitude;
      }
      print ' ';
      if ($_->{longitude} =~ /(\d+).*?(\d+).*?(\d+\.\d*)\s+([EW])/) {
        my $longitude = $1+($2/60+$3/3600);
        $longitude *= -1 if ($4 eq 'W');
        print $longitude;
      }
      print "</georss:point>\n";
      print "  </item>\n";
    }
  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.