11package org .opentripplanner .ext .geocoder ;
22
3+ import static com .google .common .truth .Truth .assertThat ;
34import static org .junit .jupiter .api .Assertions .assertEquals ;
4- import static org .opentripplanner .transit .model ._data .TimetableRepositoryForTest .id ;
5+ import static org .opentripplanner .transit .model ._data .FeedScopedIdForTestFactory .id ;
56import static org .opentripplanner .transit .model .basic .TransitMode .BUS ;
67import static org .opentripplanner .transit .model .basic .TransitMode .FERRY ;
78
1718import org .junit .jupiter .api .Test ;
1819import org .junit .jupiter .params .ParameterizedTest ;
1920import org .junit .jupiter .params .provider .ValueSource ;
21+ import org .opentripplanner ._support .geometry .Polygons ;
2022import org .opentripplanner .core .model .id .FeedScopedId ;
2123import org .opentripplanner .ext .stopconsolidation .internal .DefaultStopConsolidationRepository ;
2224import org .opentripplanner .ext .stopconsolidation .internal .DefaultStopConsolidationService ;
2527import org .opentripplanner .transit .model .basic .TransitMode ;
2628import org .opentripplanner .transit .model .network .Route ;
2729import org .opentripplanner .transit .model .organization .Agency ;
30+ import org .opentripplanner .transit .model .site .AreaStop ;
2831import org .opentripplanner .transit .model .site .RegularStop ;
2932import org .opentripplanner .transit .model .site .Station ;
3033import org .opentripplanner .transit .model .site .StopLocation ;
@@ -35,63 +38,70 @@ class LuceneIndexTest {
3538
3639 private static final TimetableRepositoryForTest TEST_MODEL = TimetableRepositoryForTest .of ();
3740
38- static final Agency BVG = Agency .of (id ("bvg" ))
41+ private static final Agency BVG = Agency .of (id ("bvg" ))
3942 .withName ("BVG" )
4043 .withTimezone ("Europe/Berlin" )
4144 .build ();
4245
4346 // Berlin
44- static final Station BERLIN_HAUPTBAHNHOF_STATION = TEST_MODEL .station ("Hauptbahnhof" )
47+ private static final Station BERLIN_HAUPTBAHNHOF_STATION = TEST_MODEL .station ("Hauptbahnhof" )
4548 .withCoordinate (52.52495 , 13.36952 )
4649 .build ();
47- static final Station ALEXANDERPLATZ_STATION = TEST_MODEL .station ("Alexanderplatz" )
50+ private static final Station ALEXANDERPLATZ_STATION = TEST_MODEL .station ("Alexanderplatz" )
4851 .withCoordinate (52.52277 , 13.41046 )
4952 .build ();
5053
51- static final RegularStop ALEXANDERPLATZ_BUS = TEST_MODEL .stop ("Alexanderplatz Bus" )
54+ private static final RegularStop ALEXANDERPLATZ_BUS = TEST_MODEL .stop ("Alexanderplatz Bus" )
5255 .withCoordinate (52.52277 , 13.41046 )
5356 .withVehicleType (BUS )
5457 .withParentStation (ALEXANDERPLATZ_STATION )
5558 .build ();
5659
57- static final RegularStop ALEXANDERPLATZ_RAIL = TEST_MODEL .stop ("Alexanderplatz S-Bahn" )
60+ private static final RegularStop ALEXANDERPLATZ_RAIL = TEST_MODEL .stop ("Alexanderplatz S-Bahn" )
5861 .withCoordinate (52.52157 , 13.41123 )
5962 .withVehicleType (TransitMode .RAIL )
6063 .withParentStation (ALEXANDERPLATZ_STATION )
6164 .build ();
62- static final RegularStop LICHTERFELDE_OST_1 = TEST_MODEL .stop ("Lichterfelde Ost" )
65+ private static final RegularStop LICHTERFELDE_OST_1 = TEST_MODEL .stop ("Lichterfelde Ost" )
6366 .withId (id ("lichterfelde-gleis-1" ))
6467 .withCoordinate (52.42986 , 13.32808 )
6568 .build ();
66- static final RegularStop LICHTERFELDE_OST_2 = TEST_MODEL .stop ("Lichterfelde Ost" )
69+ private static final RegularStop LICHTERFELDE_OST_2 = TEST_MODEL .stop ("Lichterfelde Ost" )
6770 .withId (id ("lichterfelde-gleis-2" ))
6871 .withCoordinate (52.42985 , 13.32807 )
6972 .build ();
70- static final RegularStop WESTHAFEN = TEST_MODEL .stop ("Westhafen" )
73+ private static final RegularStop WESTHAFEN = TEST_MODEL .stop ("Westhafen" )
7174 .withVehicleType (null )
7275 .withCoordinate (52.42985 , 13.32807 )
7376 .build ();
7477
7578 // Atlanta
76- static final Station FIVE_POINTS_STATION = TEST_MODEL .station ("Five Points" )
79+ private static final Station FIVE_POINTS_STATION = TEST_MODEL .station ("Five Points" )
7780 .withCoordinate (33.753899 , -84.39156 )
7881 .build ();
7982
80- static final RegularStop ARTS_CENTER = TEST_MODEL .stop ("Arts Center" )
83+ private static final RegularStop ARTS_CENTER = TEST_MODEL .stop ("Arts Center" )
8184 .withCode ("4456" )
8285 .withCoordinate (52.52277 , 13.41046 )
8386 .build ();
84- static final RegularStop ARTHUR = TEST_MODEL .stop ("Arthur Langford Jr Pl SW at 220" )
87+ private static final RegularStop ARTHUR = TEST_MODEL .stop ("Arthur Langford Jr Pl SW at 220" )
8588 .withCoordinate (52.52277 , 13.41046 )
8689 .build ();
8790
88- static final RegularStop MERIDIAN_AVE = TEST_MODEL .stop ("Meridian Ave N & N 148th St" ).build ();
89- static final RegularStop MERIDIAN_N1 = TEST_MODEL .stop ("Meridian N & Spencer" ).build ();
90- static final RegularStop MERIDIAN_N2 = TEST_MODEL .stop ("N 205th St & Meridian Ave N" ).build ();
91+ private static final RegularStop MERIDIAN_AVE = TEST_MODEL .stop (
92+ "Meridian Ave N & N 148th St"
93+ ).build ();
94+ private static final RegularStop MERIDIAN_N1 = TEST_MODEL .stop ("Meridian N & Spencer" ).build ();
95+ private static final RegularStop MERIDIAN_N2 = TEST_MODEL .stop (
96+ "N 205th St & Meridian Ave N"
97+ ).build ();
9198
92- static LuceneIndex index ;
99+ private static final String FLEX_ZONE_NAME = "CCCCC" ;
100+ private static final AreaStop FLEX_ZONE = TEST_MODEL .areaStop (FLEX_ZONE_NAME )
101+ .withGeometry (Polygons .BERLIN )
102+ .build ();
93103
94- static StopClusterMapper mapper ;
104+ private static LuceneIndex index ;
95105
96106 @ BeforeAll
97107 static void setup () {
@@ -108,6 +118,7 @@ static void setup() {
108118 MERIDIAN_N2 ,
109119 MERIDIAN_AVE
110120 ).forEach (siteRepository ::withRegularStop );
121+ siteRepository .withAreaStop (FLEX_ZONE );
111122 List .of (ALEXANDERPLATZ_STATION , BERLIN_HAUPTBAHNHOF_STATION , FIVE_POINTS_STATION ).forEach (
112123 siteRepository ::withStation
113124 );
@@ -161,7 +172,6 @@ public FeedInfo getFeedInfo(String feedId) {
161172 timetableRepository
162173 );
163174 index = new LuceneIndex (transitService , stopConsolidationService );
164- mapper = new StopClusterMapper (transitService , stopConsolidationService );
165175 }
166176
167177 @ Nested
@@ -257,6 +267,12 @@ void modes() {
257267 assertEquals (List .of (FERRY .name (), BUS .name ()), cluster .primary ().modes ());
258268 }
259269
270+ @ Test
271+ void skipFlexZones () {
272+ var result = index .queryStopClusters (FLEX_ZONE_NAME , null );
273+ assertThat (result ).isEmpty ();
274+ }
275+
260276 @ Test
261277 void agenciesAndFeedPublisher () {
262278 var cluster = index .queryStopClusters ("alexanderplatz" , null ).toList ().getFirst ();
0 commit comments