View Javadoc
1   package org.opentrafficsim.road.gtu.lane.perception.object;
2   
3   import java.util.Set;
4   
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.djutils.immutablecollections.ImmutableSet;
7   import org.opentrafficsim.core.gtu.GtuException;
8   import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
9   import org.opentrafficsim.road.network.lane.Lane;
10  import org.opentrafficsim.road.network.lane.object.BusStop;
11  
12  /**
13   * Perceived bus stop.
14   * <p>
15   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * </p>
18   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
20   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
21   */
22  public class PerceivedBusStop extends PerceivedLaneBasedObjectBase
23  {
24  
25      /** Relative lane. */
26      private final RelativeLane relativeLane;
27  
28      /** Lines. */
29      private final ImmutableSet<String> lines;
30  
31      /** Conflicts downstream of the bus stop. */
32      private final Set<String> conflictIds;
33  
34      /**
35       * Constructor.
36       * @param busStop bus stop
37       * @param distance distance
38       * @param relativeLane relative lane
39       * @param conflictIds conflicts downstream of the bus stop
40       * @param lane lane
41       * @throws GtuException when id is null, or parameters are inconsistent
42       */
43      public PerceivedBusStop(final BusStop busStop, final Length distance, final RelativeLane relativeLane,
44              final Set<String> conflictIds, final Lane lane) throws GtuException
45      {
46          super(busStop.getId(), ObjectType.BUSSTOP, Length.ZERO, Kinematics.staticAhead(distance), lane);
47          this.relativeLane = relativeLane;
48          this.lines = busStop.getLines();
49          this.conflictIds = conflictIds;
50      }
51  
52      /**
53       * Returns relative lane.
54       * @return relativeLane.
55       */
56      public final RelativeLane getRelativeLane()
57      {
58          return this.relativeLane;
59      }
60  
61      /**
62       * Returns lines.
63       * @return lines.
64       */
65      public final ImmutableSet<String> getLines()
66      {
67          return this.lines;
68      }
69  
70      /**
71       * Returns conflict ids.
72       * @return conflictIds.
73       */
74      public final Set<String> getConflictIds()
75      {
76          return this.conflictIds;
77      }
78  
79      @Override
80      public final String toString()
81      {
82          return "PerceivedBusStop [relativeLane=" + this.relativeLane + ", lines=" + this.lines + ", conflictIds="
83                  + this.conflictIds + "]";
84      }
85  
86  }