ZoningConverter

ZoningConverter instance

The ZoningConverter class instance can be created via the ConverterFactory. Once created it can be used to create zoning readers and writers that in turn can be offered to this converter to convert from the reader format to the writer format.

Via its .create_reader(+) and .create_writer(+) methods, the converter can construct readers and writers of supported types. The reader takes a ZoningReaderType while the writer takes a ZoningWriterType to indicate what reader/writer is to be created. The result is an instance of the desired reader/writer. The user then can/should configure the reader/writer based on the available settings. Once configured, the actual conversion can be performed through this converter by providing the created reader/writer to the .convert(+) method.

The user is expected to configure each reader/writers minimum required settings, often involving setting input/output file locations and/or directories for example. For each reader/writer these minimum user configuration actions are clearly indicated. Failing to do so will cause the conversion to fail as information is missing.

Zoning readers require a network reader as a prerequisite as network and zoning are tightly coupled. This network reader is expected to be made available upon construction of the zoning reader. To avoid such complexities a user can instead opt to construct an ‘all-in-one’ intermodal reader instead, if available.

Methods

ZoningConverter exposes the following methods

Name Description
.create_reader(+) Create a new zoning reader based on the provided ZoningReaderType
.create_writer(+) Create a new zoning writer based on the provided ZoningReaderType
.convert(+) Convert the zoning reader’s input into the zoning writer’s output format

Properties

N/A

Example 1

from planit import *

zoning_converter = planit.converter_factory.create(ConverterType.ZONING)

####### NETWORK PREP
#
# TNTP net reader
tntp_net_reader: TntpNetworkReaderWrapper = 
  planit.converter_factory.create(ConverterType.NETWORK).create_reader(NetworkReaderType.TNTP)
network_settings = tntp_net_reader.settings
network_settings.set_network_file(NETWORK_FILE_PATH)
network_settings.set_node_coordinate_file(NODE_COORD_FILE_PATH)
network_settings.set_network_file_columns(create_tntp_network_file_cols())

network_settings.set_speed_units(SpeedUnits.MILES_H)
network_settings.set_length_units(LengthUnits.MILES)
network_settings.set_capacity_period(1, TimeUnits.HOURS)
network_settings.set_free_flow_travel_time_units(TimeUnits.MINUTES)
network_settings.set_default_maximum_speed(DEFAULT_MAXIMUM_SPEED_KM_H)
network_settings.set_coordinate_reference_system("EPSG:26971")

# TNTP zoning reader - (pass in net_reader)
tntp_reader: TntpNetworkReaderWrapper = zoning_converter.create_reader(ZoningReaderType.TNTP, tntp_net_reader)
zoning_settings = tntp_reader.settings
zoning_settings.set_network_file_location(NETWORK_FILE_PATH)

# PLANit writer
planit_writer = zoning_converter.create_writer(ZoningWriterType.PLANIT)
planit_writer.settings.set_output_directory(OUTPUT_PATH)
planit_writer.settings.set_country(AUSTRALIA)

# perform conversion
zoning_converter.convert(tntp_reader, planit_writer)

See also

ConverterFactory for the converter factory to create other types of converters
ZoningReaderType for the supported zoning reader types
ZoningWriterType for the supported zoning writer types


.convert(+)

ZoningConverter method

.create_reader(+)

ZoningConverter reader factory method

.create_writer(+)

ZoningConverter writer factory method