Class MatsimNetworkWriterSettings

  • All Implemented Interfaces:
    ConverterWriterSettings

    public class MatsimNetworkWriterSettings
    extends PlanitMatsimWriterSettings
    Settings for the MATSIM writer By default the MATSIM writer will activate all available predefined PLANit modes for writing. In case the user wants to include custom modes as well, then they must be added manually via the class' available functionality. In case the user wants to exclude certain modes that are available in the network that is provided, they must be removed manually here as well. The CRS used for the writer is based on the CRS defined in the settings, if this is not set, we utilise the CRS corresponding to the provided country, if no country is provided, it will retain the CRS of the network provided. If the network has no CRS an exception will be thrown
    Author:
    markr
    • Field Detail

      • DEFAULT_PLANIT2MATSIM_MODE_MAPPING

        protected static final Map<PredefinedModeType,​String> DEFAULT_PLANIT2MATSIM_MODE_MAPPING
        provides the default mapping from planit modes ((predefined) mode name) to MATSIM mode (string)
      • DEFAULT_ACTIVATED_MODES

        protected static final Set<PredefinedModeType> DEFAULT_ACTIVATED_MODES
        track the PLANit modes that we include in the network to write
      • planit2MatsimModeMapping

        protected final Map<PredefinedModeType,​String> planit2MatsimModeMapping
        provides the mapping from PLANit modes ((predefined) mode name) to MATSIM mode (string)
      • activatedPlanitModes

        protected final Set<PredefinedModeType> activatedPlanitModes
        track the PLANit modes that we include in the network to write
      • decimalFormat

        protected DecimalFormat decimalFormat
        number of decimals to use, default is Precision.DEFAULT_DECIMAL_FORMAT
      • generateDetailedLinkGeometryFile

        protected boolean generateDetailedLinkGeometryFile
        when set to true, a separate detailed geometry file is generated that provides the detailed geometry of each link it can be used in the VIA viewer to enhance the look of the network which otherwise only depicts the end and start node, default is false
      • DEFAULT_NETWORK_FILE_NAME

        public static final String DEFAULT_NETWORK_FILE_NAME
        default names used for MATSIM network file that is being generated
        See Also:
        Constant Field Values
      • DEFAULT_GENERATE_DETAILED_LINK_GEOMETRY

        public static final Boolean DEFAULT_GENERATE_DETAILED_LINK_GEOMETRY
        Default setting for generating detailed link geometry file is false
      • DEFAULT_PUBLIC_TRANSPORT_MODE

        public static final String DEFAULT_PUBLIC_TRANSPORT_MODE
        default mode for all public transport modes in Matsim is pt, so that is what we use for initial mapping
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_TRANSPORT_MODE

        public static final String DEFAULT_PRIVATE_TRANSPORT_MODE
        default mode for all private transport modes in Matsim is car, so that is what we use for initial mapping
        See Also:
        Constant Field Values
    • Constructor Detail

      • MatsimNetworkWriterSettings

        public MatsimNetworkWriterSettings​(String countryName)
        constructor
        Parameters:
        countryName - to use
      • MatsimNetworkWriterSettings

        public MatsimNetworkWriterSettings​(String outputDirectory,
                                           String countryName)
        constructor
        Parameters:
        outputDirectory - to use
        countryName - to use
      • MatsimNetworkWriterSettings

        public MatsimNetworkWriterSettings​(String outputDirectory,
                                           String outputFileName,
                                           String countryName)
        constructor
        Parameters:
        outputDirectory - to use
        outputFileName - to use
        countryName - to use
    • Method Detail

      • createDefaultPredefinedModeMappings

        protected static Map<PredefinedModeType,​String> createDefaultPredefinedModeMappings()
        Initialise the predefined PLANit modes to MATSIM mode mapping, based on the (predefined) mode names. MATSIM seems not to have any predefined modes, so any name can be given to them. We therefore apply the PLANit's name attribute as the id for the mapping to MATSIM mode
        Returns:
        default mode mapping based on predefined modes
      • getDefaultPredefinedModeMappings

        protected static String getDefaultPredefinedModeMappings​(PredefinedModeType modeType)
        Collect the default mapping from PLANit predefined mode to MATSim mode
        Parameters:
        modeType - to get MATSim default mapping for
        Returns:
        default mapping found
      • createDefaultActivatedPlanitModes

        protected static Set<PredefinedModeType> createDefaultActivatedPlanitModes()
        Create the default activate PLANit modes that the MATSIM write will include when writing the network (if they are available). By default all predefined PLANit modes that could be reasonably mapped to motorised private mode car (car) or public transport (pt) are activated.
        Returns:
        default activate PLANit modes (by name)
      • logSettings

        protected void logSettings​(MacroscopicNetwork macroscopicNetwork)
        Convenience method to log all the current settings
        Parameters:
        macroscopicNetwork - provided for reference
      • overwritePredefinedModeMapping

        public void overwritePredefinedModeMapping​(PredefinedModeType planitModeType,
                                                   String matsimMode)
        Overwrite a mapping from a predefined PLANit mode to a particular MATSim mode
        Parameters:
        planitModeType - PLANit mode
        matsimMode - the new MATSim mode string to use
      • deactivatedPredefinedMode

        public void deactivatedPredefinedMode​(PredefinedModeType planitModeType)
        Remove the provided predefined mode from the activated modes listed for inclusion in the MATSIM network (in mapped form)
        Parameters:
        planitModeType - to deactivate
      • activatePredefinedMode

        public void activatePredefinedMode​(PredefinedModeType planitModeType)
        Activate the provided predefined mode from the activated modes listed for inclusion in the MATSIM network (in mapped form). By default all PLANit modes are active, so this is only needed when a mode has been deactivated earlier
        Parameters:
        planitModeType - to activate
      • getDecimalFormat

        public DecimalFormat getDecimalFormat()
        Collect number of decimals used in writing coordinates
        Returns:
        number of decimals used
      • setDecimalFormat

        public void setDecimalFormat​(DecimalFormat decimalFormat)
        Set number of decimals used in writing coordinates
        Parameters:
        decimalFormat - format to use
      • setNtCategoryFunction

        public void setNtCategoryFunction​(Function<MacroscopicLinkSegment,​String> linkNtCategoryfunction)
        Allow the user to provide their own function on how to populate the nt_category field of a MATSIM link based on the link segment that is provided to it
        Parameters:
        linkNtCategoryfunction - to apply
      • setNtTypeFunction

        public void setNtTypeFunction​(Function<MacroscopicLinkSegment,​String> linkNtTypefunction)
        Allow the user to provide their own function on how to populate the nt_type field of a MATSIM link based on the link segment that is provided to it
        Parameters:
        linkNtTypefunction - to apply
      • setTypeFunction

        public void setTypeFunction​(Function<MacroscopicLinkSegment,​String> linkTypefunction)
        Allow the user to provide their own function on how to populate the type field of a MATSIM link based on the link segment that is provided to it
        Parameters:
        linkTypefunction - to apply
      • createPlanitModeToMatsimModeMapping

        public Map<Mode,​String> createPlanitModeToMatsimModeMapping​(MacroscopicNetworkLayerImpl networkLayer)
        Creating a mapping from actual PLANit modes in the network to the MATSIM mode mapping as per the configuration in this class instance
        Parameters:
        networkLayer - the networkLayer
        Returns:
        the mapped PLANit mode instances to MATSIM modes (string)
      • isGenerateDetailedLinkGeometryFile

        public boolean isGenerateDetailedLinkGeometryFile()
        Check if a detailed geometry file is generated
        Returns:
        true when active, false otherwise
      • setGenerateDetailedLinkGeometryFile

        public void setGenerateDetailedLinkGeometryFile​(boolean generateDetailedLinkGeometryFile)
        Set the choice for whether or not a detailed geometry file for each link is created. this geometry is extracted from the PLANit link geometry
        Parameters:
        generateDetailedLinkGeometryFile - flag indicating to generate geometry file or not
      • reset

        public void reset()
        reset settings after persisting