Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Thad Floryan
On 11/29/2011 5:14 PM, Jürgen Exner wrote:
> Thad Floryan  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):


and


:-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread J�rgen Exner
Thad Floryan  wrote:
>On 11/29/2011 2:53 PM, Xah Lee wrote:

Please do not reply to the eternal troll

Thanks

jue
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Thad Floryan
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://mail.python.org/mailman/listinfo/python-list


Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Ian Kelly
On Tue, Nov 29, 2011 at 3: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.

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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Micky Hulse
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:



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! :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Programing Language: latitude-longitude-decimalize

2011-11-29 Thread Xah Lee
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
-- 
http://mail.python.org/mailman/listinfo/python-list