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, uses default values for properties file name, description property and version propertyPlanItOutputFormatter(IdGroupingToken groupId, String propertiesFileName)Constructor, uses default values description property and version propertyPlanItOutputFormatter(IdGroupingToken groupId, String propertiesFileName, String descriptionProperty, String versionProperty)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(Map<OutputType,OutputTypeConfiguration> outputTypeConfigurations, 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 typeStringgetDescription()Collect the description propertyStringgetXmlFileName(OutputType outputType)Returns the XML output file name for a specified output typevoidinitialiseBeforeSimulation(Map<OutputType,OutputTypeConfiguration> outputTypeConfigurations, 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)Sets the root name of the CSV output filevoidsetDescription(String description)Allows the developer to set the output description propertyvoidsetOutputDirectory(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.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, uses default values for properties file name, description property and version property- Parameters:
groupId- contiguous id generation within this group for instances of this class- Throws:
PlanItException- thrown if error
-
PlanItOutputFormatter
public PlanItOutputFormatter(IdGroupingToken groupId, String propertiesFileName, String descriptionProperty, String versionProperty) 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 classpropertiesFileName- the name of the application properties filedescriptionProperty- the name of the description propertyversionProperty- the name of the version property- Throws:
PlanItException- thrown if the application properties file exists but cannot be opened
-
PlanItOutputFormatter
public PlanItOutputFormatter(IdGroupingToken groupId, String propertiesFileName) throws PlanItException
Constructor, uses default values description property and version property- Parameters:
groupId- contiguous id generation within this group for instances of this classpropertiesFileName- the name of the application properties file- 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(Map<OutputType,OutputTypeConfiguration> outputTypeConfigurations, long runId) throws PlanItException
Create the output directories and open the CSV writers- Specified by:
initialiseBeforeSimulationin interfaceOutputFormatter- Parameters:
outputTypeConfigurations- OutputTypeConfiguration for the assignment to be savedrunId- 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(Map<OutputType,OutputTypeConfiguration> outputTypeConfigurations, OutputAdapter outputAdapter) throws PlanItException
Finalize the persistence after the simulation. Here we generate the XML meta-data file(s) *- Specified by:
finaliseAfterSimulationin interfaceOutputFormatter- Parameters:
outputTypeConfigurations- OutputTypeConfigurations for 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
-
setCsvNameRoot
public void setCsvNameRoot(String csvNameRoot)
Sets the root name of the CSV output file- Specified by:
setCsvNameRootin 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:
setCsvNameExtensionin interfaceCsvTextFileOutputFormatter- Parameters:
csvNameExtension- the extension of the CSV output file
-
setDescription
public void setDescription(String description)
Allows the developer to set the output description property- Parameters:
description- description to be included
-
getDescription
public String getDescription()
Collect the description property- Returns:
- description
-
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
-
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
-
-