27
27
import org .opentripplanner .transit .model .network .TripPattern ;
28
28
import org .opentripplanner .transit .model .site .StopTransferPriority ;
29
29
import org .opentripplanner .transit .model .timetable .TripTimes ;
30
+ import org .opentripplanner .transit .service .DefaultTransitService ;
30
31
import org .opentripplanner .transit .service .StopModel ;
31
32
import org .opentripplanner .transit .service .TransitModel ;
33
+ import org .opentripplanner .transit .service .TransitService ;
32
34
import org .slf4j .Logger ;
33
35
import org .slf4j .LoggerFactory ;
34
36
@@ -47,10 +49,12 @@ public class TransitLayerMapper {
47
49
48
50
private static final Logger LOG = LoggerFactory .getLogger (TransitLayerMapper .class );
49
51
50
- private final TransitModel transitModel ;
52
+ private final TransitService transitService ;
53
+ private final StopModel stopModel ;
51
54
52
55
private TransitLayerMapper (TransitModel transitModel ) {
53
- this .transitModel = transitModel ;
56
+ this .transitService = new DefaultTransitService (transitModel );
57
+ this .stopModel = transitModel .getStopModel ();
54
58
}
55
59
56
60
public static TransitLayer map (
@@ -74,20 +78,19 @@ private TransitLayer map(TransitTuningParameters tuningParameters) {
74
78
HashMap <LocalDate , List <TripPatternForDate >> tripPatternsByStopByDate ;
75
79
List <List <Transfer >> transferByStopIndex ;
76
80
ConstrainedTransfersForPatterns constrainedTransfers = null ;
77
- StopModel stopModel = transitModel .getStopModel ();
78
81
79
82
LOG .info ("Mapping transitLayer from TransitModel..." );
80
83
81
- Collection <TripPattern > allTripPatterns = transitModel .getAllTripPatterns ();
84
+ Collection <TripPattern > allTripPatterns = transitService .getAllTripPatterns ();
82
85
83
86
tripPatternsByStopByDate = mapTripPatterns (allTripPatterns );
84
87
85
- transferByStopIndex = mapTransfers (stopModel , transitModel );
88
+ transferByStopIndex = mapTransfers (stopModel , transitService );
86
89
87
90
TransferIndexGenerator transferIndexGenerator = null ;
88
91
if (OTPFeature .TransferConstraints .isOn ()) {
89
92
transferIndexGenerator =
90
- new TransferIndexGenerator (transitModel .getTransferService ().listAll (), allTripPatterns );
93
+ new TransferIndexGenerator (transitService .getTransferService ().listAll (), allTripPatterns );
91
94
constrainedTransfers = transferIndexGenerator .generateTransfers ();
92
95
}
93
96
@@ -98,9 +101,9 @@ private TransitLayer map(TransitTuningParameters tuningParameters) {
98
101
return new TransitLayer (
99
102
tripPatternsByStopByDate ,
100
103
transferByStopIndex ,
101
- transitModel .getTransferService (),
104
+ transitService .getTransferService (),
102
105
stopModel ,
103
- transitModel .getTimeZone (),
106
+ transitService .getTimeZone (),
104
107
transferCache ,
105
108
constrainedTransfers ,
106
109
transferIndexGenerator ,
@@ -118,13 +121,10 @@ private HashMap<LocalDate, List<TripPatternForDate>> mapTripPatterns(
118
121
Collection <TripPattern > allTripPatterns
119
122
) {
120
123
TripPatternForDateMapper tripPatternForDateMapper = new TripPatternForDateMapper (
121
- transitModel . getTransitModelIndex () .getServiceCodesRunningForDate ()
124
+ transitService .getServiceCodesRunningForDate ()
122
125
);
123
126
124
- Set <LocalDate > allServiceDates = transitModel
125
- .getTransitModelIndex ()
126
- .getServiceCodesRunningForDate ()
127
- .keySet ();
127
+ Set <LocalDate > allServiceDates = transitService .getAllServiceCodes ();
128
128
129
129
List <TripPatternForDate > tripPatternForDates = Collections .synchronizedList (new ArrayList <>());
130
130
0 commit comments