From 8209cc28d0404e5351b147f147edda10ee843756 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 2 Jan 2024 21:49:37 +0000 Subject: Put in special cases to correct slightly misnamed stations. * rent.scm (lines-at-station): Handle misnamed Paddington and Hammersmith stations. --- rent.scm | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'rent.scm') diff --git a/rent.scm b/rent.scm index 6b64245..2ffdc03 100644 --- a/rent.scm +++ b/rent.scm @@ -382,30 +382,38 @@ of actual distances by cycle, and not distance as the crow flies." (define (lines-at-station station-name) "Return a list of tube lines serving @var{station-name}." - (let* ((modes (list "dlr" "elizabeth-line" "tube")) - (station-id - ;; Assume the first search result is the station we are - ;; looking for. - (json-ref - (json-get (string-append %tfl-base-url - "/StopPoint/Search/" - (uri-encode station-name) - "?modes=" - (string-join modes ","))) - "matches" 0 "id"))) - ;; Assume that we actually find tube lines at this station. This - ;; may not be the case if the supplied station-name is not - ;; actually a tube station. - (vector->list - (json-ref (find (lambda (mode-group) - (member (json-ref mode-group "modeName") - modes)) - (vector->list - (json-ref - (json-get (string-append %tfl-base-url - "/StopPoint/" station-id)) - "lineModeGroups"))) - "lineIdentifier")))) + (cond + ;; Correct slightly misnamed stations. + ((string=? station-name "Paddington (Hammersmith & City)") + (lines-at-station "Paddington")) + ((member station-name (list "Hammersmith (District & Piccadilly)" + "Hammersmith (District and Piccadilly)")) + (lines-at-station "Hammersmith")) + (else + (let* ((modes (list "dlr" "elizabeth-line" "tube")) + (station-id + ;; Assume the first search result is the station we are + ;; looking for. + (json-ref + (json-get (string-append %tfl-base-url + "/StopPoint/Search/" + (uri-encode station-name) + "?modes=" + (string-join modes ","))) + "matches" 0 "id"))) + ;; Assume that we actually find tube lines at this station. This + ;; may not be the case if the supplied station-name is not + ;; actually a tube station. + (vector->list + (json-ref (find (lambda (mode-group) + (member (json-ref mode-group "modeName") + modes)) + (vector->list + (json-ref + (json-get (string-append %tfl-base-url + "/StopPoint/" station-id)) + "lineModeGroups"))) + "lineIdentifier")))))) (define (list-house house) "Display details of @var{house} on the current output port." -- cgit v1.2.3