1 package org.opentrafficsim.road.network.factory.opendrive;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.List;
6
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 LaneTag implements Serializable
22 {
23
24
25 private static final long serialVersionUID = 20150723L;
26
27
28 @SuppressWarnings("checkstyle:visibilitymodifier")
29 Integer id = null;
30
31
32 @SuppressWarnings("checkstyle:visibilitymodifier")
33 String type = null;
34
35
36 @SuppressWarnings("checkstyle:visibilitymodifier")
37 String level = null;
38
39
40 @SuppressWarnings("checkstyle:visibilitymodifier")
41 String successorId = null;
42
43
44 @SuppressWarnings("checkstyle:visibilitymodifier")
45 String predecessorId = null;
46
47
48 @SuppressWarnings("checkstyle:visibilitymodifier")
49 List<WidthTag> widthTags = new ArrayList<>();
50
51
52 @SuppressWarnings("checkstyle:visibilitymodifier")
53 List<RoadMarkTag> roadMarkTags = new ArrayList<>();
54
55
56 @SuppressWarnings("checkstyle:visibilitymodifier")
57 List<SpeedTag> speedTags = new ArrayList<>();
58
59
60 @SuppressWarnings("checkstyle:visibilitymodifier")
61 HeightTag heightTag = null;
62
63
64
65
66
67
68
69
70
71 @SuppressWarnings("checkstyle:needbraces")
72 static LaneTag parseLane(final Node node, final OpenDriveNetworkLaneParser parser) throws SAXException, NetworkException
73 {
74 NamedNodeMap attributes = node.getAttributes();
75 LaneTag laneTag = new LaneTag();
76
77 Node id = attributes.getNamedItem("id");
78 if (id == null)
79 throw new SAXException("LANE: missing attribute id");
80 laneTag.id = Integer.parseInt(id.getNodeValue().trim());
81
82 Node type = attributes.getNamedItem("type");
83 if (type == null)
84 throw new SAXException("LANE: missing attribute type");
85 laneTag.type = type.getNodeValue().trim();
86
87 Node level = attributes.getNamedItem("level");
88 if (level == null)
89 throw new SAXException("LANE: missing attribute level");
90 laneTag.level = level.getNodeValue().trim();
91
92 for (Node link : XMLParser.getNodes(node.getChildNodes(), "link"))
93 {
94 NamedNodeMap attributes1 = link.getAttributes();
95
96 for (Node successor : XMLParser.getNodes(link.getChildNodes(), "successor"))
97 {
98 NamedNodeMap attributes2 = successor.getAttributes();
99 Node successorId = attributes2.getNamedItem("id");
100 laneTag.successorId = successorId.getNodeValue().trim();
101 }
102
103 for (Node predecessor : XMLParser.getNodes(link.getChildNodes(), "predecessor"))
104 {
105 NamedNodeMap attributes2 = predecessor.getAttributes();
106 Node predecessorId = attributes2.getNamedItem("id");
107 laneTag.predecessorId = predecessorId.getNodeValue().trim();
108 }
109 }
110
111 WidthTag.parseWidth(node.getChildNodes(), parser, laneTag);
112 RoadMarkTag.parseRoadMark(node.getChildNodes(), parser, laneTag);
113 SpeedTag.parseSpeed(node.getChildNodes(), parser, laneTag);
114 HeightTag.parseHeight(node.getChildNodes(), parser, laneTag);
115
116 return laneTag;
117 }
118
119
120 @Override
121 public final String toString()
122 {
123 return "LaneTag [id=" + this.id + ", type=" + this.type + ", level=" + this.level + ", successorId=" + this.successorId
124 + ", predecessorId=" + this.predecessorId + ", widthTags=" + this.widthTags + ", roadMarkTags="
125 + this.roadMarkTags + ", speedTags=" + this.speedTags + ", heightTag=" + this.heightTag + "]";
126 }
127 }