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.xml.sax.SAXException;
11
12
13
14
15
16
17
18
19
20
21 class SuperElevationTag implements Serializable
22 {
23
24
25 private static final long serialVersionUID = 20150723L;
26
27
28 @SuppressWarnings("checkstyle:visibilitymodifier")
29 int id = 0;
30
31
32 @SuppressWarnings("checkstyle:visibilitymodifier")
33 Length s = null;
34
35
36 @SuppressWarnings("checkstyle:visibilitymodifier")
37 Length a = null;
38
39
40 @SuppressWarnings("checkstyle:visibilitymodifier")
41 Length b = null;
42
43
44 @SuppressWarnings("checkstyle:visibilitymodifier")
45 Length c = null;
46
47
48 @SuppressWarnings("checkstyle:visibilitymodifier")
49 Length d = null;
50
51
52
53
54
55
56
57
58
59 @SuppressWarnings("checkstyle:needbraces")
60 static SuperElevationTag parseSuperElevation(final Node node, final OpenDriveNetworkLaneParser parser)
61 throws SAXException, NetworkException
62 {
63 NamedNodeMap attributes = node.getAttributes();
64 SuperElevationTag elevationTag = new SuperElevationTag();
65
66 Node s = attributes.getNamedItem("s");
67 if (s == null)
68 throw new SAXException("Geometry: missing attribute s");
69 elevationTag.s = new Length(Double.parseDouble(s.getNodeValue().trim()), LengthUnit.METER);
70
71 Node a = attributes.getNamedItem("a");
72 if (a == null)
73 throw new SAXException("Geometry: missing attribute a");
74 elevationTag.a = new Length(Double.parseDouble(a.getNodeValue().trim()), LengthUnit.METER);
75
76 Node b = attributes.getNamedItem("b");
77 if (b == null)
78 throw new SAXException("Geometry: missing attribute b");
79 elevationTag.b = new Length(Double.parseDouble(b.getNodeValue().trim()), LengthUnit.METER);
80
81 Node c = attributes.getNamedItem("c");
82 if (c == null)
83 throw new SAXException("Geometry: missing attribute c");
84 elevationTag.c = new Length(Double.parseDouble(c.getNodeValue().trim()), LengthUnit.METER);
85
86 Node d = attributes.getNamedItem("d");
87 if (d == null)
88 throw new SAXException("Geometry: missing attribute d");
89 elevationTag.d = new Length(Double.parseDouble(d.getNodeValue().trim()), LengthUnit.METER);
90
91 return elevationTag;
92 }
93
94
95 @Override
96 public final String toString()
97 {
98 return "SuperElevationTag [id=" + this.id + ", s=" + this.s + ", a=" + this.a + ", b=" + this.b + ", c=" + this.c
99 + ", d=" + this.d + "]";
100 }
101 }