View Javadoc
1   package org.opentrafficsim.road.network.factory.xml.old;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.opentrafficsim.core.geometry.OTSPoint3D;
7   import org.opentrafficsim.core.network.NetworkException;
8   import org.opentrafficsim.core.network.factory.xml.units.Coordinates;
9   import org.opentrafficsim.core.network.factory.xml.units.LengthUnits;
10  import org.w3c.dom.NamedNodeMap;
11  import org.w3c.dom.Node;
12  import org.xml.sax.SAXException;
13  
14  /**
15   * <p>
16   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
18   * <p>
19   * $LastChangedDate: 2016-08-19 16:55:58 +0200 (Fri, 19 Aug 2016) $, @version $Revision: 2131 $, by $Author: averbraeck $,
20   * initial version Jul 24, 2015 <br>
21   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
22   */
23  class PolyLineTag implements Serializable
24  {
25      /** */
26      private static final long serialVersionUID = 20150724L;
27  
28      /** Length. */
29      @SuppressWarnings("checkstyle:visibilitymodifier")
30      Length length = null;
31  
32      /** Coordinates of this PolyLineTag. */
33      OTSPoint3D[] coordinates = null;
34  
35      /**
36       * Parse the LINK.POLYLINE tag.
37       * @param polyLine Node; the XML-node to parse
38       * @param parser XmlNetworkLaneParserOld; the parser with the lists of information
39       * @param linkTag LinkTag; the parent link tag
40       * @throws SAXException when parsing of the tag fails
41       * @throws NetworkException when parsing of the tag fails
42       */
43      @SuppressWarnings("checkstyle:needbraces")
44      static void parsePolyLine(final Node polyLine, final XmlNetworkLaneParserOld parser, final LinkTag linkTag)
45              throws SAXException, NetworkException
46      {
47          NamedNodeMap polyLineAttributes = polyLine.getAttributes();
48          linkTag.polyLineTag = new PolyLineTag();
49  
50          if (polyLineAttributes.getNamedItem("INTERMEDIATEPOINTS") != null)
51              linkTag.polyLineTag.coordinates =
52                      Coordinates.parseCoordinates(polyLineAttributes.getNamedItem("INTERMEDIATEPOINTS").getNodeValue());
53          if (polyLineAttributes.getNamedItem("LENGTH") != null)
54              linkTag.polyLineTag.length = LengthUnits.parseLength(polyLineAttributes.getNamedItem("LENGTH").getNodeValue());
55  
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      public final String toString()
61      {
62          return "PolyLineTag [length=" + this.length + "]";
63      }
64  }