aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-10-07 20:40:24 +0100
committerArun Isaac2023-10-07 20:44:30 +0100
commitd97998201a16e1eda23f9f0654561e8a659a8f38 (patch)
tree8c228f4bc56ba706a58bbaff01e369fcd0aee480
parent392bca3614fdef2e2fc23baca3e86ba46b2a5b81 (diff)
downloadrent-in-london-d97998201a16e1eda23f9f0654561e8a659a8f38.tar.gz
rent-in-london-d97998201a16e1eda23f9f0654561e8a659a8f38.tar.lz
rent-in-london-d97998201a16e1eda23f9f0654561e8a659a8f38.zip
Construct OSRM URL using format.
format is simpler and more readable, in this case. * rent.scm (cycling-distance): Construct OSRM URL using format.
-rw-r--r--rent.scm26
1 files changed, 13 insertions, 13 deletions
diff --git a/rent.scm b/rent.scm
index db047b7..1effb3e 100644
--- a/rent.scm
+++ b/rent.scm
@@ -347,19 +347,19 @@ characters. Else, return @code{#f}."
"Compute the cycling distance between @var{point-a} and
@var{point-b}. The returned distance is the actual distance by cycle,
and not distance as the crow flies."
- (call-with-port (open-bytevector-input-port
- (http-get*
- (string-append %osrm-base-url "/table/v1/bike/"
- (string-join (map (match-lambda
- (#(latitude longitude)
- (format #f "~a,~a" longitude latitude)))
- (list point-a point-b))
- ";")
- "?annotations=distance&sources=0&destinations=1")))
- (lambda (port)
- (/ (json-ref (json->scm port)
- "distances" 0 0)
- 1000))))
+ (match (list point-a point-b)
+ ((#(point-a-latitude point-a-longitude)
+ #(point-b-latitude point-b-longitude))
+ (call-with-port (open-bytevector-input-port
+ (http-get*
+ (format #f "~a/table/v1/bike/~a,~a;~a,~a?annotations=distance&sources=0&destinations=1"
+ %osrm-base-url
+ point-a-longitude point-a-latitude
+ point-b-longitude point-b-latitude)))
+ (lambda (port)
+ (/ (json-ref (json->scm port)
+ "distances" 0 0)
+ 1000))))))
(define (all-tube-lines)
"Return a list of all tube lines in London."