1 package org.opentrafficsim.road.network.lane;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.List;
7 import java.util.Map;
8
9 import org.opentrafficsim.core.geometry.OTSLine3D;
10 import org.opentrafficsim.core.gtu.GTUType;
11 import org.opentrafficsim.core.network.LinkType;
12 import org.opentrafficsim.core.network.LongitudinalDirectionality;
13 import org.opentrafficsim.core.network.OTSLink;
14 import org.opentrafficsim.core.network.OTSNode;
15 import org.opentrafficsim.road.network.lane.changing.LaneKeepingPolicy;
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public class CrossSectionLink extends OTSLink implements Serializable
30 {
31
32 private static final long serialVersionUID = 20141015L;
33
34
35 private final List<CrossSectionElement> crossSectionElementList = new ArrayList<>();
36
37
38 private final LaneKeepingPolicy laneKeepingPolicy;
39
40
41
42
43
44
45
46
47
48
49
50 public CrossSectionLink(final String id, final OTSNode startNode, final OTSNode endNode, final LinkType linkType,
51 final OTSLine3D designLine, final Map<GTUType, LongitudinalDirectionality> directionalityMap,
52 final LaneKeepingPolicy laneKeepingPolicy)
53 {
54 super(id, startNode, endNode, linkType, designLine, directionalityMap);
55 this.laneKeepingPolicy = laneKeepingPolicy;
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69 public CrossSectionLink(final String id, final OTSNode startNode, final OTSNode endNode, final LinkType linkType,
70 final OTSLine3D designLine, final LongitudinalDirectionality directionality,
71 final LaneKeepingPolicy laneKeepingPolicy)
72 {
73 super(id, startNode, endNode, linkType, designLine, directionality);
74 this.laneKeepingPolicy = laneKeepingPolicy;
75 }
76
77
78
79
80
81
82
83
84
85
86
87 public CrossSectionLink(final String id, final OTSNode startNode, final OTSNode endNode, final LinkType linkType,
88 final OTSLine3D designLine, final LaneKeepingPolicy laneKeepingPolicy)
89 {
90 this(id, startNode, endNode, linkType, designLine, new HashMap<GTUType, LongitudinalDirectionality>(),
91 laneKeepingPolicy);
92 }
93
94
95
96
97
98
99 protected final void addCrossSectionElement(final CrossSectionElement cse)
100 {
101 this.crossSectionElementList.add(cse);
102 }
103
104
105
106
107
108
109
110 protected final void addCrossSectionElement(final CrossSectionElement cse, final int index)
111 {
112 this.crossSectionElementList.add(index, cse);
113 }
114
115
116
117
118 public final List<CrossSectionElement> getCrossSectionElementList()
119 {
120 return this.crossSectionElementList;
121 }
122
123
124
125
126 public final LaneKeepingPolicy getLaneKeepingPolicy()
127 {
128 return this.laneKeepingPolicy;
129 }
130
131
132
133
134
135 public final CrossSectionElement getCrossSectionElement(final String id)
136 {
137 for (CrossSectionElement cse : this.crossSectionElementList)
138 {
139 if (cse.getId().equals(id))
140 {
141 return cse;
142 }
143 }
144 return null;
145 }
146 }