Package org.goplanit.io.output.formatter
Class PlanItOutputFormatter
- java.lang.Object
-
- org.goplanit.output.formatter.BaseOutputFormatter
-
- org.goplanit.output.formatter.FileOutputFormatter
-
- org.goplanit.output.formatter.CsvFileOutputFormatter
-
- org.goplanit.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.goplanit.output.formatter.CsvFileOutputFormatter
csvFileNameMap
-
Fields inherited from class org.goplanit.output.formatter.BaseOutputFormatter
id, initialCostsLocation, outputKeyProperties, outputTimeUnit, outputTypeKeysLocked, outputTypes, outputTypeValuesLocked, outputValueProperties
-
Fields inherited from interface org.goplanit.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 booleancanHandleMultipleIterations()Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to truevoidfinaliseAfterSimulation(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 typeStringgetXmlFileName(OutputType outputType)Returns the XML output file name for a specified output typevoidinitialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId)Create the output directories and open the CSV writersbooleanisCsvDirectorySet()Returns whether the csv directory has been setbooleanisXmlDirectorySet()Returns whether the XML directory has been setvoidresetCsvDirectory()Call this method to delete all existing files in the CSV output directoryvoidresetXmlDirectory()Call this method to delete all existing files in the XML output directoryvoidsetCsvDirectory(String csvDirectory)Set the directory for CSV output filesvoidsetCsvNameExtension(String csvNameExtension)Sets the extension of the CSV output filevoidsetCsvNameRoot(String csvNameRoot)Set the root name of the CSV output file for all output typesvoidsetOutputDirectory(String outputDirectory)Set the common directoryvoidsetXmlDirectory(String xmlDirectory)Set the output directory for XML output filesvoidsetXmlFileNamePerOutputType(OutputType outputType, String xmlFileName)Set the name of an XML output file for a specified output typevoidsetXmlNameExtension(String xmlNameExtension)Sets the extension of the XML output filevoidsetXmlNameRoot(String xmlNameRoot)Sets the root name of the XML output fileprotected voidwriteGeneralResultsForCurrentTimePeriod(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 voidwriteLinkResultsForCurrentTimePeriod(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 voidwriteOdResultsForCurrentTimePeriod(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 voidwritePathResultsForCurrentTimePeriod(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 voidwriteSimulationResultsForCurrentTimePeriod(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.goplanit.output.formatter.CsvFileOutputFormatter
addCsvFileNamePerOutputType, openCsvFileAndWriteHeaders, writeLinkResultsForCurrentTimePeriodToCsvPrinter, writeOdResultsForCurrentTimePeriodToCsvPrinter, writePathResultsForCurrentTimePeriodToCsvPrinter
-
Methods inherited from class org.goplanit.output.formatter.FileOutputFormatter
generateOutputFileName, generateOutputFileName
-
Methods inherited from class org.goplanit.output.formatter.BaseOutputFormatter
getId, lockOutputProperties, persist
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.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:
writeSimulationResultsForCurrentTimePeriodin 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:
writeGeneralResultsForCurrentTimePeriodin 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:
writeOdResultsForCurrentTimePeriodin 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:
writePathResultsForCurrentTimePeriodin 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:
writeLinkResultsForCurrentTimePeriodin 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:
initialiseBeforeSimulationin 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:
finaliseAfterSimulationin 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 PlanItExceptionCall 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 PlanItExceptionCall 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:
setXmlDirectoryin 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:
setCsvDirectoryin 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:
setXmlNameExtensionin 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:
setXmlNameRootin interfaceXmlTextFileOutputFormatter- Parameters:
xmlNameRoot- root name of XML output file
-
setCsvNameExtension
public void setCsvNameExtension(String csvNameExtension)
Sets the extension of the CSV output file- Specified by:
setCsvNameExtensionin 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:
getCsvFileNamein interfaceCsvTextFileOutputFormatter- Parameters:
outputType- the specified output type- Returns:
- the name of the output file
-
setCsvNameRoot
public void setCsvNameRoot(String csvNameRoot)
Set the root name of the CSV output file for all output types- Specified by:
setCsvNameRootin interfaceCsvTextFileOutputFormatter- Parameters:
csvNameRoot- the root 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:
canHandleMultipleIterationsin 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:
getXmlFileNamein 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:
setXmlFileNamePerOutputTypein interfaceXmlTextFileOutputFormatter- Parameters:
outputType- the specified output typexmlFileName- the name of the output file to be added for the specified output type
-
-