View Javadoc
1   package org.opentrafficsim.road.network.factory.opendrive;
2   
3   import java.io.Serializable;
4   import java.util.ArrayList;
5   import java.util.List;
6   
7   import org.opentrafficsim.core.network.NetworkException;
8   import org.w3c.dom.Node;
9   import org.w3c.dom.NodeList;
10  import org.xml.sax.SAXException;
11  
12  /**
13   * <p>
14   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * <p>
17   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
18   * initial version Jul 23, 2015 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   */
21  class LateralProfileTag implements Serializable
22  {
23  
24      /** */
25      private static final long serialVersionUID = 20150723L;
26  
27      /** GeometryTags */
28      @SuppressWarnings("checkstyle:visibilitymodifier")
29      List<SuperElevationTag> superElevationTags = new ArrayList<SuperElevationTag>();
30  
31      /**
32       * Parse the attributes of the road tag. The sub-elements are parsed in separate classes.
33       * @param nodeList NodeList; the list of subnodes of the road node
34       * @param parser OpenDriveNetworkLaneParser; the parser with the lists of information
35       * @param roadTag RoadTag; the RoadTag to which this element belongs
36       * @throws SAXException when parsing of the tag fails
37       * @throws NetworkException when parsing of the tag fails
38       */
39      @SuppressWarnings("checkstyle:needbraces")
40      static void parseElevationProfile(final NodeList nodeList, final OpenDriveNetworkLaneParser parser, final RoadTag roadTag)
41              throws SAXException, NetworkException
42      {
43          for (Node node0 : XMLParser.getNodes(nodeList, "lateralProfile"))
44          {
45              int superElevationCount = 0;
46              for (Node node : XMLParser.getNodes(node0.getChildNodes(), "superelevation"))
47              {
48                  LateralProfileTag lateralProfileTag = new LateralProfileTag();
49                  roadTag.lateralProfileTag = lateralProfileTag;
50  
51                  SuperElevationTag superElevationTag = SuperElevationTag.parseSuperElevation(node, parser);
52                  superElevationTag.id = superElevationCount;
53                  superElevationCount++;
54  
55                  lateralProfileTag.superElevationTags.add(superElevationTag);
56              }
57          }
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public final String toString()
63      {
64          return "LateralProfileTag [superElevationTags=" + this.superElevationTags + "]";
65      }
66  }