1 package org.opentrafficsim.road.gtu.strategical.route;
2
3 import java.io.Serializable;
4
5 import org.opentrafficsim.base.parameters.Parameters;
6 import org.opentrafficsim.core.gtu.GTUException;
7 import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterFactory;
8 import org.opentrafficsim.core.network.Node;
9 import org.opentrafficsim.core.network.route.Route;
10 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
11 import org.opentrafficsim.road.gtu.lane.tactical.LaneBasedTacticalPlanner;
12 import org.opentrafficsim.road.gtu.lane.tactical.LaneBasedTacticalPlannerFactory;
13 import org.opentrafficsim.road.gtu.strategical.AbstractLaneBasedStrategicalPlannerFactory;
14 import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlanner;
15
16
17
18
19
20
21
22
23
24
25
26
27 public class LaneBasedStrategicalRoutePlannerFactory
28 extends AbstractLaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> implements Serializable
29 {
30
31
32 private static final long serialVersionUID = 20160811L;
33
34
35 private final RouteSupplier routeSupplier;
36
37
38
39
40
41 public LaneBasedStrategicalRoutePlannerFactory(
42 final LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> tacticalPlannerFactory)
43 {
44 super(tacticalPlannerFactory);
45 this.routeSupplier = null;
46 }
47
48
49
50
51
52
53 public LaneBasedStrategicalRoutePlannerFactory(
54 final LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> tacticalPlannerFactory,
55 final RouteSupplier routeSupplier)
56 {
57 super(tacticalPlannerFactory);
58 this.routeSupplier = routeSupplier;
59 }
60
61
62
63
64
65
66 public LaneBasedStrategicalRoutePlannerFactory(
67 final LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> tacticalPlannerFactory,
68 final ParameterFactory parametersFactory)
69 {
70 super(tacticalPlannerFactory, parametersFactory);
71 this.routeSupplier = null;
72 }
73
74
75
76
77
78
79
80 public LaneBasedStrategicalRoutePlannerFactory(
81 final LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> tacticalPlannerFactory,
82 final ParameterFactory parametersFactory, final RouteSupplier routeSupplier)
83 {
84 super(tacticalPlannerFactory, parametersFactory);
85 this.routeSupplier = routeSupplier;
86 }
87
88
89 @Override
90 public final LaneBasedStrategicalPlanner create(final LaneBasedGTU gtu, final Route route, final Node origin,
91 final Node destination) throws GTUException
92 {
93 LaneBasedStrategicalRoutePlanner strategicalPlanner;
94 if (this.routeSupplier == null)
95 {
96 strategicalPlanner =
97 new LaneBasedStrategicalRoutePlanner(nextTacticalPlanner(gtu), route, gtu, origin, destination);
98 }
99 else
100 {
101 strategicalPlanner = new LaneBasedStrategicalRoutePlanner(nextTacticalPlanner(gtu), route, gtu, origin, destination,
102 this.routeSupplier);
103 }
104 gtu.setParameters(nextParameters(gtu.getGTUType()));
105 return strategicalPlanner;
106 }
107
108
109 @Override
110 protected Parameters getParameters()
111 {
112
113 return null;
114 }
115
116
117 @Override
118 public final String toString()
119 {
120 return "LaneBasedStrategicalRoutePlannerFactory [tacticalPlannerFactory=" + getTacticalPlannerFactory() + "]";
121 }
122
123 }