1 package org.opentrafficsim.road.network.factory.opendrive;
2
3 import java.io.Serializable;
4
5 import org.djunits.unit.LengthUnit;
6 import org.djunits.value.vdouble.scalar.Length;
7 import org.w3c.dom.NamedNodeMap;
8 import org.w3c.dom.Node;
9 import org.w3c.dom.NodeList;
10 import org.xml.sax.SAXException;
11
12
13
14
15
16
17
18
19
20
21 class SpiralTag implements Serializable
22 {
23
24 private static final long serialVersionUID = 20150723L;
25
26
27 @SuppressWarnings("checkstyle:visibilitymodifier")
28 Length curvStart = null;
29
30
31 @SuppressWarnings("checkstyle:visibilitymodifier")
32 Length curvEnd = null;
33
34
35
36
37
38
39
40
41 @SuppressWarnings("checkstyle:needbraces")
42 static void parseSpiral(final NodeList nodeList, final OpenDriveNetworkLaneParser parser, final GeometryTag geometryTag)
43 throws SAXException
44 {
45 int typeCount = 0;
46 for (Node node : XMLParser.getNodes(nodeList, "spiral"))
47 {
48 typeCount++;
49
50 SpiralTag spiralTag = new SpiralTag();
51 NamedNodeMap attributes = node.getAttributes();
52
53 Node curvStart = attributes.getNamedItem("curvStart");
54 if (curvStart != null)
55 spiralTag.curvStart = new Length(Double.parseDouble(curvStart.getNodeValue().trim()), LengthUnit.SI);
56
57 Node curvEnd = attributes.getNamedItem("curvEnd");
58 if (curvEnd != null)
59 spiralTag.curvEnd = new Length(Double.parseDouble(curvEnd.getNodeValue().trim()), LengthUnit.SI);
60
61 geometryTag.spiralTag = spiralTag;
62 }
63
64 if (typeCount > 1)
65 throw new SAXException("ROAD: more than one spiral tag!");
66 }
67
68
69 @Override
70 public final String toString()
71 {
72 return "SpiralTag [curvStart=" + this.curvStart + ", curvEnd=" + this.curvEnd + "]";
73 }
74 }