Package org.planit.io.output.formatter
Class PlanItOutputFormatter
- java.lang.Object
-
- org.planit.output.formatter.BaseOutputFormatter
-
- org.planit.output.formatter.FileOutputFormatter
-
- org.planit.output.formatter.CsvFileOutputFormatter
-
- org.planit.io.output.formatter.PlanItOutputFormatter
-
- All Implemented Interfaces:
CsvTextFileOutputFormatter
,OutputFormatter
,XmlTextFileOutputFormatter
public class PlanItOutputFormatter extends CsvFileOutputFormatter implements CsvTextFileOutputFormatter, XmlTextFileOutputFormatter
The default output formatter of PlanIt- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.planit.output.formatter.CsvFileOutputFormatter
csvFileNameMap
-
Fields inherited from class org.planit.output.formatter.BaseOutputFormatter
id, initialCostsLocation, outputKeyProperties, outputTimeUnit, outputTypeKeysLocked, outputTypes, outputTypeValuesLocked, outputValueProperties
-
Fields inherited from interface org.planit.output.formatter.OutputFormatter
MEMORY_OUTPUT_FORMATTER, NOT_SPECIFIED, PLANIT_OUTPUT_FORMATTER
-
-
Constructor Summary
Constructors Constructor Description PlanItOutputFormatter(IdGroupingToken groupId)
Constructor, takes values for properties file name, description and version property
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canHandleMultipleIterations()
Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to truevoid
finaliseAfterSimulation(OutputConfiguration outputConfiguration, OutputAdapter outputAdapter)
Finalize the persistence after the simulation.List<String>
getCsvFileName(OutputType outputType)
Returns the list of names of CSV output file for a specified output typeString
getXmlFileName(OutputType outputType)
Returns the XML output file name for a specified output typevoid
initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId)
Create the output directories and open the CSV writersboolean
isCsvDirectorySet()
Returns whether the csv directory has been setboolean
isXmlDirectorySet()
Returns whether the xml directory has been setvoid
resetCsvDirectory()
Call this method to delete all existing files in the CSV output directoryvoid
resetXmlDirectory()
Call this method to delete all existing files in the XML output directoryvoid
setCsvDirectory(String csvDirectory)
Set the directory for CSV output filesvoid
setCsvNameExtension(String csvNameExtension)
Sets the extension of the CSV output filevoid
setCsvNameRoot(String csvNameRoot)
Sets the root name of the CSV output filevoid
setOutputDirectory(String outputDirectory)
Set the common directoryvoid
setXmlDirectory(String xmlDirectory)
Set the output directory for XML output filesvoid
setXmlFileNamePerOutputType(OutputType outputType, String xmlFileName)
Set the name of an XML output file for a specified output typevoid
setXmlNameExtension(String xmlNameExtension)
Sets the extension of the XML output filevoid
setXmlNameRoot(String xmlNameRoot)
Sets the root name of the XML output fileprotected void
writeGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write General results for the current time period to the CSV fileprotected void
writeLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write link results for the current time period to the CSV fileprotected void
writeOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Origin-Destination results for the time period to the CSV fileprotected void
writePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Path results for the time period to the CSV fileprotected void
writeSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Simulation results for the current time period to the CSV file-
Methods inherited from class org.planit.output.formatter.CsvFileOutputFormatter
addCsvFileNamePerOutputType, openCsvFileAndWriteHeaders, writeLinkResultsForCurrentTimePeriodToCsvPrinter, writeOdResultsForCurrentTimePeriodToCsvPrinter, writePathResultsForCurrentTimePeriodToCsvPrinter
-
Methods inherited from class org.planit.output.formatter.FileOutputFormatter
generateOutputFileName, generateOutputFileName
-
Methods inherited from class org.planit.output.formatter.BaseOutputFormatter
getId, getOutputTimeUnit, getOutputTimeUnitString, lockOutputProperties, persist, setOutputTimeUnit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.output.formatter.CsvTextFileOutputFormatter
addCsvFileNamePerOutputType
-
-
-
-
Constructor Detail
-
PlanItOutputFormatter
public PlanItOutputFormatter(IdGroupingToken groupId) throws PlanItException
Constructor, takes values for properties file name, description and version property- Parameters:
groupId
- contiguous id generation within this group for instances of this class- Throws:
PlanItException
- thrown if the application properties file exists but cannot be opened
-
-
Method Detail
-
writeSimulationResultsForCurrentTimePeriod
protected void writeSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Simulation results for the current time period to the CSV file- Specified by:
writeSimulationResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
writeGeneralResultsForCurrentTimePeriod
protected void writeGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write General results for the current time period to the CSV file- Specified by:
writeGeneralResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
writeOdResultsForCurrentTimePeriod
protected void writeOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Origin-Destination results for the time period to the CSV file- Specified by:
writeOdResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
writePathResultsForCurrentTimePeriod
protected void writePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Path results for the time period to the CSV file- Specified by:
writePathResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
writeLinkResultsForCurrentTimePeriod
protected void writeLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write link results for the current time period to the CSV file- Specified by:
writeLinkResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
initialiseBeforeSimulation
public void initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId) throws PlanItException
Create the output directories and open the CSV writers- Specified by:
initialiseBeforeSimulation
in interfaceOutputFormatter
- Parameters:
outputConfiguration
- OutputConfiguration of the assignmentrunId
- the id of the traffic assignment to be saved- Throws:
PlanItException
- thrown if there is an error or validation failure during set up of the output formatter
-
finaliseAfterSimulation
public void finaliseAfterSimulation(OutputConfiguration outputConfiguration, OutputAdapter outputAdapter) throws PlanItException
Finalize the persistence after the simulation. Here we generate the XML meta-data file(s) *- Specified by:
finaliseAfterSimulation
in interfaceOutputFormatter
- Parameters:
outputConfiguration
- OutputTypeConfiguration of the assignment that have been activatedoutputAdapter
- the outputAdapter- Throws:
PlanItException
- thrown if there is an error closing a resource
-
resetXmlDirectory
public void resetXmlDirectory() throws PlanItException
Call this method to delete all existing files in the XML output directory- Throws:
PlanItException
- thrown if there is an error
-
resetCsvDirectory
public void resetCsvDirectory() throws PlanItException
Call this method to delete all existing files in the CSV output directory- Throws:
PlanItException
- thrown if there is an error
-
setXmlDirectory
public void setXmlDirectory(String xmlDirectory)
Set the output directory for XML output files- Specified by:
setXmlDirectory
in interfaceXmlTextFileOutputFormatter
- Parameters:
xmlDirectory
- directory for XML output files
-
isXmlDirectorySet
public boolean isXmlDirectorySet()
Returns whether the xml directory has been set- Returns:
- true if the xml directory has been set, false otherwise
-
isCsvDirectorySet
public boolean isCsvDirectorySet()
Returns whether the csv directory has been set- Returns:
- true if the csv directory has been set, false otherwise
-
setCsvDirectory
public void setCsvDirectory(String csvDirectory)
Set the directory for CSV output files- Specified by:
setCsvDirectory
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvDirectory
- directory for CSV output files
-
setOutputDirectory
public void setOutputDirectory(String outputDirectory)
Set the common directory- Parameters:
outputDirectory
- common output directory
-
setXmlNameExtension
public void setXmlNameExtension(String xmlNameExtension)
Sets the extension of the XML output file- Specified by:
setXmlNameExtension
in interfaceXmlTextFileOutputFormatter
- Parameters:
xmlNameExtension
- the extension of the XML output file
-
setXmlNameRoot
public void setXmlNameRoot(String xmlNameRoot)
Sets the root name of the XML output file- Specified by:
setXmlNameRoot
in interfaceXmlTextFileOutputFormatter
- Parameters:
xmlNameRoot
- root name of XML output file
-
setCsvNameRoot
public void setCsvNameRoot(String csvNameRoot)
Sets the root name of the CSV output file- Specified by:
setCsvNameRoot
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvNameRoot
- root name of CSV output file
-
setCsvNameExtension
public void setCsvNameExtension(String csvNameExtension)
Sets the extension of the CSV output file- Specified by:
setCsvNameExtension
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvNameExtension
- the extension of the CSV output file
-
getCsvFileName
public List<String> getCsvFileName(OutputType outputType)
Returns the list of names of CSV output file for a specified output type- Specified by:
getCsvFileName
in interfaceCsvTextFileOutputFormatter
- Parameters:
outputType
- the specified output type- Returns:
- the name of the output file
-
canHandleMultipleIterations
public boolean canHandleMultipleIterations()
Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to true- Specified by:
canHandleMultipleIterations
in interfaceOutputFormatter
- Returns:
- flag to indicate whether the OutputFormatter can handle multiple iterations
-
getXmlFileName
public String getXmlFileName(OutputType outputType)
Returns the XML output file name for a specified output type- Specified by:
getXmlFileName
in interfaceXmlTextFileOutputFormatter
- Parameters:
outputType
- the specified output type- Returns:
- the name of the output file
-
setXmlFileNamePerOutputType
public void setXmlFileNamePerOutputType(OutputType outputType, String xmlFileName)
Set the name of an XML output file for a specified output type- Specified by:
setXmlFileNamePerOutputType
in interfaceXmlTextFileOutputFormatter
- Parameters:
outputType
- the specified output typexmlFileName
- the name of the output file to be added for the specified output type
-
-