Journey Planner cardinal direction


#1

via e-mail:

I was wondering why you do not include Cardinal directions (Eastbound, Westbound, etc) in your API responses for the Journey endpoint. Am I overlooking something?


#2

There are “skyDirection” and “lineString” fields returned in the Journey Planner result legs which should help with this:

e.g. Westminster to Bank

$ curl -s https://api.tfl.gov.uk/journey/journeyresults/1000266/to/1000013 | jq . | grep skyDirection
                "skyDirection": 365,
                "skyDirectionDescription": "North",
                "skyDirection": 373,
                "skyDirectionDescription": "North",
                "skyDirection": 427,
                "skyDirectionDescription": "North",
                "skyDirection": 428,
                "skyDirectionDescription": "North",
                "skyDirection": 393,

Also there is a lineString which gives the exact path:

$ curl -s https://api.tfl.gov.uk/journey/journeyresults/1000266/to/1000013 | jq . | grep lineString
            "lineString": "[[51.50100345276, -0.12485992101],[51.5009783417, -0.12441429778],[51.50106337511, -0.12298439272],[51.50170090818, -0.11955780858],[51.50334046308, -0.11302069463],[51.50334046308, -0.11302069463],[51.50398263824, -0.11045815313],[51.50426792153, -0.10863078519],[51.50435392304, -0.10727275095],[51.50428007336, -0.10492710023],[51.50428007336, -0.10492710023],[51.50407248611, -0.0987685702],[51.50422182972, -0.09577963576],[51.50438856048, -0.09441820849],[51.50474305469, -0.09299129429],[51.50495952019, -0.09247792387],[51.50527608892, -0.09148484967],[51.50575025934, -0.08967822594],[51.50586159146, -0.08823258945],[51.50583751486, -0.08785894256]]",
etc.