1 package org.opentrafficsim.road.network.factory.vissim;
2
3 import java.io.Serializable;
4
5 import org.djunits.value.vdouble.scalar.Direction;
6 import org.djunits.value.vdouble.scalar.Length;
7 import org.opentrafficsim.core.geometry.OTSPoint3D;
8 import org.opentrafficsim.core.network.NetworkException;
9 import org.opentrafficsim.core.network.factory.xml.units.AngleUnits;
10 import org.opentrafficsim.core.network.factory.xml.units.LengthUnits;
11 import org.w3c.dom.NamedNodeMap;
12 import org.w3c.dom.Node;
13 import org.xml.sax.SAXException;
14
15
16
17
18
19
20
21
22
23
24 class ArcTag implements Serializable
25 {
26
27 private static final long serialVersionUID = 20150724L;
28
29
30 @SuppressWarnings("checkstyle:visibilitymodifier")
31 Direction angle = null;
32
33
34 @SuppressWarnings("checkstyle:visibilitymodifier")
35 Length radius = null;
36
37
38 @SuppressWarnings("checkstyle:visibilitymodifier")
39 ArcDirection direction = null;
40
41
42 @SuppressWarnings("checkstyle:visibilitymodifier")
43 OTSPoint3D center;
44
45
46 @SuppressWarnings("checkstyle:visibilitymodifier")
47 double startAngle;
48
49
50 enum ArcDirection
51 {
52
53 LEFT,
54
55 RIGHT;
56 }
57
58
59
60
61
62
63
64
65
66 @SuppressWarnings("checkstyle:needbraces")
67 static void parseArc(final Node arcNode, final VissimNetworkLaneParser parser, final LinkTag linkTag)
68 throws SAXException, NetworkException
69 {
70 NamedNodeMap arcAttributes = arcNode.getAttributes();
71 linkTag.arcTag = new ArcTag();
72
73 Node radius = arcAttributes.getNamedItem("RADIUS");
74 if (radius == null)
75 {
76 throw new SAXException("ARC: missing attribute RADIUS");
77 }
78 linkTag.arcTag.radius = LengthUnits.parseLength(radius.getNodeValue());
79
80 Node angle = arcAttributes.getNamedItem("ANGLE");
81 if (angle == null)
82 {
83 throw new SAXException("ARC: missing attribute ANGLE");
84 }
85 linkTag.arcTag.angle = AngleUnits.parseDirection(angle.getNodeValue());
86
87 Node dirNode = arcAttributes.getNamedItem("DIRECTION");
88 if (dirNode == null)
89 {
90 throw new SAXException("ARC: missing attribute DIRECTION");
91 }
92 String dir = dirNode.getNodeValue().trim();
93 linkTag.arcTag.direction = (dir.equals("L") || dir.equals("LEFT") || dir.equals("COUNTERCLOCKWISE")) ? ArcDirection.LEFT
94 : ArcDirection.RIGHT;
95
96 }
97
98
99 @Override
100 public final String toString()
101 {
102 return "ArcTag [angle=" + this.angle + ", radius=" + this.radius + ", direction=" + this.direction + ", center="
103 + this.center + ", startAngle=" + this.startAngle + "]";
104 }
105 }