Class DefinitionsParser


  • public final class DefinitionsParser
    extends Object
    DefinitionParser parses the XML nodes of the DEFINITIONS tag: GTUTYPE, GTUTEMPLATE, LINKTYPE, LANETYPE and ROADLAYOUT.

    Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. BSD-style license. See OpenTrafficSim License.

    Author:
    Alexander Verbraeck
    • Method Detail

      • parseDefinitions

        public static void parseDefinitions​(OTSRoadNetwork otsNetwork,
                                            DEFINITIONS definitions,
                                            boolean overwriteDefaults,
                                            Map<String,​ROADLAYOUT> roadLayoutMap,
                                            Map<String,​GTUTEMPLATE> gtuTemplates,
                                            Map<String,​StreamInformation> streamMap,
                                            Map<LinkType,​Map<GTUType,​Speed>> linkTypeSpeedLimitMap)
                                     throws XmlParserException
        Parse the DEFINITIONS tag in the OTS XML file.
        Parameters:
        otsNetwork - OTSRoadNetwork; the network
        definitions - DEFINITIONS; the DEFINTIONS tag
        overwriteDefaults - boolean; overwrite default definitions in otsNetwork or not
        roadLayoutMap - Map<String,ROADLAYOUT>; temporary storage for the road layouts
        gtuTemplates - Map<String,GTUTEMPLATE>; map of GTU templates for the OD and/or Generators
        streamMap - Map<String,StreamInformation>; map with stream information
        linkTypeSpeedLimitMap - Map<LinkType,Map<GTUType,Speed>>; map with speed limit information per link type
        Throws:
        XmlParserException - on parsing error
      • parseGtuTypes

        public static void parseGtuTypes​(DEFINITIONS definitions,
                                         OTSRoadNetwork otsNetwork,
                                         boolean overwriteDefaults)
                                  throws XmlParserException
        Parse the GTUTYPES tag in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        overwriteDefaults - boolean; overwrite default definitions in otsNetwork or not
        Throws:
        XmlParserException - on parsing error
      • parseLinkTypes

        public static void parseLinkTypes​(DEFINITIONS definitions,
                                          OTSRoadNetwork otsNetwork,
                                          boolean overwriteDefaults,
                                          Map<LinkType,​Map<GTUType,​Speed>> linkTypeSpeedLimitMap)
                                   throws XmlParserException
        Parse the LINKTYPES tag in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        overwriteDefaults - boolean; overwrite default definitions in otsNetwork or not
        linkTypeSpeedLimitMap - Map<LinkType,Map<GTUType,Speed>>; map with speed limit information per link type
        Throws:
        XmlParserException - on parsing error
      • parseLaneTypes

        public static void parseLaneTypes​(DEFINITIONS definitions,
                                          OTSRoadNetwork otsNetwork,
                                          boolean overwriteDefaults)
                                   throws XmlParserException
        Parse the LANETYPES tag in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        overwriteDefaults - boolean; overwrite default definitions in otsNetwork or not
        Throws:
        XmlParserException - on parsing error
      • parseGtuTemplates

        public static void parseGtuTemplates​(DEFINITIONS definitions,
                                             OTSRoadNetwork otsNetwork,
                                             boolean overwriteDefaults,
                                             Map<String,​GTUTEMPLATE> gtuTemplates,
                                             Map<String,​StreamInformation> streamMap)
                                      throws XmlParserException
        Store the GTUTEMPLATE tags in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        overwriteDefaults - boolean; overwrite default definitions in otsNetwork or not
        gtuTemplates - Map<String,GTUTEMPLATE>; the templates to be used in the OD/Generators
        streamMap - Map<String,StreamInformation>; map with stream information
        Throws:
        XmlParserException - on parsing error
      • parseRoadLayouts

        public static void parseRoadLayouts​(DEFINITIONS definitions,
                                            OTSRoadNetwork otsNetwork,
                                            Map<String,​ROADLAYOUT> roadLayoutMap)
                                     throws XmlParserException
        Parse the ROADLAYOUTS tag in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        roadLayoutMap - Map<String,ROADLAYOUT>; temporary storage for the road layouts
        Throws:
        XmlParserException - on parsing error
      • parseParameterTypes

        public static void parseParameterTypes​(DEFINITIONS definitions,
                                               OTSRoadNetwork otsNetwork,
                                               Map<String,​ParameterType<?>> parameterMap)
                                        throws XmlParserException
        Parse the PARAMETERTYPE tags in the OTS XML file.
        Parameters:
        definitions - DEFINITIONS; the DEFINTIONS tag
        otsNetwork - OTSRoadNetwork; the network
        parameterMap - Map<String,ParameterType<?>>; map to store parameter type by id
        Throws:
        XmlParserException - if the field in a PARAMETERTYPE does not refer to a ParameterType<?>