Samtrafiken Noptis to GTFS mapping

This page describes how Samtrafiken maps Noptis data (see https://www.noptis.com/ ) to static GTFS data. For a complete specification of the GTFS format, please see http://gtfs.org/reference/static.

Data older than 3 days in the past is not imported. This means that, even if input data contains years of data in the past, only data with a validity period ending later than 3 days in the past can be imported and exported

Feed Info

feed_info.txt is not derived from any Noptis data. It is created based on the data-source configuration by Samtrafiken.

Field

Source data

Field

Source data

feed_id

SE-[agency abbreviation], configured by Samtrafiken

feed_publisher_name

Samtrafiken i Sverige AB hardcoded

feed_publisher_url

https://www.samtrafiken.se hardcoded

feed_lang

sv hardcoded

feed_version

Current day in yyyy-mm-dd format

Agency

Agencies are based on Noptis TransportAuthority objects. Some additional details, configured by Samtrafiken, are exported for the “primary” TransportAuthority in the region which is being exported.

Field

Source data

Field

Source data

agency_id

TransportAuthority.id

agency_name

TransportAuthority.FormalName if set,
TransportAuthority.Name if FormalName not set

agency_url

Agency homepage, configured by Samtrafiken

agency_timezone

Europe/Stockholm hardcoded

agency_lang

sv hardcoded

agency_fare_url

Agency homepage, configured by Samtrafiken

Routes

Each route is based on a Noptis Line. Since there are cases where some journeys skip certain stops on the line (for example, a bus 1 and a bus 1X which share a Line), these Lines are split into one route per headsign.

  • If a Line only has journeys with the same headsign, there will be one Route that corresponds with the template.

  • If a Line has journeys with a different headsign, there will be one Route for each headsign that corresponds with the template.

Field

Source data

Field

Source data

route_id

Line.Gid when this the main route of a Noptis Line. The main route is the route with the shortest LineDesignation.

Line.Gid-DestinationDisplay.LineDesignation when this is an additional route on a Noptis Line.

For example, a line with Gid 1 and lineDesignations 8 and 8X will result in two routes with the following ids:

  • 1

  • 1-8X

agency_id

TransportAuthority.Id

route_short_name

DestinationDisplay.LineDesignation

route_long_name

Line.Name (only if Line.Name is set and different from DestinationDisplay.LineDesignation, otherwise empty)

route_type

Line.DefaultTransportModeCode

  • BUS → 700

  • TRAM → 900

  • METRO → 401

  • TRAIN → 100

  • SHIP → 1000

  • FERRY → 1000

  • TAXI → 1501

route_desc

GroupOfLines.Name

Trips

Trips are based on VehicleJourneys. For each unique DirectionOfLine Gid, the most recent DirectionOfLine is kept. For these kept DirectionOfLines VehicleJourneys are fetched. This means that, if there are past or future versions of a certain DirectionOfLine, trips associated to these versions will not be exported.

Each exported VehicleJourney is represented by one line in trips.txt.

Field

Source data

Field

Source data

route_id

Line.Gid when this the main route of a Noptis Line. The main route is the route with the shortest LineDesignation.

Line.Gid-DestinationDisplay.LineDesignation When this is an additional route on a Noptis Line.

service_id

sequential integer id, starting at 1

trip_id

VehicleJourney.Id

trip_headsign

Empty since this information is already present in route_short_name and route_long_name

direction_id

DirectionOfLine.DirectionCode

  • Even (2) → 0

  • Odd (1) → 1

shape_id

sequential integer id, starting at 1, matches the related shape shape_id

Calendar

Calendar.txt is only used to indicate the validity period for trips. All days are hardcoded to 0 (no traffic), after which actual traffic is added through calendar_dates.txt.

The calendar is constructed by going through all VehicleJourneys (which become GTFS Trips), and looking up all DatedVehicleJourneys for each of those VehicleJourneys. The collection of dates in the DatedVehicleJourneys for one VehicleJourney becomes a GTFS calendar entry, identified by a service_id in the GTFS Calendar and Calendar_dates file.

Each combination of dates for VehicleJourneys will have one service_id at most. If there are multiple VehicleJourneys with the same dates, both VehicleJourneys (GTFS Trips) will share the same service_id and calendar.

Field

Source data

Field

Source data

service_id

Sequential integer id, starting at 1, matches the related service_id in trips.txt

monday

0 hardcoded

tuesday

0 hardcoded

wednesday

0 hardcoded

thursday

0 hardcoded

friday

0 hardcoded

saturday

0 hardcoded

sunday

0 hardcoded

start_date

First DatedVehicleJourney.OperatingDayDate for the VehicleJourney this calendar is linked to

end_date

Last DatedVehicleJourney.OperatingDayDate for the VehicleJourney this calendar is linked to

Calendar_dates

Calendar_dates.txt is used to indicate on which days a trip is run. It is constructed by going through all VehicleJourneys (which become GTFS Trips), and looking up all DatedVehicleJourneys for each of those VehicleJourneys. The collection of dates in the DatedVehicleJourneys for one VehicleJourney becomes a GTFS calendar entry, identified by a service_id in the GTFS Calendar and Calendar_dates file. Each DatedVehicleJourney becomes a row in calendar_dates, linking a GTFS trip to the date specified in the calendar_date.

Each combination of dates for VehicleJourneys will have one service_id at most. If there are multiple VehicleJournes with the same dates, both VehicleJourneys (GTFS Trips) will share the same service_id and calendar_dates rows.

Field

Source data

Field

Source data

service_id

Sequential integer id, starting at 1, matches the related service_id in trips.txt

date

DatedVehicleJourney.OperatingDayDate

exception_type

1 hardcoded (Service has been added for the specified date)

Stop_times

For each GTFS Trip, which is based on a VehicleJourney, its stops are obtained from the associated CallAndPointInJourneyPatterns through the TimedJourneyPattern and VehicleJourneyTemplate. Each call becomes one row in stop_times.txt. Only stops which are associated with a StopPoint are exported.

DestinationDisplay is used to fill in the stop_headsign field. This is done by obtaining the NamedJourneyPattern for the VehicleJourneyTemplate, followed by looking up if a DestinationDisplay matches the DestinationPatternId and PointInJourneyPatternId.

Field

Source data

Field

Source data

trip_id

VehicleJourney.Id

arrival_time

VehicleJourney.PlannedStartOffsetDayTime + CallOnTimedJourneyPattern.LatestArrivalTimeOffsetSeconds

departure_time

VehicleJourney.PlannedStartOffsetDayTime + CallOnTimedJourneyPattern.EarliestDepartureTimeOffsetSeconds

stop_id

StopPoint.Gid (through CallOnTimedJourneyPattern → PointInJourneyPattern)

stop_sequence

PointInJourneyPattern.SequenceNumber

stop_headsign

Depends on DestinationDisplay:

  • When no DestinationDisplay is available: empty

  • When only a primary destination name is available, the primary destination name: DestinationDisplay.PrimaryDestinationName

  • When a secondary destination name of the “VIA” type is available, the first “via” the second destination name: DestinationDisplay.PrimaryDestinationName via DestinationDisplay.SecondaryDestinationName

pickup_type

PointInJourneyPattern.DepartureType:

  • No stop (0) → Pickup not available (1)

  • Stop but no boarding (1) → Pickup not available (1)

  • Stop, boarding if necessary (2) →
    If AdvanceOrderCondition exists: “Must coordinate with agency” (2), else “Must coordinate with driver” (3)

  • Flexible stop (5):
    If AdvanceOrderCondition exists: “Must coordinate with agency” (2), else “Must coordinate with driver” (3)

  • Always boarding (3):
    If AdvanceOrderCondition exists: “Must arrange with agency” (2), else “Scheduled”
    (0)

drop_off_type

PointInJourneyPattern.ArrivalType:

  • No stop (0) → Drop-off not available (1)

  • Stop but no boarding (1) → Drop-off not available (1)

  • Stop, boarding if necessary (2) →
    If AdvanceOrderCondition exists: “Must coordinate with agency” (2), else “Must coordinate with driver” (3)

  • Flexible stop (5):
    If AdvanceOrderCondition exists: “Must coordinate with agency” (2), else “Must arrange with driver” (3)

  • Always alighting (3):
    If AdvanceOrderCondition exists: “Must coordinate with agency” (2), else “Scheduled”
    (0)

shape_dist_traveled

Sum of distances in RouteLink.DistanceMeters up to this point

timepoint

CallOnTimedJourneyPattern.isTimingPoint

Stops

The content in the stops.txt file is generated from multiple sources: StopAreas, StopPoints and StationEntryPoints.

StopAreas in Stops.txt

Field

Source data

Field

Source data

stop_id

StopArea.Gid

stop_name

StopArea.Name

stop_lat

StopArea.CentroidNorthingCoordinate

stop_lon

StopArea.CentroidEastingCoordinate

location_type

1

parent_station

empty

platform_code

empty

StopPoints in Stops.txt

Field

Source data

Field

Source data

stop_id

StopPoint.Gid

stop_name

StopPoint.Name if available, otherwise StopArea.Name

stop_lat

JourneyPatternPoint.CentroidNorthingCoordinate

stop_lon

JourneyPatternPoint.CentroidEastingCoordinate

location_type

0

parent_station

StopPoint.IsIncludedInStopAreaGid

platform_code

StopPoint.Designation

StationEntrancePoints in Stops.txt

Field

Source data

Field

Source data

stop_id

StationEntrancePoint.Gid

stop_name

StationEntrancePoint.Name

stop_lat

StationEntrancePoint.CentroidNorthingCoordinate

stop_lon

StationEntrancePoint.CentroidEastingCoordinate

location_type

2

parent_station

StationEntrancePoint.IsIncludedInStopAreaGid

platform_code

empty

Shapes

Shapes.txt contains the RouteLinks for the VehicleJourneys described in trips.txt. The RouteLinks are selected by the TransportModeCode and JourneyPatternPoints.

Field

Source data

Field

Source data

shape_id

sequential integer id, starting at 1, matches the related shape_id in trips.txt

shape_pt_lat

PointOnRouteLink.LocationEastingCoordinate

shape_pt_lon

PointOnRouteLink.LocationNorthingCoordinate

shape_pt_sequence

sequential integer id, starting at 1 for each shape_id

shape_dist_traveled

Sum of distances in RouteLink.DistanceMeters up to this point

Transfers

Transfers.txt contains 3 types of transfers:

  • stop-to-stop transfers from a StopArea to that same StopArea, based on StopArea.DefaultInterchangeDurationSeconds. Only created when DefaultInterchangeDurationSeconds is set.

  • stop-to-stop transfers between two StopPoints, based on ConnectionLinks.

  • trip-to-trip transfers, based on ConnectionCandidates with ConnectionType “ANSL”. The related JourneyPatternPoint GIDs are fetched by looking up the JourneyPatternPoint associated with the CallOnTimedJourneyPatterns that correspond with ConnectionCandidateEntity.IsFromFeederCallOnTimedJourneyPatternId / ConnectionCandidateEntity.IsToFetcherCallOnTimedJourneyPatternId

Field

Source data

Field

Source data

from_stop_id

One of:

  • StopArea.Gid, only to the same StopArea.

  • StopPoint.Gid (referenced from ConnectionLink)

to_stop_id

One of:

  • StopArea.Gid, only from the same StopArea.

  • StopPoint.Gid (referenced from ConnectionLink)

from_trip_id

ConnectionCandidateEntity.IsFromFeederCallOnTimedJourneyPatternId

to_trip_id

ConnectionCandidateEntity.IsToFetcherCallOnTimedJourneyPatternId

transfer_type

  • 1 (Timed transfer point between two routes) for trip-to-trip transfers

  • 2 (Transfer requires a minimum amount of time between arrival and departure to ensure a connection) for stop-to-stop transfers

min_transfer_time

Only used for stop-to-stop transfers. One of (see description above):

  • StopArea.DefaultInterchangeDurationSeconds

  • ConnectionLink.DefaultDurationSeconds

Attribution

File attributions.txt contains the operator name for each trip.

Field

Source data

Field

Source data

trip_id

VehicleJourney.Id

organization_name

Contractor.FormalName or Contractor.Name

is_operator

1 hardcoded

Extra: trips_dated_vehicle_journey.txt

We produce an additional file for those who want to map the GTFS data to the source Noptis data. trips_dated_vehicle_journey.txt contains a mapping of trip_id and operating_day_date combination to find the original DatedVehicleJourney.Gid and the associated journey number.

Field

Source data

Field

Source data

trip_id

GTFS trips.txt → trip_id

operating_day_date

GTFS calendar_dates.txt → date

dated_vehicle_journey_gid

Noptis DatedVehicleJourney.Gid

journey_number

DatedVehicleJourney journey number