.create(+)
ConverterFactory factory method
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 provide an easy way to convert one data format into another by means of a predefined process that requires:
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 the following types of converters:
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 implementation. PLANit-Python only provides access to the officially supported readers/writers detailed in this manual.
All readers/writers are to be created by your converter. Once you have create a reader and writer, it may need specific configuration. To achieve this, all readers and writers have one or more settings properties, see Example 1. The properties and options vary per reader/writer, but all provide a settings property. In case of a converter that encompasses multiple converters (like the intermodal converter). The settings of such a converter, in turn provide access, the to settings of each underlying sub-converter.
This approach of configuring all readers and writers in the same way 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.
The ConverterFactory
instance exposes the following methods
Name | Description |
---|---|
.create(+) |
create a novel converter based on the provided ConverterType |
N/A
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, "Australia")
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("Australia")
# perform conversion
network_converter.convert(reader,writer)
NetworkConverter for more information on how to create and configure a network converter
ZoningConverter for more information on how to create and configure a zoning converter
DemandsConverter for more information on how to create and configure a demands (od trips) converter
IntermodalConverter for more information on how to create and configure an intermodal converter
Class ConverterFactory
in converter.py
ConverterFactory factory method
IntermodalConverter instance
NetworkConverter instance
ZoningConverter instance
DemandsConverter instance