View Javadoc
1   package org.opentrafficsim.road.network.factory.xml;
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-2017 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      OTSPoint3D[] coordinates = null;
33  
34      /**
35       * Parse the LINK.POLYLINE tag.
36       * @param polyLine the XML-node to parse
37       * @param parser the parser with the lists of information
38       * @param linkTag the parent link tag
39       * @throws SAXException when parsing of the tag fails
40       * @throws NetworkException when parsing of the tag fails
41       */
42      @SuppressWarnings("checkstyle:needbraces")
43      static void parsePolyLine(final Node polyLine, final XmlNetworkLaneParser parser, final LinkTag linkTag)
44              throws SAXException, NetworkException
45      {
46          NamedNodeMap polyLineAttributes = polyLine.getAttributes();
47          linkTag.polyLineTag = new PolyLineTag();
48  
49          if (polyLineAttributes.getNamedItem("INTERMEDIATEPOINTS") != null)
50              linkTag.polyLineTag.coordinates =
51                      Coordinates.parseCoordinates(polyLineAttributes.getNamedItem("INTERMEDIATEPOINTS").getNodeValue());
52          if (polyLineAttributes.getNamedItem("LENGTH") != null)
53              linkTag.polyLineTag.length = LengthUnits.parseLength(polyLineAttributes.getNamedItem("LENGTH").getNodeValue());
54  
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public final String toString()
60      {
61          return "PolyLineTag [length=" + this.length + "]";
62      }
63  }