aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-09-26 10:19:16 +0100
committerArun Isaac2023-09-26 10:19:16 +0100
commit808c8027fa5e2c94a8be6e0e06ef6a796b0050a3 (patch)
tree1a2c3cf3c53b089855c83205d8d4c09bb64bdafc
parent56d7aa8e2ff13a18edf0eef101c3af77c640254e (diff)
downloadrent-in-london-808c8027fa5e2c94a8be6e0e06ef6a796b0050a3.tar.gz
rent-in-london-808c8027fa5e2c94a8be6e0e06ef6a796b0050a3.tar.lz
rent-in-london-808c8027fa5e2c94a8be6e0e06ef6a796b0050a3.zip
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.
-rw-r--r--rent.scm13
1 files 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