diff options
author | Arun Isaac | 2024-01-02 21:49:37 +0000 |
---|---|---|
committer | Arun Isaac | 2024-06-18 14:51:51 +0100 |
commit | 8209cc28d0404e5351b147f147edda10ee843756 (patch) | |
tree | 140e65044a15758173a1ae69507191f723b94098 | |
parent | e200e606900328bea1c237287d55ccd1f2b3ff2f (diff) | |
download | rent-in-london-main.tar.gz rent-in-london-main.tar.lz rent-in-london-main.zip |
* rent.scm (lines-at-station): Handle misnamed Paddington and
Hammersmith stations.
-rw-r--r-- | rent.scm | 56 |
1 files changed, 32 insertions, 24 deletions
@@ -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." |