View Javadoc
1   package org.opentrafficsim.road.network.factory.opendrive;
2   
3   import java.io.Serializable;
4   import java.util.NavigableMap;
5   import java.util.TreeMap;
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   * Parser for elevation profile.
14   * <p>
15   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * <p>
18   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
19   * initial version Jul 23, 2015 <br>
20   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   */
22  class ElevationProfileTag implements Serializable
23  {
24  
25      /** */
26      private static final long serialVersionUID = 20150723L;
27  
28      /** ElevationTags */
29      @SuppressWarnings("checkstyle:visibilitymodifier")
30      NavigableMap<Double, ElevationTag> elevationTags = new TreeMap<Double, ElevationTag>();
31  
32      /**
33       * Parse the attributes of the road tag. The sub-elements are parsed in separate classes.
34       * @param nodeList NodeList; the list of subnodes of the road node
35       * @param parser OpenDriveNetworkLaneParser; the parser with the lists of information
36       * @param roadTag RoadTag; the RoadTag to which this element belongs
37       * @throws SAXException when parsing of the tag fails
38       * @throws NetworkException when parsing of the tag fails
39       */
40      @SuppressWarnings("checkstyle:needbraces")
41      static void parseElevationProfile(final NodeList nodeList, final OpenDriveNetworkLaneParser parser, final RoadTag roadTag)
42              throws SAXException, NetworkException
43      {
44          ElevationProfileTag elevationProfileTag = new ElevationProfileTag();
45  
46          for (Node node0 : XMLParser.getNodes(nodeList, "elevationProfile"))
47              for (Node node : XMLParser.getNodes(node0.getChildNodes(), "elevation"))
48              {
49                  ElevationTag elevationTag = ElevationTag.parseElevation(node, parser);
50                  elevationProfileTag.elevationTags.put(elevationTag.s.si, elevationTag);
51              }
52          roadTag.elevationProfileTag = elevationProfileTag;
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public final String toString()
58      {
59          return "ElevationProfileTag [elevationTags=" + this.elevationTags + "]";
60      }
61  }