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

It also makes use of the changed and modification attributes (see https://enturas.atlassian.net/wiki/spaces/PUBLIC/pages/728727624/framework#EntityInVersion) 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: https://brm.samtrafiken.se/showtimes?pta=-1&station=g%C3%B6teborg+centralstation .

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

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.

Stops file - _stops.xml - 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”.

<groupsOfStopPlaces> <GroupOfStopPlaces version="231007" id="SE:030:GroupOfStopPlaces:9091074000098000"> <ValidBetween> <FromDate>2023-10-07T00:00:00</FromDate> </ValidBetween> <keyList> <KeyValue> <Key>sellable</Key> <Value>true</Value> </KeyValue> <KeyValue> <Key>rikshallplatsNummer</Key> <Value>740098000</Value> </KeyValue> </keyList> <Name>STOCKHOLM</Name> <ShortName>STOCKHOLM</ShortName> <PrivateCode>98000</PrivateCode> <members> <StopPlaceRef ref="SE:030:StopPlace:9021074000001000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074000622000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074001617000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074004383000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074012144000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074020749000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074023844000" version="231007"/> <StopPlaceRef ref="SE:030:StopPlace:9021074024382000" version="231007"/> <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”.

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

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: https://samtrafiken.atlassian.net/wiki/spaces/SamA/pages/3619717173.

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: https://samtrafiken.atlassian.net/wiki/spaces/SamA/pages/3735617539 .

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:

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.

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

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.