aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rent.scm56
1 files changed, 32 insertions, 24 deletions
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."