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.opentrafficsim.core.network.NetworkException;
8 import org.w3c.dom.NamedNodeMap;
9 import org.w3c.dom.Node;
10 import org.w3c.dom.NodeList;
11 import org.xml.sax.SAXException;
12
13
14
15
16
17
18
19
20
21
22 class WidthTag implements Serializable
23 {
24
25 private static final long serialVersionUID = 20150723L;
26
27
28 @SuppressWarnings("checkstyle:visibilitymodifier")
29 Length sOffst = null;
30
31
32 @SuppressWarnings("checkstyle:visibilitymodifier")
33 Length a = null;
34
35
36 @SuppressWarnings("checkstyle:visibilitymodifier")
37 Length b = null;
38
39
40 @SuppressWarnings("checkstyle:visibilitymodifier")
41 Length c = null;
42
43
44 @SuppressWarnings("checkstyle:visibilitymodifier")
45 Length d = null;
46
47
48
49
50
51
52
53
54
55 @SuppressWarnings("checkstyle:needbraces")
56 static void parseWidth(final NodeList nodeList, final OpenDriveNetworkLaneParser parser, final LaneTag laneTag)
57 throws SAXException, NetworkException
58 {
59 int widthCount = 0;
60 for (Node node : XMLParser.getNodes(nodeList, "width"))
61 {
62 widthCount++;
63 WidthTag widthTag = new WidthTag();
64 NamedNodeMap attributes = node.getAttributes();
65
66 Node sOffst = attributes.getNamedItem("sOffset");
67 if (sOffst != null)
68 widthTag.sOffst = new Length(Double.parseDouble(sOffst.getNodeValue().trim()), LengthUnit.METER);
69
70 Node a = attributes.getNamedItem("a");
71 if (a != null)
72 widthTag.a = new Length(Double.parseDouble(a.getNodeValue().trim()), LengthUnit.METER);
73
74 Node b = attributes.getNamedItem("b");
75 if (b != null)
76 widthTag.b = new Length(Double.parseDouble(b.getNodeValue().trim()), LengthUnit.METER);
77
78 Node c = attributes.getNamedItem("c");
79 if (c != null)
80 widthTag.c = new Length(Double.parseDouble(c.getNodeValue().trim()), LengthUnit.METER);
81
82 Node d = attributes.getNamedItem("d");
83 if (d != null)
84 widthTag.d = new Length(Double.parseDouble(d.getNodeValue().trim()), LengthUnit.METER);
85
86 laneTag.widthTags.add(widthTag);
87 }
88
89
90
91 }
92
93
94 @Override
95 public final String toString()
96 {
97 return "WidthTag [sOffst=" + this.sOffst + ", a=" + this.a + ", b=" + this.b + ", c=" + this.c + ", d=" + this.d + "]";
98 }
99 }