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.xml.sax.SAXException;
11
12
13
14
15
16
17
18
19
20
21 class SignalTag implements Serializable
22 {
23
24 private static final long serialVersionUID = 20150723L;
25
26
27 @SuppressWarnings("checkstyle:visibilitymodifier")
28 Length s = null;
29
30
31 @SuppressWarnings("checkstyle:visibilitymodifier")
32 Length t = null;
33
34
35 @SuppressWarnings("checkstyle:visibilitymodifier")
36 String id = null;
37
38
39 @SuppressWarnings("checkstyle:visibilitymodifier")
40 String name = null;
41
42
43 @SuppressWarnings("checkstyle:visibilitymodifier")
44 String dynamic = null;
45
46
47 @SuppressWarnings("checkstyle:visibilitymodifier")
48 String orientation = null;
49
50
51 @SuppressWarnings("checkstyle:visibilitymodifier")
52 Length zOffset = null;
53
54
55 @SuppressWarnings("checkstyle:visibilitymodifier")
56 String country = null;
57
58
59 @SuppressWarnings("checkstyle:visibilitymodifier")
60 String type = null;
61
62
63 @SuppressWarnings("checkstyle:visibilitymodifier")
64 String subtype = null;
65
66
67 @SuppressWarnings("checkstyle:visibilitymodifier")
68 String value = null;
69
70
71
72
73
74
75
76
77
78 @SuppressWarnings("checkstyle:needbraces")
79 static SignalTag parseSignal(final Node node, final OpenDriveNetworkLaneParser parser) throws SAXException, NetworkException
80 {
81 SignalTag signalTag = new SignalTag();
82 NamedNodeMap attributes = node.getAttributes();
83
84 Node s = attributes.getNamedItem("s");
85 if (s != null)
86 signalTag.s = new Length(Double.parseDouble(s.getNodeValue().trim()), LengthUnit.METER);
87
88 Node t = attributes.getNamedItem("t");
89 if (t != null)
90 signalTag.t = new Length(Double.parseDouble(t.getNodeValue().trim()), LengthUnit.METER);
91
92 Node id = attributes.getNamedItem("id");
93 if (id != null)
94 signalTag.id = id.getNodeValue().trim();
95
96 Node name = attributes.getNamedItem("name");
97 if (name != null)
98 signalTag.name = name.getNodeValue().trim();
99
100 Node dynamic = attributes.getNamedItem("dynamic");
101 if (dynamic != null)
102 signalTag.dynamic = dynamic.getNodeValue().trim();
103
104 Node orientation = attributes.getNamedItem("orientation");
105 if (orientation != null)
106 signalTag.orientation = orientation.getNodeValue().trim();
107
108 Node zOffset = attributes.getNamedItem("zOffset");
109 if (zOffset != null)
110 signalTag.zOffset = new Length(Double.parseDouble(zOffset.getNodeValue().trim()), LengthUnit.METER);
111
112 Node country = attributes.getNamedItem("country");
113 if (country != null)
114 signalTag.country = country.getNodeValue().trim();
115
116 Node type = attributes.getNamedItem("type");
117 if (type != null)
118 signalTag.type = type.getNodeValue().trim();
119
120 Node subtype = attributes.getNamedItem("subtype");
121 if (subtype != null)
122 signalTag.subtype = subtype.getNodeValue().trim();
123
124 Node value = attributes.getNamedItem("value");
125 if (value != null)
126 signalTag.value = value.getNodeValue().trim();
127
128 return signalTag;
129
130 }
131
132
133 @Override
134 public final String toString()
135 {
136 return "SignalTag [s=" + this.s + ", t=" + this.t + ", id=" + this.id + ", name=" + this.name + ", dynamic="
137 + this.dynamic + ", orientation=" + this.orientation + ", zOffset=" + this.zOffset + ", country=" + this.country
138 + ", type=" + this.type + ", subtype=" + this.subtype + ", value=" + this.value + "]";
139 }
140 }