Class PlanItOutputFormatter

    • 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 class BaseOutputFormatter
        Parameters:
        outputConfiguration - output configuration
        outputTypeConfiguration - OutputTypeConfiguration for current persistence
        currentOutputType - active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)
        outputAdapter - OutputAdapter for current persistence
        modes - Set of modes of travel
        timePeriod - current time period
        iterationIndex - 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 class BaseOutputFormatter
        Parameters:
        outputConfiguration - output configuration
        outputTypeConfiguration - OutputTypeConfiguration for current persistence
        currentOutputType - active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)
        outputAdapter - OutputAdapter for current persistence
        modes - Set of modes of travel
        timePeriod - current time period
        iterationIndex - 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 class BaseOutputFormatter
        Parameters:
        outputConfiguration - output configuration
        outputTypeConfiguration - OutputTypeConfiguration for current persistence
        currentOutputType - active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)
        outputAdapter - OutputAdapter for current persistence
        modes - Set of modes of travel
        timePeriod - current time period
        iterationIndex - 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 class BaseOutputFormatter
        Parameters:
        outputConfiguration - output configuration
        outputTypeConfiguration - OutputTypeConfiguration for current persistence
        currentOutputType - active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)
        outputAdapter - OutputAdapter for current persistence
        modes - Set of modes of travel
        timePeriod - current time period
        iterationIndex - 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 class BaseOutputFormatter
        Parameters:
        outputConfiguration - output configuration
        outputTypeConfiguration - OutputTypeConfiguration for current persistence
        currentOutputType - active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)
        outputAdapter - OutputAdapter for current persistence
        modes - Set of modes of travel
        timePeriod - current time period
        iterationIndex - 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 interface OutputFormatter
        Parameters:
        outputConfiguration - OutputConfiguration of the assignment
        runId - 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 interface OutputFormatter
        Parameters:
        outputConfiguration - OutputTypeConfiguration of the assignment that have been activated
        outputAdapter - 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 interface XmlTextFileOutputFormatter
        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 interface CsvTextFileOutputFormatter
        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 interface XmlTextFileOutputFormatter
        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 interface XmlTextFileOutputFormatter
        Parameters:
        xmlNameRoot - root name of XML output file
      • setCsvNameExtension

        public void setCsvNameExtension​(String csvNameExtension)
        Sets the extension of the CSV output file
        Specified by:
        setCsvNameExtension in interface CsvTextFileOutputFormatter
        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 interface CsvTextFileOutputFormatter
        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:
        setCsvNameRoot in interface CsvTextFileOutputFormatter
        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:
        canHandleMultipleIterations in interface OutputFormatter
        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 interface XmlTextFileOutputFormatter
        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 interface XmlTextFileOutputFormatter
        Parameters:
        outputType - the specified output type
        xmlFileName - the name of the output file to be added for the specified output type