Skip to end of banner
Go to start of banner

NeTEx format adjustments - Samtrafiken sales export

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 44 Next »

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: Samtrafiken NeTEx export

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.

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.

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

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

N.B: All of the referred stops in a sellable GroupOfStopPlace 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 GroupOfStopPlace “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:

<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 version="any" id="SE:074:ServiceJourney:30_300_300_1036_1036_J_RE_2">
    <keyList>
        <KeyValue>
            <Key>productCode</Key>
            <Value>RE</Value>
        </KeyValue>
        <KeyValue>
            <Key>fingerprint</Key>
            <Value>nib84qjrt4p3pvaiatvag8u32cnjno8j</Value>
        </KeyValue>    
    </keyList>
    <PrivateCode>1036</PrivateCode>    
    <TransportMode>rail</TransportMode>
    <TransportSubmode>
        <RailSubmode>unknown</RailSubmode>
    </TransportSubmode>
    <dayTypes>
        <DayTypeRef ref="SE:074:DayType:ah0l8tejnuptnmgqvmp348sc3t8pmk72"/>
    </dayTypes>
    <JourneyPatternRef ref="SE:074:JourneyPattern:949400000000636569" version="any"/>
    <PublicCode>1036</PublicCode>
    <OperatorRef ref="SE:074:Operator:9013300000100000"/>
    <trainNumbers>
        <TrainNumberRef>1036</TrainNumberRef>
    </trainNumbers>
    <passingTimes>
        ...
    </passingTimes>
    <facilities>
        <ServiceFacilitySet version="any" id="SE:074:ServiceFacilitySet:949400000001112786">
            <keyList>
                <KeyValue>
                    <Key>attributes</Key>
                    <Value>KOMAB,BOKEJB,EVFEUJ,KOMEL,KOMIUK,KOMLYF</Value>
                </KeyValue>
            </keyList>
            <MobilityFacilityList>suitableForWheelchairs</MobilityFacilityList>
            <PassengerCommsFacilityList>powerSupplySockets internet</PassengerCommsFacilityList>
            <ServiceReservationFacilityList>noReservationsPossible</ServiceReservationFacilityList>
        </ServiceFacilitySet>
    </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:

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

<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

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

producerNumber,changeType
74,MODIFIED
222,MODIFIED
245,UNMODIFIED
248,UNMODIFIED
251,UNMODIFIED
252,UNMODIFIED
253,UNMODIFIED
254,UNMODIFIED
255,MODIFIED
256,UNMODIFIED
300,MODIFIED
310,UNMODIFIED
313,MODIFIED
315,MODIFIED
319,UNMODIFIED
812,MODIFIED
815,DELETED
821,UNMODIFIED
826,ADDED
828,MODIFIED
829,MODIFIED

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

producerNumber,lineNumber,changeType
74,1,MODIFIED
74,2,MODIFIED
74,10,UNMODIFIED
74,11,UNMODIFIED
74,13,UNMODIFIED
74,8248,UNMODIFIED
222,40,UNMODIFIED
222,41,UNMODIFIED
222,42,UNMODIFIED
222,44,UNMODIFIED
222,48,UNMODIFIED
251,1,MODIFIED
251,2,MODIFIED
275,966,UNMODIFIED
275,982,DELETED
279,3751,MODIFIED
279,3752,MODIFIED
279,3754,ADDED
279,3755,MODIFIED

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.

  • No labels