Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Programing Language: latitude-longitude-decimalize
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Xah Lee  
View profile  
 More options Nov 29 2011, 5:53 pm
Newsgroups: comp.lang.lisp, comp.emacs, comp.lang.python, comp.lang.perl.misc
From: Xah Lee <xah...@gmail.com>
Date: Tue, 29 Nov 2011 14:53:15 -0800 (PST)
Local: Tues, Nov 29 2011 5:53 pm
Subject: Programing Language: latitude-longitude-decimalize
fun programing exercise. Write a function “latitude-longitude-
decimalize”.

It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」.
The return value should be a pair of numbers, like this: 「[37.44345
-6.25396]」.

Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp
solution in a couple of days.

 Xah


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Micky Hulse  
View profile  
 More options Nov 29 2011, 6:29 pm
Newsgroups: comp.lang.python
From: Micky Hulse <mickyhulse.li...@gmail.com>
Date: Tue, 29 Nov 2011 15:29:29 -0800
Local: Tues, Nov 29 2011 6:29 pm
Subject: Re: Programing Language: latitude-longitude-decimalize
Last time I did this was using AS3. The format I used was DMS:

GPSLongitude: 122,42,47.79
GPSLongitudeRef: W
GPSLatitude: 45,30,30.390001198897014
GPSLatitudeRef: N

Here's the method:

<https://gist.github.com/1407126>

Not shown in above code: If West longitude or South latitude I would
make that DD (decimal degree) value negative.

Anyway, that was a fun learning experience! :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Kelly  
View profile  
 More options Nov 29 2011, 6:49 pm
Newsgroups: comp.lang.python
From: Ian Kelly <ian.g.ke...@gmail.com>
Date: Tue, 29 Nov 2011 16:49:18 -0700
Local: Tues, Nov 29 2011 6:49 pm
Subject: Re: Programing Language: latitude-longitude-decimalize

On Tue, Nov 29, 2011 at 3:53 PM, Xah Lee <xah...@gmail.com> wrote:
> fun programing exercise. Write a function “latitude-longitude-
> decimalize”.

> It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」.
> The return value should be a pair of numbers, like this: 「[37.44345
> -6.25396]」.

> Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp
> solution in a couple of days.

For Python 3:

import re

def latitude_longitude_decimalize(string):
    regex = r"""(\d+)\xb0(\d+)'([\d+.]+)"([NS])\s*(\d+)\xb0(\d+)'([\d+.]+)"([EW])"""
    match = re.match(regex, string)
    if not match:
        raise ValueError("Invalid input string: {0:r}".format(string))
    def decimalize(degrees, minutes, seconds, direction):
        decimal = int(degrees) + int(minutes) / 60 + float(seconds) / 3600
        if direction in 'SW':
            decimal = -decimal
        return decimal
    latitude = decimalize(*match.groups()[:4])
    longitude = decimalize(*match.groups()[4:8])
    return latitude, longitude


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thad Floryan  
View profile  
 More options Nov 29 2011, 6:50 pm
Newsgroups: comp.lang.lisp, comp.emacs, comp.lang.python, comp.lang.perl.misc
From: Thad Floryan <t...@thadlabs.com>
Date: Tue, 29 Nov 2011 15:50:33 -0800
Local: Tues, Nov 29 2011 6:50 pm
Subject: Re: Programing Language: latitude-longitude-decimalize
On 11/29/2011 2:53 PM, Xah Lee wrote:

> fun programing exercise. Write a function “latitude-longitude-
> decimalize”.

> It should take a string like this: 「"37°26′36.42″N 06°15′14.28″W"」.
> The return value should be a pair of numbers, like this: 「[37.44345
> -6.25396]」.

> Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp
> solution in a couple of days.

What a waste of time when the following works fine (probably Java):

<http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jürgen Exner  
View profile  
 More options Nov 29 2011, 8:14 pm
Newsgroups: comp.lang.lisp, comp.emacs, comp.lang.python, comp.lang.perl.misc
From: Jürgen Exner <jurge...@hotmail.com>
Date: Tue, 29 Nov 2011 17:14:23 -0800
Local: Tues, Nov 29 2011 8:14 pm
Subject: Re: Programing Language: latitude-longitude-decimalize

Thad Floryan <t...@thadlabs.com> wrote:
>On 11/29/2011 2:53 PM, Xah Lee wrote:

Please do not reply to the eternal troll

Thanks

jue


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thad Floryan  
View profile  
 More options Nov 29 2011, 9:10 pm
Newsgroups: comp.lang.lisp, comp.emacs, comp.lang.python, comp.lang.perl.misc
From: Thad Floryan <t...@thadlabs.com>
Date: Tue, 29 Nov 2011 18:10:17 -0800
Local: Tues, Nov 29 2011 9:10 pm
Subject: Re: Programing Language: latitude-longitude-decimalize
On 11/29/2011 5:14 PM, Jürgen Exner wrote:

> Thad Floryan <t...@thadlabs.com> wrote:
>> On 11/29/2011 2:53 PM, Xah Lee wrote:

> Please do not reply to the eternal troll

> Thanks

Mea culpa, you're correct.  I responded only because the subject
is something with which I'm familiar, e.g., one of my posts from
1988 (23 years ago):

<http://groups.google.com/group/sci.math/msg/d6c891302914fd84>
and
<http://groups.google.co.jp/group/sci.math/msg/d6c891302914fd84>

:-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »