From d97998201a16e1eda23f9f0654561e8a659a8f38 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 7 Oct 2023 20:40:24 +0100 Subject: Construct OSRM URL using format. format is simpler and more readable, in this case. * rent.scm (cycling-distance): Construct OSRM URL using format. --- rent.scm | 26 +++++++++++++------------- 1 file 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." -- cgit v1.2.3