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

Only for the Open Street Map 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 OSM files. If not provided or the country is not yet supported with OSM defaults by Planit, the reader falls back to “Global” defaults.

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

Signature

.create_reader(intermodal_reader_type:IntermodalReaderType, country:str=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 network is sourced from (ISO 3166).

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

NetworkReaderType.<enum> for the various network reader types available
OsmNetworkReader for more information on the OSM network reader
PlanitNetworkReader for more information on the Planit network reader

Source code

Class NetworkConverter in converter.py

Last modified January 1, 0001