aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-01-02 21:49:37 +0000
committerArun Isaac2024-06-18 14:51:51 +0100
commit8209cc28d0404e5351b147f147edda10ee843756 (patch)
tree140e65044a15758173a1ae69507191f723b94098
parente200e606900328bea1c237287d55ccd1f2b3ff2f (diff)
downloadrent-in-london-main.tar.gz
rent-in-london-main.tar.lz
rent-in-london-main.zip
Put in special cases to correct slightly misnamed stations.HEADmain
* rent.scm (lines-at-station): Handle misnamed Paddington and Hammersmith stations.
-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."