1 package org.opentrafficsim.road.network.factory.opendrive;
2
3 import java.io.Serializable;
4
5 import org.djunits.unit.AngleUnit;
6 import org.djunits.unit.LengthUnit;
7 import org.djunits.value.vdouble.scalar.Angle;
8 import org.djunits.value.vdouble.scalar.Length;
9 import org.opentrafficsim.core.network.NetworkException;
10 import org.w3c.dom.NamedNodeMap;
11 import org.w3c.dom.Node;
12 import org.xml.sax.SAXException;
13
14
15
16
17
18
19
20
21
22
23 class ObjectTag implements Serializable
24 {
25
26 private static final long serialVersionUID = 20150723L;
27
28
29 @SuppressWarnings("checkstyle:visibilitymodifier")
30 Length s = null;
31
32
33 @SuppressWarnings("checkstyle:visibilitymodifier")
34 Length t = null;
35
36
37 @SuppressWarnings("checkstyle:visibilitymodifier")
38 String id = null;
39
40
41 @SuppressWarnings("checkstyle:visibilitymodifier")
42 String name = null;
43
44
45 @SuppressWarnings("checkstyle:visibilitymodifier")
46 String orientation = null;
47
48
49 @SuppressWarnings("checkstyle:visibilitymodifier")
50 Length zOffset = null;
51
52
53 @SuppressWarnings("checkstyle:visibilitymodifier")
54 String type = null;
55
56
57 @SuppressWarnings("checkstyle:visibilitymodifier")
58 Length validLength = null;
59
60
61 @SuppressWarnings("checkstyle:visibilitymodifier")
62 Length length = null;
63
64
65 @SuppressWarnings("checkstyle:visibilitymodifier")
66 Length width = null;
67
68
69 @SuppressWarnings("checkstyle:visibilitymodifier")
70 Length height = null;
71
72
73 @SuppressWarnings("checkstyle:visibilitymodifier")
74 Angle hdg = null;
75
76
77 @SuppressWarnings("checkstyle:visibilitymodifier")
78 Angle pitch = null;
79
80
81 @SuppressWarnings("checkstyle:visibilitymodifier")
82 Angle roll = null;
83
84
85
86
87
88
89
90
91
92 @SuppressWarnings("checkstyle:needbraces")
93 static ObjectTag parseObject(final Node node, final OpenDriveNetworkLaneParser parser) throws SAXException, NetworkException
94 {
95 ObjectTag objectTag = new ObjectTag();
96 NamedNodeMap attributes = node.getAttributes();
97
98 Node s = attributes.getNamedItem("s");
99 if (s != null)
100 objectTag.s = new Length(Double.parseDouble(s.getNodeValue().trim()), LengthUnit.METER);
101
102 Node t = attributes.getNamedItem("t");
103 if (t != null)
104 objectTag.t = new Length(Double.parseDouble(t.getNodeValue().trim()), LengthUnit.METER);
105
106 Node id = attributes.getNamedItem("id");
107 if (id != null)
108 objectTag.id = id.getNodeValue().trim();
109
110 Node name = attributes.getNamedItem("name");
111 if (name != null)
112 objectTag.name = name.getNodeValue().trim();
113
114 Node orientation = attributes.getNamedItem("orientation");
115 if (orientation != null)
116 objectTag.orientation = orientation.getNodeValue().trim();
117
118 Node zOffset = attributes.getNamedItem("zOffset");
119 if (zOffset != null)
120 objectTag.zOffset = new Length(Double.parseDouble(zOffset.getNodeValue().trim()), LengthUnit.METER);
121
122 Node type = attributes.getNamedItem("type");
123 if (type != null)
124 objectTag.type = type.getNodeValue().trim();
125
126 Node validLength = attributes.getNamedItem("validLength");
127 if (validLength != null)
128 objectTag.validLength = new Length(Double.parseDouble(validLength.getNodeValue().trim()), LengthUnit.METER);
129
130 Node length = attributes.getNamedItem("length");
131 if (length != null)
132 objectTag.length = new Length(Double.parseDouble(length.getNodeValue().trim()), LengthUnit.METER);
133
134 Node width = attributes.getNamedItem("width");
135 if (width != null)
136 objectTag.width = new Length(Double.parseDouble(width.getNodeValue().trim()), LengthUnit.METER);
137
138 Node height = attributes.getNamedItem("height");
139 if (height != null)
140 objectTag.height = new Length(Double.parseDouble(height.getNodeValue().trim()), LengthUnit.METER);
141
142 Node hdg = attributes.getNamedItem("hdg");
143 if (hdg != null)
144 objectTag.hdg = new Angle(Double.parseDouble(hdg.getNodeValue().trim()), AngleUnit.RADIAN);
145
146 Node pitch = attributes.getNamedItem("pitch");
147 if (pitch != null)
148 objectTag.pitch = new Angle(Double.parseDouble(pitch.getNodeValue().trim()), AngleUnit.RADIAN);
149
150 Node roll = attributes.getNamedItem("roll");
151 if (roll != null)
152 objectTag.roll = new Angle(Double.parseDouble(roll.getNodeValue().trim()), AngleUnit.RADIAN);
153
154 return objectTag;
155
156 }
157
158
159 @Override
160 public final String toString()
161 {
162 return "ObjectTag [s=" + this.s + ", t=" + this.t + ", id=" + this.id + ", name=" + this.name + ", orientation="
163 + this.orientation + ", zOffset=" + this.zOffset + ", type=" + this.type + ", validLength=" + this.validLength
164 + ", length=" + this.length + ", width=" + this.width + ", height=" + this.height + ", hdg=" + this.hdg
165 + ", pitch=" + this.pitch + ", roll=" + this.roll + "]";
166 }
167 }