TntpNetworkReader

TntpNetworkReader instance

The TntpNetworkReader class instance can be created via the NetworkConverter. It provides the functionality to parse networks in the TNTP format, and possibly persist it in the same or another format using a NetworkWriter. Once created the user can configure its settings.

For information on the TNTP data format, please consult the Data formats/Input/tntp section

All configuration of this reader is performed via its .settings property, providing access to the TntpNetworkReaderSettings.

Minimum configuration requirements

The user is required to explicitly configure at least the following settings on TntpNetworkReader:

  • set a network file via .settings.set_network_file(+)
  • set node coordinates file via .settings.set_node_coordinate_file(+)

since the TNTP format is not very rigorously defined it is most likely you also explicitly need to provide the column mapping information to correctly parse the data, as well as defining the units in which the information is provided via

  • configure the column configuration via .settings.set_network_file_columns(+)
  • configure units via various methods, e.g., for speed units for example use .settings.set_speed_units(+)

Methods

N/A

Properties

This class exposes the following properties:

Property Availability Description
.settings Always Access to TntpNetworkReaderSettings to configure the reader

Example 1

from planit import *

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

# TNTP network reader        
tntp_reader = network_converter.create_reader(NetworkReaderType.TNTP)
tntp_reader.settings.set_network_file(NETWORK_FILE_PATH)
tntp_reader.settings.set_node_coordinate_file(NODE_COORD_FILE_PATH)

#PLANit network writer
planit_writer = network_converter.create_writer(NetworkWriterType.PLANIT)
planit_writer.settings.set_output_directory("<path_to_output_dir>")

# perform conversion
network_converter.convert(tntp_reader, planit_writer)

See also

TntpNetworkReaderSettings for configuration of the TNTP network reader
ConverterFactory for the converter factory to create other types of converters
NetworkReaderType for the supported network reader types
NetworkWriterType for the supported network writer types

Source code

Class TntpNetworkReaderWrapper in converterwrappers.py


.settings

TntpNetworkReader property