diff options
author | Arun Isaac | 2023-10-07 20:40:24 +0100 |
---|---|---|
committer | Arun Isaac | 2023-10-07 20:44:30 +0100 |
commit | d97998201a16e1eda23f9f0654561e8a659a8f38 (patch) | |
tree | 8c228f4bc56ba706a58bbaff01e369fcd0aee480 | |
parent | 392bca3614fdef2e2fc23baca3e86ba46b2a5b81 (diff) | |
download | rent-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.scm | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -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." |