Converter Factory

Converter Factory instance

Reference documentation for the ConverterFactory class instance that can be collected from the top-level Planit() instance to create, i.e., manufacture, converters of a specific type. The most common use case for creating a converter would be to convert a network from one format into another, e.g., parse an OSM network and persist it as a PLANit network for example

Converters follow a specific format. they require a:

  • Reader
  • Writer
  • Converter

The reader extracts data from a certain input format and presents it to the converter internally as a PLANit memory model. The writer accepts a PLANit memory model and persists it in its output format. The converter takes both a reader and writer and performs the conversion via a dedicated procedure.

PLANit-Python currently supports two types of converters:

  • a NetworkConverter that supports the conversion of road and/or rail infrastructure
  • an IntermodalConverter that adds support for “transfer zones”, e.g., infrastructure where transfers between modes occur such as bus stops, train platforms, stations etc.

Intermodal converters do not yet support bus/rail service as these are not considered part of the infrastructure. This is likely to be added at a later stage

There exist a number of reader/writer implementations that are supported out-of-the-box in PLANit-Python. As a user you can create your own reader/writers as well, although to use them you would need to utilise the Planit-Java imeplementation. PLANit-Python only provides access to the officially supported readers/writers detailed in this manual.

Configuration of reader/writers

To configure a reader/writer of any type - created by your converter - you should use the settings property, see Example 1. The available settings vary per reader/writer type, but all of the readers and writers provide a settings property. this way the creation of readers and writers can largely be done without providing complex parameters. However, it does mean that the user - depending on the chosen reader/writer type - has to provide a bare minimum of configuration settings before any conversion can proceed. To aid the user in what settings must be configured explicitly each reader/writer page in this manual details these settings to avoid any confusion.

Methods

A ConverterFactory instance exposes the following methods

Name Description
.create(+) create a novel converter based on the provided ConverterType

Properties

N/A

Example 1

from planit import *

# create a network converter
planit_instance = Planit()
network_converter = planit_instance.converter_factory.create(ConverterType.NETWORK)

# example Open Street Map (OSM) network reader        
osm_reader = network_converter.create_reader(NetworkReaderType.OSM, "<country_name>")
osm_reader.settings.set_input_file("<path_to_input_file>")

# example Planit network writer
planit_writer = network_converter.create_writer(NetworkWriterType.PLANIT)
planit_writer.settings.set_output_directory("<path_to_output_dir>")
planit_writer.settings.set_country("<country_name>")

# perform conversion
network_converter.convert(reader,writer)

See also

NetworkConverter for more information on how to create and configure a network converter
IntermodalConverter for more information on how to create and configure an intermodal converter

Source code

Class ConverterFactory in converter.py


.create(+)

ConverterFactory factory method

IntermodalConverter

IntermodalConverter instance

NetworkConverter

NetworkConverter instance

Last modified January 1, 0001