Home

Awesome

NeTEx-to-GTFS Converter Java

CircleCI

Converts NeTEX datasets into GTFS datasets. The input NeTEx datasets are required to follow the Nordic NeTEx Profile.

Input data

The converter requires:

Output

The converter produces a GTFS zip archive containing timetable data.

Data format prerequisites

The library supports out-of-the-box NeTEx datasets that follow the Nordic NeTEx Profile and assumes that the dataset structure and completeness are compatible with the Nordic NeTEx Profile (example: required name on a Line, required DestinationDisplay on the first stop of a JourneyPattern, ...). Supporting other NeTEx profiles is possible by overriding the default conversion process (see Extension points below).

Usage

    InputStream stopsAndQuaysDataset = // input stream pointing to a zip archive containing the NeTEX stops and quays definitions.
    DefaultStopAreaRepository defaultStopAreaRepository = new DefaultStopAreaRepository();
    defaultStopAreaRepository.loadStopAreas(stopsAndQuaysDataset);

    InputStream netexTimetableDataset = // input stream pointing to a zip archive containing the NeTEX timetable data.
    String codespace = // NeTEX codespace for the timetable data provider.

    GtfsExporter gtfsExport = new DefaultGtfsExporter(codespace, defaultStopAreaRepository);

    // the returned Inputstream points to a GTFS zip archive
    InputStream exportedGtfs = gtfsExport.convertTimetablesToGtfs(netexTimetableDataset);

Extension points

GTFS entities are created by Producers interfaces (AgencyProducer, TripProducer, ...) The library contains default implementations for these interfaces. They can be overridden in order to customize the conversion process. The NetexDatasetLoader interface specifies the way NeTEx data is loaded into memory. The default implementation can also be overridden. Example:

public class EnturGtfsExporter extends DefaultGtfsExporter {
    public EnturGtfsExporter(String codespace, StopAreaRepository stopAreaRepository) {
        super(codespace, stopAreaRepository);
        setNetexDatasetLoader(new EnturNetexDatasetLoader());
        setAgencyProducer(new EnturAgencyProducer(getNetexDatasetRepository(), codespace));
        setFeedInfoProducer(new EnturFeedInfoProducer());
}

GtfsExporter gtfsExport = new EnturGtfsExporter(codespace, defaultStopAreaRepository);

}

Route Type Mapping

The table below contains the mapping between NeTEx transport modes/submodes and GTFS route types.
This mapping is a combination of:

Please note that NeTEx allows for overriding transport modes/submodes at the ServiceJourney level, while GTFS allows only one route type per route.
In case a NeTEx line makes use of multiple transport modes/submodes, only the transport mode/submode defined at the Line level is used in the conversion process.

NeTEx modeNeTEx submodeGTFS route type nameGTFS route type code
airAIR_SERVICE1100
airdomesticFlightDOMESTIC_AIR_SERVICE1102
airhelicopterServiceHELICOPTER_AIR_SERVICE1110
airinternationalFlightINTERNATIONAL_AIR_SERVICE1101
busBUS_SERVICE700
busairportLinkBusBUS_SERVICE700
busexpressBusEXPRESS_BUS_SERVICE702
buslocalBusLOCAL_BUS_SERVICE704
busnightBusNIGHT_BUS_SERVICE705
busrailReplacementBusRAIL_REPLACEMENT_BUS_SERVICE714
busregionalBusREGIONAL_BUS_SERVICE701
busschoolBusSCHOOL_BUS712
busshuttleBusSHUTTLE_BUS711
bussightseeingBusSIGHTSEEING_BUS710
cablewayTELECABIN_SERVICE1300
coachCOACH_SERVICE200
coachinternationalCoachINTERNATIONAL_COACH_SERVICE201
coachnationalCoachNATIONAL_COACH_SERVICE202
coachtouristCoachTOURIST_COACH_SERVICE207
ferryFERRY_SERVICE1200
funicularFUNICULAR_SERVICE1400
liftTELECABIN_SERVICE1300
metroMETRO_SERVICE401
otherMISCELLANEOUS_SERVICE1700
railRAILWAY_SERVICE100
railairportLinkRailHIGH_SPEED_RAIL_SERVICE101
railinternationalLONG_DISTANCE_TRAINS102
railinterregionalRailINTER_REGIONAL_RAIL_SERVICE103
raillocalRAILWAY_SERVICE100
raillongDistanceLONG_DISTANCE_TRAINS102
railnightRailSLEEPER_RAIL_SERVICE105
railregionalRailREGIONAL_RAIL_SERVICE106
railtouristRailwayTOURIST_RAILWAY_SERVICE107
taxiTAXI_SERVICE1500
tramTRAM_SERVICE900
tramcityTramCITY_TRAM_SERVICE901
tramlocalTramLOCAL_TRAM_SERVICE902
trolleyBusTROLLEYBUS_SERVICE800
waterWATER_TRANSPORT_SERVICE1000
waterhighSpeedPassengerServicePASSENGER_HIGH_SPEED_FERRY_SERVICE1014
waterhighSpeedVehicleServiceCAR_HIGH_SPEED_FERRY_SERVICE1013
waterinternationalCarFerryINTERNATIONAL_CAR_FERRY_SERVICE1001
waterinternationalPassengerFerryINTERNATIONAL_PASSENGER_FERRY_SERVICE1005
waterlocalCarFerryLOCAL_CAR_FERRY_SERVICE1004
waterlocalPassengerFerryLOCAL_PASSENGER_FERRY_SERVICE1008
waternationalCarFerryNATIONAL_CAR_FERRY_SERVICE1002
watersightseeingServiceSIGHTSEEING_BOAT_SERVICE1015