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 RoadMarkTag 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 String type = null;
34
35
36 @SuppressWarnings("checkstyle:visibilitymodifier")
37 String weight = null;
38
39
40 @SuppressWarnings("checkstyle:visibilitymodifier")
41 String color = null;
42
43
44 @SuppressWarnings("checkstyle:visibilitymodifier")
45 Length width = null;
46
47
48 @SuppressWarnings("checkstyle:visibilitymodifier")
49 String laneChange = null;
50
51
52
53
54
55
56
57
58
59 @SuppressWarnings("checkstyle:needbraces")
60 static void parseRoadMark(final NodeList nodeList, final OpenDriveNetworkLaneParser parser, final LaneTag laneTag)
61 throws SAXException, NetworkException
62 {
63 int roadMarkCount = 0;
64 for (Node node : XMLParser.getNodes(nodeList, "roadMark"))
65 {
66
67 RoadMarkTag roadMarkTag = new RoadMarkTag();
68 NamedNodeMap attributes = node.getAttributes();
69
70 Node sOffst = attributes.getNamedItem("sOffst");
71 if (sOffst != null)
72 roadMarkTag.sOffst = new Length(Double.parseDouble(sOffst.getNodeValue().trim()), LengthUnit.METER);
73
74 Node type = attributes.getNamedItem("type");
75 if (type != null)
76 roadMarkTag.type = type.getNodeValue().trim();
77
78 Node weight = attributes.getNamedItem("weight");
79 if (weight != null)
80 roadMarkTag.weight = weight.getNodeValue().trim();
81
82 Node color = attributes.getNamedItem("color");
83 if (color != null)
84 roadMarkTag.color = color.getNodeValue().trim();
85
86 Node width = attributes.getNamedItem("width");
87 if (width != null)
88 roadMarkTag.width = new Length(Double.parseDouble(width.getNodeValue().trim()), LengthUnit.METER);
89
90 Node laneChange = attributes.getNamedItem("laneChange");
91 if (laneChange != null)
92 roadMarkTag.laneChange = laneChange.getNodeValue().trim();
93
94 laneTag.roadMarkTags.add(roadMarkCount, roadMarkTag);
95 roadMarkCount++;
96 }
97
98 }
99
100
101 @Override
102 public final String toString()
103 {
104 return "RoadMarkTag [sOffst=" + this.sOffst + ", type=" + this.type + ", weight=" + this.weight + ", color="
105 + this.color + ", width=" + this.width + ", laneChange=" + this.laneChange + "]";
106 }
107 }