.create_reader(+)

IntermodalConverter reader factory method
Description

The factory method that allows you to create (manufacture) intermodal reader instances of a chosen type. Currently, the following options are supported:

Whenever a country name is to be supplied, make sure this name complies with the ISO 3166 standard (see for example https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes ).

For all but the PLANit reader it is recommended to provide the country of origin of the input file as it is used to create the appropriate defaults that are not embedded in the input files. If not provided or the country is not yet supported by PLANit, the reader falls back to “Global” defaults.

Some readers, such as the GTFS reader, the underlying data is not able to construct all inputs, in those cases an alternative reader needs to be supplied to do so. For GTFS, this would typically be an OSM intermodal reader. See GTFS intermodal reader for an example.

Each reader can be configured further via its settings, where each type of reader exposes different settings depending on its type.

Signature

.create_reader(intermodal_reader_type:IntermodalReaderType, country:str="Global", reference_reader: IntermodalReaderWrapper = None )

with

Parameter Type Unit Compulsory Description
intermodal_reader_type IntermodalReaderType.<enum> None YES Type of intermodal reader to create
country String None NO The Country the contents resides in (ISO 3166)
reference_reader IntermodalReaderWrapper None NO The reader to obtain contents from not natively available for this reader’s data source

Return type

IntermodalReader implementation

Example 1

from planit import *

# create an intermodal converter
planit_instance = Planit()
intermodal_converter = planit_instance.converter_factory.create(ConverterType.NETWORK)

# example Open Street Map (OSM) intermodal reader        
osm_reader = intermodal_converter.create_reader(IntermodalReaderType.OSM, "<country_name>")
osm_reader.settings.set_input_file("<path_to_input_file>")

# example PLANit intermodal writer
planit_writer = intermodal_converter.create_writer(IntermodalReaderType.PLANIT)
planit_writer.settings.set_output_directory("<path_to_output_dir>")
planit_writer.settings.set_country("<country_name>")

# perform conversion
intermodal_converter.convert(osm_reader,matsim_writer)

See also

IntermodalReaderType.<enum> for the various intermodal reader types available
OsmIntermodalReader for more information on the OSM intermodal reader
GtfsIntermodalReader for more information on the GTFS intermodal reader
PlanitIntermodalReader for more information on the PLANit intermodal reader

Source code

Class IntermodalConverter in converter.py