2
2
3
3
import com .google .common .collect .Iterables ;
4
4
import java .util .Collection ;
5
+ import java .util .List ;
5
6
import java .util .Optional ;
6
7
import org .opentripplanner .framework .collection .ListUtils ;
7
8
import org .opentripplanner .framework .geometry .WgsCoordinate ;
8
9
import org .opentripplanner .framework .i18n .I18NString ;
9
10
import org .opentripplanner .model .FeedInfo ;
11
+ import org .opentripplanner .transit .model .network .Route ;
10
12
import org .opentripplanner .transit .model .organization .Agency ;
11
13
import org .opentripplanner .transit .model .site .StopLocation ;
12
14
import org .opentripplanner .transit .model .site .StopLocationsGroup ;
@@ -59,8 +61,7 @@ Iterable<LuceneStopCluster> generateStopClusters(
59
61
60
62
LuceneStopCluster map (StopLocationsGroup g ) {
61
63
var modes = transitService .getModesOfStopLocationsGroup (g ).stream ().map (Enum ::name ).toList ();
62
- var agencies = transitService
63
- .getAgenciesForStopLocationsGroup (g )
64
+ var agencies = agenciesForStopLocationsGroup (g )
64
65
.stream ()
65
66
.map (s -> s .getId ().toString ())
66
67
.toList ();
@@ -75,11 +76,7 @@ LuceneStopCluster map(StopLocationsGroup g) {
75
76
}
76
77
77
78
Optional <LuceneStopCluster > map (StopLocation sl ) {
78
- var agencies = transitService
79
- .getAgenciesForStopLocation (sl )
80
- .stream ()
81
- .map (a -> a .getId ().toString ())
82
- .toList ();
79
+ var agencies = agenciesForStopLocation (sl ).stream ().map (a -> a .getId ().toString ()).toList ();
83
80
return Optional
84
81
.ofNullable (sl .getName ())
85
82
.map (name -> {
@@ -95,6 +92,19 @@ Optional<LuceneStopCluster> map(StopLocation sl) {
95
92
});
96
93
}
97
94
95
+ private List <Agency > agenciesForStopLocation (StopLocation stop ) {
96
+ return transitService .getRoutesForStop (stop ).stream ().map (Route ::getAgency ).distinct ().toList ();
97
+ }
98
+
99
+ private List <Agency > agenciesForStopLocationsGroup (StopLocationsGroup group ) {
100
+ return group
101
+ .getChildStops ()
102
+ .stream ()
103
+ .flatMap (sl -> agenciesForStopLocation (sl ).stream ())
104
+ .distinct ()
105
+ .toList ();
106
+ }
107
+
98
108
private static StopCluster .Coordinate toCoordinate (WgsCoordinate c ) {
99
109
return new StopCluster .Coordinate (c .latitude (), c .longitude ());
100
110
}
0 commit comments