1 package org.opentrafficsim.road.network.factory.vissim;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.core.network.NetworkException;
6 import org.w3c.dom.NamedNodeMap;
7 import org.w3c.dom.Node;
8 import org.xml.sax.SAXException;
9
10
11
12
13
14
15
16
17
18
19 class SinkTag implements Serializable
20 {
21
22 private static final long serialVersionUID = 20150723L;
23
24
25 @SuppressWarnings("checkstyle:visibilitymodifier")
26 String positionStr = null;
27
28
29
30
31
32
33
34
35
36 @SuppressWarnings("checkstyle:needbraces")
37 static void parseSink(final Node node, final VissimNetworkLaneParser parser, final LinkTag linkTag)
38 throws SAXException, NetworkException
39 {
40 NamedNodeMap attributes = node.getAttributes();
41 SinkTag sinkTag = new SinkTag();
42
43 if (attributes.getNamedItem("LANE") == null)
44 {
45 throw new SAXException("SINK: missing attribute LANE" + " for link " + linkTag.name);
46 }
47 String laneName = attributes.getNamedItem("LANE").getNodeValue().trim();
48 if (linkTag.roadLayoutTag == null)
49 {
50 throw new NetworkException("SINK: LANE " + laneName + " no ROADTYPE for link " + linkTag.name);
51 }
52 CrossSectionElementTag cseTag = linkTag.roadLayoutTag.cseTags.get(laneName);
53 if (cseTag == null)
54 {
55 throw new NetworkException("SINK: LANE " + laneName + " not found in elements of link " + linkTag.name
56 + " - roadtype " + linkTag.roadLayoutTag.name);
57 }
58 if (cseTag.elementType != org.opentrafficsim.road.network.factory.vissim.CrossSectionElementTag.ElementType.LANE)
59 {
60 throw new NetworkException("SINK: LANE " + laneName + " not a real GTU lane for link " + linkTag.name
61 + " - roadtype " + linkTag.roadLayoutTag.name);
62 }
63 if (linkTag.generatorTags.containsKey(laneName))
64 {
65 throw new SAXException("SINK for LANE with NAME " + laneName + " defined twice");
66 }
67
68 Node position = attributes.getNamedItem("POSITION");
69 if (position == null)
70 {
71 throw new NetworkException("SINK: POSITION element not found in elements of link " + linkTag.name + " - roadtype "
72 + linkTag.roadLayoutTag.name);
73 }
74 sinkTag.positionStr = position.getNodeValue().trim();
75
76 linkTag.sinkTags.put(laneName, sinkTag);
77 }
78
79
80 @Override
81 public final String toString()
82 {
83 return "SinkTag [positionStr=" + this.positionStr + "]";
84 }
85 }