Detta inlägg är gammalt och kan innehålla inaktuell information.

SL Trafikläge 2 - Event Status

SL Trafikläget 2 api(https://www.trafiklab.se/api/sl-trafiklage-2/sl...) states in its documentation, that the event can have one of the three following status: i.e:

  1. Inga större störningar
  2. Stor påverkan
  3. Avstängt

But, apparently in the api response(see example below) "Status" and "TrafficStatus" fields are always "null", instead there is another field named "StatusIcon" which seems to have the appropriate values according to the respective event.

{
StatusCode: 0
Message: ""
ExecutionTime: 10
ResponseData: {
TrafficTypes: [6]
0: {
Id: 2
Name: "Tunnelbana"
Type: "metro"
TrafficStatus: null
StatusIcon: "EventMinor"
Events: [2]
0: {
EventId: 2041
Message: "Förseningar på upp till ca 10 min på tunnelbanans gröna linje. Efter ett tidigare stopp. "
LineNumbers: {
InputDataIsOptional: true
Text: null
}-
Expanded: true
Planned: false
SortIndex: 100
TrafficLine: "Gröna linjen"
EventInfoUrl: null
Status: null
StatusIcon: "EventMinor"
}-
1: {
EventId: 0
Message: "Övriga linjer: inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: false
}-
1: {
Id: 6
Name: "Pendeltåg"
Type: "train"
TrafficStatus: null
StatusIcon: "EventMinor"
Events: [2]
0: {
EventId: 2036
Message: "Enstaka förseningar upp till 15 minuter för tåg mot Märsta efter tidigare stopp pga ordningsproblem"
LineNumbers: {
InputDataIsOptional: true
Text: null
}-
Expanded: true
Planned: false
SortIndex: 100
TrafficLine: "Märsta-Södertälje"
EventInfoUrl: null
Status: null
StatusIcon: "EventMinor"
}-
1: {
EventId: 0
Message: "Övriga linjer: inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: false
}-
2: {
Id: 14
Name: "Lokalbana"
Type: "local"
TrafficStatus: null
StatusIcon: "EventGood"
Events: [2]
0: {
EventId: 2026
Message: "Lördag 14 februari ersätter bussar tågen mellan Nacka och Slussen pga banarbeten."
LineNumbers: {
InputDataIsOptional: true
Text: "25,26"
}-
Expanded: true
Planned: true
SortIndex: 50
TrafficLine: "Saltsjöbanan"
EventInfoUrl: null
Status: null
StatusIcon: "EventPlanned"
}-
1: {
EventId: 0
Message: "Övriga linjer: inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: true
}-
3: {
Id: 20
Name: "Spårvagn"
Type: "tram"
TrafficStatus: null
StatusIcon: "EventGood"
Events: [1]
0: {
EventId: 0
Message: "Inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: false
}-
4: {
Id: 22
Name: "Buss"
Type: "bus"
TrafficStatus: null
StatusIcon: "EventGood"
Events: [2]
0: {
EventId: 2023
Message: "Linje 113 kör endast vänstervarv genom Jungfrudansen på grund av begränsad framkomlighet. "
LineNumbers: {
InputDataIsOptional: true
Text: null
}-
Expanded: true
Planned: false
SortIndex: 100
TrafficLine: "Solna/Sundbyberg"
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-
1: {
EventId: 0
Message: "Övriga linjer: inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: false
}-
5: {
Id: 45
Name: "Båt"
Type: "fer"
TrafficStatus: null
StatusIcon: "EventGood"
Events: [1]
0: {
EventId: 0
Message: "Inga större störningar"
LineNumbers: null
Expanded: false
Planned: false
SortIndex: 10000
TrafficLine: null
EventInfoUrl: null
Status: null
StatusIcon: "EventGood"
}-

##

Expanded: true

HasPlannedEvent: false
}-

##

}-

So, my question is, is this a documentation glitch, or the api response is wrong?

And if status and traffic status fields are expected to be null, and we should instead look for the StatusIcon field, then what are all the possible values for this field?

Kommentarer

  • Hello,

    The list you are refering to is more like a list of states that a event can be in. It is not to be compared to the field status or trafficsituationstatus. Those two fields where used in the old version of trafficsituation though and did contain those values.

    The api is not wrong, it is built to be easily implemented without extra conversions of fields and data, by just looping through the data and setting things like message, icon etc by using the values provided.
    E.g. http://sl.se is implementing this api without any further additions to it by just looping through the data.

    You are ment to look at the StatusIcon field for an somewhat equivalent to the old status field.

    Possible values for StatusIcon on a TrafficEvent is:

    • EventMajor
    • EventMinor
    • EventGood
    • EventPlanned

    Possible values for StatusIcon on a TrafficType is:

    • EventMajor
    • EventMinor
    • EventGood

    //Daniel A

  • Thanks a lot for the explanation, so it indeed was the old documentation then.

  • Btw, what is the equivalent StstusIcon for status "Avstängt"?

  • EventMajor => "Avstängt"
    EventMinor => "Stor påverkan"
    EventGood => "Inga större störningar"
    EventPlanned => "Inga större störningar" with boolean flag Planned = true.

    At sl.se we use icons like this:
    A red cross for EventMajor
    A tiny symbol of an orange clock for EventMinor
    A green tick for EventGood.
    A gray triangle for EventPlanned.

    //Daniel A

  • Once again, thanks a lot for the detailed explanation.

    /Syed.

Kommentera eller skriv ett nytt inlägg

Ditt namn och inlägg kan ses av alla. Din e-post visas aldrig publikt.