From 808c8027fa5e2c94a8be6e0e06ef6a796b0050a3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 26 Sep 2023 10:19:16 +0100 Subject: Specify points explicitly in distance computation. Previously, work coordinates were implicit in cycling distance computation. Pass it explicitly as an argument. * rent.scm (house-cycling-distance): Rename to ... (cycling-distance): ... this. Pass start and end points explicitly. (list-house): Use cycling-distance instead of house-cycling-distance. --- rent.scm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rent.scm b/rent.scm index 08e8dde..ac71d56 100644 --- a/rent.scm +++ b/rent.scm @@ -326,18 +326,17 @@ characters. Else, return @code{#f}." '()))) (*default* . ,handle-default)))) -(define (house-cycling-distance house) - "Compute the cycling distance between @var{house} and work. The -returned distance is the actual distance by cycle, and not distance as -the crow flies." +(define (cycling-distance point-a point-b) + "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 (house-coordinates house) - %work-coordinates)) + (list point-a point-b)) ";") "?annotations=distance&sources=0&destinations=1"))) (lambda (port) @@ -387,7 +386,7 @@ Cycling distance: ~,1f km %openrent-base-url (house-property-id house) (house-rent house) - (house-cycling-distance house)) + (cycling-distance (house-coordinates house) %work-coordinates)) (match (house-tube-stations house) (() (display "No tube!")) (tube-stations -- cgit v1.2.3