"′"
(if neg-lng? "W" "E")))))))
-(define (string->latitude-longitude string)
- (let* ((digits "\\([0-9]+\\)")
- (regs (re-string-match
- (string-append "^"digits"°"digits"."digits"′\\([SN]\\)"
- " "digits"°"digits"."digits"′\\([EW]\\)$")
- string)))
-
- (define-integrable (->flo n)
- (->flonum (string->number (re-match-extract string regs n))))
-
- (define-integrable (->neg? num)
- (let ((string (re-match-extract string regs num)))
- (or (string=? "W" string)
- (string=? "S" string))))
-
- (define-integrable (dms.->d neg? degrees minutes millimin)
- (let ((absolute (flo:+ degrees
- (flo:* 60.0 (flo:+ minutes
- (flo:/ millimin 1000.))))))
- (if neg?
- (flo:negate absolute)
- absolute)))
-
- (and regs
- (make-latitude/longitude
- (dms.->d (->neg? 4) (->flo 1) (->flo 2) (->flo 3))
- (dms.->d (->neg? 8) (->flo 5) (->flo 6) (->flo 7))))))
-
(define (geodesic-distance p1 p2)
;; "[Given] the geographic coordinates of two points on the surface
;; of the Earth [...] the shortest distance S between these points,
(flo:+ pi d)
d))))))
-#;(define (package-tests)
- (run-test test-lat/lng-un/parse)
- (run-test test-angular-separation))
-
-(define (test-lat/lng-un/parse)
- (let ((samp "30°26.432′N 122°44.456′W"))
- (if (not (string=? samp (latitude-longitude->string
- (string->latitude-longitude samp))))
- (warn "Latitude/longitude un/parsing failed."))))
-
(define (test-angular-separation)
(define (test lat1 lng1 lat2 lng2 degrees tolerance)