;; Answer to Programing Problem: Decimalize Latitude Longitude.
;; Found in http://xahlee.blogspot.com/2012/04/programing-problem decimalize-latitude.html
;; it is very elisp in that it uses a regexp for splitting the
;; strings, and the fact that characters are also numbers in elisp:
;; N=78<S=83 and E=69<W=87
(defun decimalize-lat-lon (lat-lon-string)
"Decimalize latitude longitude. Converts a string of the form \"37°26′36.42″N 06°15′14.28″W\" to a list with two numbers of the form (37.44345 -6.253966666666667)."
(let* ((lat-strings (split-string (car (split-string lat-lon-string)) "[^0-9A-Z.]+"))
(lon-strings (split-string (cadr (split-string lat-lon-string)) "[^0-9A-Z.]+"))
(lat-sign (- 1 (* 2(/ (string-to-char (nth 3 lat-strings)) 83))))
(lon-sign (- 1 (* 2(/ (string-to-char (nth 3 lon-strings)) 87))))
(lat (* lat-sign
(+ (string-to-number (nth 0 lat-strings))
(/ (string-to-number (nth 1 lat-strings)) 60.0)
(/ (string-to-number (nth 2 lat-strings)) (* 60.0 60.0)))))
(lon (* lon-sign
(+ (string-to-number (nth 0 lon-strings))
(/ (string-to-number (nth 1 lon-strings)) 60.0)
(/ (string-to-number (nth 2 lon-strings)) (* 60.0 60.0))))))
(list lat lon)))