NeTEx format adjustments - Samtrafiken sales export

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.

For a general description of NeTEx data published by Samtrafiken, please see the documentation here: https://samtrafiken.atlassian.net/wiki/spaces/SamtrafikenOpenData/pages/989233182

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: https://samtrafiken.atlassian.net/wiki/spaces/SamtrafikenOpenData/pages/1085276190 and for special adjustments here: https://samtrafiken.atlassian.net/wiki/spaces/SamtrafikenOpenData/pages/3619717293.

Stops file - _stops.xml

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.

It also makes use of the changed and modification attributes (see ) so that changes to stops can be detected and handled by receiving systems, in order for them to avoid having to update all stops data with every new dataset.

Below is an example, the station “Göteborg Centralstation”.

<StopPlace changed="2023-08-23T22:49:53" modification="revise" version="20210926" id="SE:074:StopPlace:9021074000002000"> <ValidBetween> <FromDate>2021-09-26T00:00:00</FromDate> </ValidBetween> <keyList> <KeyValue> <Key>minimumInterchangeSeconds</Key> <Value>900</Value> </KeyValue> <KeyValue> <Key>sellable</Key> <Value>true</Value> </KeyValue> <KeyValue> <Key>rikshallplatsNummer</Key> <Value>740000002</Value> </KeyValue> <KeyValue> <Key>interchanges</Key> <Value>279:279:BLT:BLT:300|279:279:BLT:SLT:300|279:279:BLT:JLT:840|279:279:SLT:BLT:300|279:279:SLT:SLT:300|279:279:SLT:JLT:840|279:279:JLT:BLT:540|279:279:JLT:SLT:540|279:279:JLT:JLT:600|586:300:::1200</Value> </KeyValue> <KeyValue> <Key>trafikverketSignatures</Key> <Value>G</Value> </KeyValue> </keyList> <Name>Göteborg Centralstation</Name> <ShortName>Göteborg C</ShortName> <PrivateCode>2</PrivateCode> <Centroid> <Location> <Longitude>11.973478</Longitude> <Latitude>57.708894</Latitude> </Location> </Centroid> <OrganisationRef ref="SE:074:Authority:9010074000000000"/> <TransportMode>other</TransportMode> <StopPlaceType>other</StopPlaceType> <Weighting>preferredInterchange</Weighting>

Information about new and changed stops: changed and modification attributes

The changed attribute shows the last time that data for a StopPlace was changed in some way.

The modification attribute describes what type of change that occurred, compared to the last exported NeTEx dataset:

  • new - means that the StopPlace did not exist in the previous dataset, so it is a new stop.

  • revise - means that the StopPlace was changed in some way from the previous dataset.

Stops that have not been changed will not have have a modification attribute and their changed timestamp will be the same as in the previous dataset.

Stops that have been deleted, are simply removed from the _stops.xml file so if the receiving system wants to detect and handle that case, then it must be solved by the receiving system.

All fields and key-values on a StopPlace are evaluated in order to determine if it has been changed, EXCEPT for version and ValidBetween, because they change with every new dataset.

KeyValue: rikshallplatsNummer

This contains the “Rikshållplats”-number of the stop.

KeyValue: minimumInterchangeSeconds

This contains the default minimum time (in seconds) needed to make a change at this stop. The value is only specified if a change is allowed (as specified by the <Weighting> element).

The value is taken from Samtrafiken's BRM-system, similar to what you can see here: .

KeyValue: interchanges

This value contains specific change times (in seconds) between specific producers. It is used instead of the minimumInterchangeSeconds value for interchanges between the producer-pairs specified here.

The value actually contains multiple values, so it needs to be split twice, first on the '|' character, and then split again, on the ':' character, in order to parse the actual data.

For example the value “279:279:SLT:JLT:840|279:279:JLT:SLT:540|279:279:JLT:JLT:600|586:300:::1200" would first be split into:

279:279:SLT:JLT:840

279:279:JLT:SLT:540

279:279:JLT:JLT:600

586:300:::1200

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: .
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).

KeyValue: sellable

This value is true if the stop is sellable.

KeyValue: trafikverketSignatures

The Trafikverket station signature associated with this stop. Can be more than one, in which case signatures are separated by a comma.

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

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”.

<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:

<Line version="220224" id="SE:074:Line:9011222004000000"> <ValidBetween> <FromDate>2022-02-24T00:00:00</FromDate> </ValidBetween> <keyList> <KeyValue> <Key>salesAuthorityNumber</Key> <Value>275</Value> </KeyValue> </keyList> <Name>40</Name> <TransportMode>rail</TransportMode> <TransportSubmode> <RailSubmode>unknown</RailSubmode> </TransportSubmode> <PublicCode>40</PublicCode> <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:

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: .

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: .

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:

Changed producers file - changes.csv

An additional file changes.csv has been added to the NeTEx dataset. This file contains a list of the changed carriers/producers based on the previously published NeTEx dataset.

An example of the file is shown below (50 rows removed for brevity):

The changeType column describes if data from a producer has changed. It can have one of the 4 values:

  1. MODIFIED - Data for this producer has been modified in some way. The producer existed in the previous dataset.

  2. UNMODIFIED - Data for this producer has not been modified. The producer existed in the previous dataset.

  3. ADDED - The producer did not exist in the previous dataset. Its data has been added.

  4. DELETED - The producer existed in the previous dataset, but does not exist in the current one.

Changed lines file - changeslines.csv

An additional file changeslines.csv has been added to the NeTEx dataset. This file contains a list of the changed lines based on the previously published NeTEx dataset, so it gives a more detailed view of the changes than the changes.csv file that only shows changes on the producer level.

An example of some rows from the file is shown below (the file currently contains around 6000 rows):

The changeType column describes if data for a line has changed. It can have one of the 4 values:

  1. MODIFIED - Data for this line has been modified in some way. The line existed in the previous dataset.

  2. UNMODIFIED - Data for this line has not been modified. The line existed in the previous dataset.

  3. ADDED - The line did not exist in the previous dataset. Its data has been added.

  4. DELETED - The line existed in the previous dataset, but does not exist in the current one.