Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page describes the adjustments, additions and changes that have been made to the NeTEx traffic data that Samtrafiken will deliver to a limited number of timetable data consumers such as SJ. Some of the changes have also been introduced in Samtrafiken’s regular NeTEx exports.

...

When sending NeTEx sales data to Samtrafiken then only a subset of these additions should be used. For sending data to Samtrafiken, please refer to the documentation here: Samtrafiken NeTEx import and for special adjustments here: Special cases for sending sales data to Samtrafiken.

Stops file - _stops.xml - StopPlace

The <StopPlace> element has been extended with additional <KeyValue> elements in order to provide information concerning: interchanges, "Rikshållplats"-numbers and whether a stop is sellable or not.

...

Each of these values is interpreted as:

FromProducer:ToProducer:FromProductTransportMode:ToProductTransportMode:MinimumInterchangeTime

The value is taken from Samtrafiken's BRM-system, similar to what you can see here: https://brm.samtrafiken.se/showtimes?pta=-1&station=g%C3%B6teborg+centralstation.
The producer numbers in “FromProducer” and “ToProducer” refer to the producer responsible for sales, and prices and which is displayed to the public. This is the value “salesAuthorityNumber” on a Line (used to be called färdmedelsproducent in Petra).

...

Example values: CST for Stockholms Central Station, ÖSV,ÖSVI for Östersund Västra.

...

Stops file - _

...

stops.xml

...

The <Authority> element now has the <PrivateCode> element specified. This is the producer number used for traffic data, interchanges, line files etc.

Below is an example, the authority “Öresundståg”.

Code Block
<Authority version="20210926" id="SE:074:Authority:9010300000000000">
    <ValidBetween>
      <FromDate>2021-09-26T00:00:00</FromDate>
    </ValidBetween>
    <PrivateCode>300</PrivateCode>
    <Name>Öresundståg AB</Name>
    <LegalName>Öresundståg AB</LegalName>
    <OrganisationType>authority</OrganisationType>
</Authority>

Line files - line.xml

Naming of files

The line files now have been changed so that the file name contains the producer number (Authority.PrivateCode) and line number of the line.

For example, producer number 300 and line number 17 will be specified in the line file:

line_300_17_9011300001700000.xml

The format is thus: “line_<producerNumber>_<lineNumber>_<internalId>.xml"

Line

The <Line> element has been extended with a <KeyValue> containing the salesAuthorityNumber. The salesAuthorityNumber refers to the number/PrivateCode of the Authority that is responsible for sales and prices. Below is an example of SL Pendeltåg line 40:

...

- GroupOfStopPlaces

Addition 2024-10-08

We have now added <GroupOfStopPlaces> elements to the stops-file. There are currently around 380 GroupOfStopPlaces in the file. They are created and maintained by the Traffic-data team at Samtrafiken.

The <GroupOfStopPlaces> element has been extended with two KeyValue> elements in order to provide information concerning the "Rikshållplats"-number and whether the GroupOfStopPlaces should be used in a sellable context or not.

A GroupOfStopPlaces that is marked as sellable would normally contain at least 2 sellable stops.

N.B: All of the referred stops in a sellable GroupOfStopPlaces do not have to be marked as sellable. Each stop has its own sellable-flag to determine if that particular stop is sellable.

The “Rikshållplats”-number of a GroupOfStopPlaces can be used just like the “Rikshållplats”-number from a StopPlace when sending a trip search request to the Hafas journey planner.

Below is an example, of the GroupOfStopPlaces “STOCKHOLM”.

Code Block
breakoutModewide
        <groupsOfStopPlaces>
            <GroupOfStopPlaces version="231007" id="SE:074030:LineGroupOfStopPlaces:90112220040000009091074000098000">
     <ValidBetween>         <FromDate>2022-02-24T00:00:00</FromDate>  <ValidBetween>
  </ValidBetween>             <keyList>     <FromDate>2023-10-07T00:00:00</FromDate>
   <KeyValue>             <Key>salesAuthorityNumber<</Key>ValidBetween>
              <Value>275</Value>  <keyList>
      </KeyValue>     </keyList>     <Name>40</Name>    <KeyValue>
<TransportMode>rail</TransportMode>     <TransportSubmode>         <RailSubmode>unknown</RailSubmode>     </TransportSubmode>     <PublicCode>40<<Key>sellable</PublicCode>Key>
      <PrivateCode>40</PrivateCode>     <RepresentedByGroupRef ref="SE:074:Network:9010222000000000"/>
</Line>

ServiceJourney

The <ServiceJourney> element has been extended with a <KeyValue> containing the productCode, a <KeyValue> fingerprint to detect changes, as well as a <KeyValue> with the attributes defined for the <ServiceJourney>.

The <ServiceJourney> element also ALWAYS contains a <PublicCode> element.

Below is an example:

Code Block
breakoutModewide
<ServiceJourney version="any" id="SE:074:ServiceJourney:30_300_300_1036_1036_J_RE_2">
    <keyList>            <Value>true</Value>
          <KeyValue>          </KeyValue>
  <Key>productCode</Key>             <Value>RE</Value>     <KeyValue>
   </KeyValue>         <KeyValue>             <Key>fingerprint<<Key>rikshallplatsNummer</Key>
               <Value>nib84qjrt4p3pvaiatvag8u32cnjno8j</Value>         <<Value>740098000</KeyValue>Value>
        </keyList>     <PrivateCode>1036</PrivateCode>       </KeyValue>
 <TransportMode>rail</TransportMode>      <TransportSubmode>         <RailSubmode>unknown<</RailSubmode>keyList>
     </TransportSubmode>     <dayTypes>      <Name>STOCKHOLM</Name>
  <DayTypeRef ref="SE:074:DayType:ah0l8tejnuptnmgqvmp348sc3t8pmk72"/>
    </dayTypes>     <JourneyPatternRef ref="SE:074:JourneyPattern:949400000000636569" version="any"/>     <PublicCode>1036<<ShortName>STOCKHOLM</PublicCode>ShortName>
    <OperatorRef ref="SE:074:Operator:9013300000100000"/>     <trainNumbers>         <TrainNumberRef>1036<<PrivateCode>98000</TrainNumberRef>PrivateCode>
    </trainNumbers>     <passingTimes>       <members>
 ...     </passingTimes>     <facilities>         <ServiceFacilitySet<StopPlaceRef versionref="anySE:030:StopPlace:9021074000001000" idversion="SE:074:ServiceFacilitySet:949400000001112786"231007"/>
            <keyList>        <StopPlaceRef ref="SE:030:StopPlace:9021074000622000" version="231007"/>
      <KeyValue>              <StopPlaceRef ref="SE:030:StopPlace:9021074001617000" version="231007"/>
    <Key>attributes</Key>                <StopPlaceRef     <Value>KOMAB,BOKEJB,EVFEUJ,KOMEL,KOMIUK,KOMLYF</Value>
 ref="SE:030:StopPlace:9021074004383000" version="231007"/>
              </KeyValue>      <StopPlaceRef       </keyList>ref="SE:030:StopPlace:9021074012144000" version="231007"/>
            <MobilityFacilityList>suitableForWheelchairs</MobilityFacilityList>        <StopPlaceRef ref="SE:030:StopPlace:9021074020749000" version="231007"/>
  <PassengerCommsFacilityList>powerSupplySockets internet</PassengerCommsFacilityList>             <ServiceReservationFacilityList>noReservationsPossible</ServiceReservationFacilityList>         </ServiceFacilitySet><StopPlaceRef ref="SE:030:StopPlace:9021074023844000" version="231007"/>
                    <StopPlaceRef ref="SE:030:StopPlace:9021074024382000" version="231007"/>
         </facilities>
</ServiceJourney>

ServiceJourney.PublicCode

This element is always present in the Samtrafiken Sales NeTEx export.

It is the announced journey code for the ServiceJourney. For a public transport bus (like a SL bus) this would normally be the same as the Line.PublicCode, while for an express bus it will probably be a unique trip number and for a train it would be the first train number of the train.

The value is alphanumeric and has a maximum length of 5 characters.

KeyValue: productCode

This contains the product code of the Service Journey. The possible values are defined in separate code lists shared by Samtrafiken here: Codelist: Product Category.

KeyValue: fingerprint

This is a fingerprint of all the data for the ServiceJourney. If anything changes on the ServiceJourney then the fingerprint value will change as well. It takes into account the operating days, passing stops and times, boarding/alighting, publicCode, privateCode (trip number/train number), service facilities and more.

This can be used by you to detect if any changes have been made to the ServiceJourney, if you compare it with the fingerprint of the previous delivery.

KeyValue: attributes

This is a comma-separated list of attributes for the Service Journey. The possible values are defined in separate code lists shared by Samtrafiken here: Codelist: Attributes (service properties) .

Some of these attributes can be represented in standard Nordic-profile NeTEx, and if so they will also be specified in those terms, for example attribute “KOMEL" is also described as "powerSupplySockets". If the “attributes”-KeyValue is present it is enough to import said “attributes”, instead of also importing the regular Netex-representations of the service facilities.

Note, that the ServiceFacilities can also be specified for only parts of a journey in JourneyPart-elements.
Note that not all JourneyParts are declared for the purpose of containing ServiceFacilities. There might exist JourneyParts that express train numbers which change during a journey. A single JourneyPart-element will never contain both ServiceFacilities and a TrainNumberRef, it will always only contain one of the two. These two types of JourneyParts can be present at the same time within a ServiceJourney and they might overlap with regard to their FromStopPointRef and ToStopPointRef.
Here is one such example of a JourneyPart which contains ServiceFacilities:

Code Block
breakoutModewide
<ServiceJourney version="any           <StopPlaceRef ref="SE:030:StopPlace:9021074035997000" version="231007"/>
                </members>
                <Centroid>
                    <Location srsName="WGS84">
                        <Longitude>18.058155</Longitude>
                        <Latitude>59.330139</Latitude>
                    </Location>
                </Centroid>
            </GroupOfStopPlaces>
        </groupsOfStopPlaces>

General data - _shared.xml

The <Authority> element now has the <PrivateCode> element specified. This is the producer number used for traffic data, interchanges, line files etc.

Below is an example, the authority “Öresundståg”.

Code Block
<Authority version="20210926" id="SE:074:Authority:9010300000000000">
    <ValidBetween>
      <FromDate>2021-09-26T00:00:00</FromDate>
    </ValidBetween>
    <PrivateCode>300</PrivateCode>
    <Name>Öresundståg AB</Name>
    <LegalName>Öresundståg AB</LegalName>
    <OrganisationType>authority</OrganisationType>
</Authority>

Line files - line.xml

Naming of files

The line files now have been changed so that the file name contains the producer number (Authority.PrivateCode) and line number of the line.

For example, producer number 300 and line number 17 will be specified in the line file:

line_300_17_9011300001700000.xml

The format is thus: “line_<producerNumber>_<lineNumber>_<internalId>.xml"

Line

The <Line> element has been extended with a <KeyValue> containing the salesAuthorityNumber. The salesAuthorityNumber refers to the number/PrivateCode of the Authority that is responsible for sales and prices. Below is an example of SL Pendeltåg line 40:

Code Block
<Line version="220224" id="SE:074:ServiceJourney:300_17_f724f511e94aba890c97f8ee8d0b49d4">Line:9011222004000000">
    <ValidBetween>
        <FromDate>2022-02-24T00:00:00</FromDate>
    </ValidBetween>
    <keyList>
        <KeyValue>
            <Key>productCode<<Key>salesAuthorityNumber</Key>
            <Value>RE<<Value>275</Value>
        </KeyValue>
    </keyList>
    <PrivateCode>1036<<Name>40</PrivateCode>Name>
    <TransportMode>rail</TransportMode>
    <TransportSubmode>
        <RailSubmode>unknown</RailSubmode>
    </TransportSubmode>
    <dayTypes><PublicCode>40</PublicCode>
    <PrivateCode>40</PrivateCode>
    <DayTypeRef<RepresentedByGroupRef ref="SE:074:DayTypeNetwork:2509010222000000000"/>
    </dayTypes>
    <JourneyPatternRef ref</Line>

ServiceJourney

The <ServiceJourney> element has been extended with a <KeyValue> containing the productCode, a <KeyValue> fingerprint to detect changes, as well as a <KeyValue> with the attributes defined for the <ServiceJourney>.

The <ServiceJourney> element also ALWAYS contains a <PublicCode> element.

Below is an example:

Code Block
breakoutModewide
<ServiceJourney version="any" id="SE:074:JourneyPattern:949400000000636703" version="any"/ServiceJourney:30_300_300_1036_1036_J_RE_2">
    <PublicCode>1036</PublicCode><keyList>
    <OperatorRef ref="SE:074:Operator:9013300000100000"/>   <KeyValue>
 <trainNumbers>         <TrainNumberRef>1036</TrainNumberRef>  <Key>productCode</Key>
  </trainNumbers>     <passingTimes>     <Value>RE</Value>
   ...     </passingTimes>KeyValue>
    <parts>    <KeyValue>
    <JourneyPart version="any" id="SE:074:JourneyPart:949400000000636703_1">      <Key>fingerprint</Key>
      <MainPartRef ref="SE:074:JourneyPart:949400000000636703_1" version="any"/>     <Value>nib84qjrt4p3pvaiatvag8u32cnjno8j</Value>
       <FromStopPointRef ref="SE:074:ScheduledStopPoint:9022074000003001"/> </KeyValue>    
    </keyList>
   <ToStopPointRef ref="SE:074:ScheduledStopPoint:9022074000120001"/> <PrivateCode>1036</PrivateCode>    
    <TransportMode>rail</TransportMode>
   <StartTime>10:48:00</StartTime> <TransportSubmode>
        <RailSubmode>unknown</RailSubmode>
  <EndTime>11:00:00</EndTime>  </TransportSubmode>
    <dayTypes>
     <facilities>   <DayTypeRef ref="SE:074:DayType:ah0l8tejnuptnmgqvmp348sc3t8pmk72"/>
    </dayTypes>
       <ServiceFacilitySet<JourneyPatternRef ref="SE:074:JourneyPattern:949400000000636569" version="any" id/>
    <PublicCode>1036</PublicCode>
    <OperatorRef ref="SE:074:ServiceFacilitySetOperator:9494000000011138999013300000100000"/>
    <trainNumbers>
        <TrainNumberRef>1036</TrainNumberRef>
    </trainNumbers>
 <keyList>   <passingTimes>
        ...
    </passingTimes>
    <facilities>
  <KeyValue>      <ServiceFacilitySet version="any" id="SE:074:ServiceFacilitySet:949400000001112786">
            <keyList>
        <Key>attributes</Key>        <KeyValue>
                    <Value>BOKEJB<<Key>attributes</Value>Key>
                    <Value>KOMAB,BOKEJB,EVFEUJ,KOMEL,KOMIUK,KOMLYF</Value>
   </KeyValue>             </KeyValue>
       </keyList>     </keyList>
               <ServiceReservationFacilityList>noReservationsPossible</ServiceReservationFacilityList><MobilityFacilityList>suitableForWheelchairs</MobilityFacilityList>
            <PassengerCommsFacilityList>powerSupplySockets    </ServiceFacilitySet>internet</PassengerCommsFacilityList>
            <<ServiceReservationFacilityList>noReservationsPossible</facilities>ServiceReservationFacilityList>
        </JourneyPart>ServiceFacilitySet>
    </parts>
    <facilities>
        <ServiceFacilitySet version="any" id="SE:074:ServiceFacilitySet:949400000001113897">
            <keyList>
                <KeyValue>
                    <Key>attributes</Key>
                    <Value>KOMAB,BOKP37,EVFEUJ,KOMEL,KOMIUK,KOMLYF,BOKFRI</Value>
                </KeyValue>
            </keyList>
            <MobilityFacilityList>suitableForWheelchairs</MobilityFacilityList>
            <PassengerCommsFacilityList>powerSupplySockets internet</PassengerCommsFacilityList>
            <ServiceReservationFacilityList>reservationsPossible</ServiceReservationFacilityList>
        </ServiceFacilitySet>
    </facilities>
</ServiceJourney>facilities>
</ServiceJourney>

ServiceJourney.PublicCode

This element is always present in the Samtrafiken Sales NeTEx export.

It is the announced journey code for the ServiceJourney. For a public transport bus (like a SL bus) this would normally be the same as the Line.PublicCode, while for an express bus it will probably be a unique trip number and for a train it would be the first train number of the train.

The value is alphanumeric and has a maximum length of 5 characters.

KeyValue: productCode

This contains the product code of the Service Journey. The possible values are defined in separate code lists shared by Samtrafiken here: Codelist: Product Category.

KeyValue: fingerprint

This is a fingerprint of all the data for the ServiceJourney. If anything changes on the ServiceJourney then the fingerprint value will change as well. It takes into account the operating days, passing stops and times, boarding/alighting, publicCode, privateCode (trip number/train number), service facilities and more.

This can be used by you to detect if any changes have been made to the ServiceJourney, if you compare it with the fingerprint of the previous delivery.

KeyValue: attributes

This is a comma-separated list of attributes for the Service Journey. The possible values are defined in separate code lists shared by Samtrafiken here: Codelist: Attributes (service properties) .

Some of these attributes can be represented in standard Nordic-profile NeTEx, and if so they will also be specified in those terms, for example attribute “KOMEL" is also described as "powerSupplySockets". If the “attributes”-KeyValue is present it is enough to import said “attributes”, instead of also importing the regular Netex-representations of the service facilities.

Note, that the ServiceFacilities can also be specified for only parts of a journey in JourneyPart-elements.
Note that not all JourneyParts are declared for the purpose of containing ServiceFacilities. There might exist JourneyParts that express train numbers which change during a journey. A single JourneyPart-element will never contain both ServiceFacilities and a TrainNumberRef, it will always only contain one of the two. These two types of JourneyParts can be present at the same time within a ServiceJourney and they might overlap with regard to their FromStopPointRef and ToStopPointRef.
Here is one such example of a JourneyPart which contains ServiceFacilities:

Code Block
breakoutModewide
<ServiceJourney version="any" id="SE:074:ServiceJourney:300_17_f724f511e94aba890c97f8ee8d0b49d4">
    <keyList>
        <KeyValue>
            <Key>productCode</Key>
            <Value>RE</Value>
        </KeyValue>
    </keyList>
    <PrivateCode>1036</PrivateCode>
    <TransportMode>rail</TransportMode>
    <TransportSubmode>
        <RailSubmode>unknown</RailSubmode>
    </TransportSubmode>
    <dayTypes>
        <DayTypeRef ref="SE:074:DayType:250"/>
    </dayTypes>
    <JourneyPatternRef ref="SE:074:JourneyPattern:949400000000636703" version="any"/>
    <PublicCode>1036</PublicCode>
    <OperatorRef ref="SE:074:Operator:9013300000100000"/>
    <trainNumbers>
        <TrainNumberRef>1036</TrainNumberRef>
    </trainNumbers>
    <passingTimes>
        ...
    </passingTimes>
    <parts>
        <JourneyPart version="any" id="SE:074:JourneyPart:949400000000636703_1">
            <MainPartRef ref="SE:074:JourneyPart:949400000000636703_1" version="any"/>
            <FromStopPointRef ref="SE:074:ScheduledStopPoint:9022074000003001"/>
            <ToStopPointRef ref="SE:074:ScheduledStopPoint:9022074000120001"/>
            <StartTime>10:48:00</StartTime>
            <EndTime>11:00:00</EndTime>
            <facilities>
                <ServiceFacilitySet version="any" id="SE:074:ServiceFacilitySet:949400000001113899">
                    <keyList>
                        <KeyValue>
                            <Key>attributes</Key>
                            <Value>BOKEJB</Value>
                        </KeyValue>
                    </keyList>
                    <ServiceReservationFacilityList>noReservationsPossible</ServiceReservationFacilityList>
                </ServiceFacilitySet>
            </facilities>
        </JourneyPart>
    </parts>
    <facilities>
        <ServiceFacilitySet version="any" id="SE:074:ServiceFacilitySet:949400000001113897">
            <keyList>
                <KeyValue>
                    <Key>attributes</Key>
                    <Value>KOMAB,BOKP37,EVFEUJ,KOMEL,KOMIUK,KOMLYF,BOKFRI</Value>
                </KeyValue>
            </keyList>
            <MobilityFacilityList>suitableForWheelchairs</MobilityFacilityList>
            <PassengerCommsFacilityList>powerSupplySockets internet</PassengerCommsFacilityList>
            <ServiceReservationFacilityList>reservationsPossible</ServiceReservationFacilityList>
        </ServiceFacilitySet>
    </facilities>
</ServiceJourney>

Extension - CountyBorderCrossing in TimetabledPassingTime

A new CountyBorderCrossing extension element has been added inside the TimetabledPassingTime element.
The element is located inside an <Extensions> tag, which is the way that allows new elements to be introduced into the NeTEx data.

The CountyBorderCrossing element is inserted at the point where after that stop, the journey crosses the county-border and enters into a new county.

Below is a shortened example of this where a train goes from Boxholm in Östergötland to Tranås in Jönköping.

Code Block
breakoutModefull-width
<passingTimes>
    <TimetabledPassingTime version="any" id="SE:030:TimetabledPassingTime:313100000004740965">
        <StopPointInJourneyPatternRef ref="SE:030:StopPointInJourneyPattern:313100000000016403_313100000000370622" version="any"/>
        <DepartureTime>17:39:00</DepartureTime>
    </TimetabledPassingTime>
    <TimetabledPassingTime version="any" id="SE:030:TimetabledPassingTime:313100000004740969">
        <StopPointInJourneyPatternRef ref="SE:030:StopPointInJourneyPattern:313100000000016403_313100000000370626" version="any"/>
        <ArrivalTime>18:23:00</ArrivalTime>
        <DepartureTime>18:29:00</DepartureTime>
    </TimetabledPassingTime>
    <TimetabledPassingTime version="any" id="SE:030:TimetabledPassingTime:313100000004740970">
        <Extensions>
            <ns4:countyBorderCrossings>
                <ns4:CountyBorderCrossing>
                    <ns4:fromCounty>5</ns4:fromCounty>
                    <ns4:toCounty>6</ns4:toCounty>
                    <ns4:longitude>14.984382</ns4:longitude>
                    <ns4:latitude>58.149419</ns4:latitude>
                    <ns4:type>route</ns4:type>
                </ns4:CountyBorderCrossing>
            </ns4:countyBorderCrossings>
        </Extensions>
        <StopPointInJourneyPatternRef ref="SE:030:StopPointInJourneyPattern:313100000000016403_313100000000370627" version="any"/>
        <ArrivalTime>18:37:00</ArrivalTime>
        <DepartureTime>18:37:00</DepartureTime>
    </TimetabledPassingTime>
    <TimetabledPassingTime version="any" id="SE:030:TimetabledPassingTime:313100000004740971">
        <StopPointInJourneyPatternRef ref="SE:030:StopPointInJourneyPattern:313100000000016403_313100000000370628" version="any"/>
        <ArrivalTime>18:48:00</ArrivalTime>
    </TimetabledPassingTime>
</passingTimes>

The above example indicates that the journey travels from county 5 (Östergötland) into county 6 (Jönköping) and the coordinate where the trip crosses the county-border. The <type>route</type> indicates that the coordinate has been calculated based on the actual route that the vehicle travels. If the type instead is <type>linear</type> it means that the coordinate has been calculated by linear interpolation between the stops, meaning that it is not a very exact measurement.

In very rare cases there can actually be several CountyBorderCrossing elements inside the same TimetabledPassingTime. They would then all be put inside the same <countyBorderCrossings> element.

The CountyBorderCrossing data is only added for a few producers at the moment. They are:

  • 276 - Skånetrafiken

  • 430 - Pågatåg

  • 258 - Blekingetrafiken

  • 253 - Östgötatrafiken

  • 608 - Östgötapendeln

The county numbers used are the ones defined by SCB for all 21 counties in Sweden. See the complete list here: https://www.scb.se/hitta-statistik/regional-statistik-och-kartor/regionala-indelningar/lan-och-kommuner/lan-och-kommuner-i-kodnummerordning/

Changed producers file - changes.csv

...