Skip to content

Commit 7204b60

Browse files
Filter out flex zones from geocoder
Remove flex geocoder
1 parent 89eed00 commit 7204b60

2 files changed

Lines changed: 43 additions & 22 deletions

File tree

application/src/ext-test/java/org/opentripplanner/ext/geocoder/LuceneIndexTest.java

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.opentripplanner.ext.geocoder;
22

3+
import static com.google.common.truth.Truth.assertThat;
34
import 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;
56
import static org.opentripplanner.transit.model.basic.TransitMode.BUS;
67
import static org.opentripplanner.transit.model.basic.TransitMode.FERRY;
78

@@ -17,6 +18,7 @@
1718
import org.junit.jupiter.api.Test;
1819
import org.junit.jupiter.params.ParameterizedTest;
1920
import org.junit.jupiter.params.provider.ValueSource;
21+
import org.opentripplanner._support.geometry.Polygons;
2022
import org.opentripplanner.core.model.id.FeedScopedId;
2123
import org.opentripplanner.ext.stopconsolidation.internal.DefaultStopConsolidationRepository;
2224
import org.opentripplanner.ext.stopconsolidation.internal.DefaultStopConsolidationService;
@@ -25,6 +27,7 @@
2527
import org.opentripplanner.transit.model.basic.TransitMode;
2628
import org.opentripplanner.transit.model.network.Route;
2729
import org.opentripplanner.transit.model.organization.Agency;
30+
import org.opentripplanner.transit.model.site.AreaStop;
2831
import org.opentripplanner.transit.model.site.RegularStop;
2932
import org.opentripplanner.transit.model.site.Station;
3033
import 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();

application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.opentripplanner.street.geometry.WgsCoordinate;
5252
import org.opentripplanner.transit.model.site.StopLocation;
5353
import org.opentripplanner.transit.model.site.StopLocationsGroup;
54+
import org.opentripplanner.transit.model.site.StopType;
5455
import org.opentripplanner.transit.service.DefaultTransitService;
5556
import org.opentripplanner.transit.service.TimetableRepository;
5657
import org.opentripplanner.transit.service.TransitService;
@@ -116,6 +117,8 @@ public LuceneIndex(
116117
) {
117118
transitService
118119
.listStopLocations()
120+
.stream()
121+
.filter(stopLocation -> stopLocation.getStopType() == StopType.REGULAR)
119122
.forEach(stopLocation ->
120123
addToIndex(
121124
directoryWriter,
@@ -144,11 +147,13 @@ public LuceneIndex(
144147
)
145148
);
146149

150+
var regularStops = transitService
151+
.listStopLocations()
152+
.stream()
153+
.filter(stopLocation -> stopLocation.getStopType() == StopType.REGULAR)
154+
.toList();
147155
stopClusterMapper
148-
.generateStopClusters(
149-
transitService.listStopLocations(),
150-
transitService.listStopLocationGroups()
151-
)
156+
.generateStopClusters(regularStops, transitService.listStopLocationGroups())
152157
.forEach(stopCluster ->
153158
addToIndex(
154159
directoryWriter,

0 commit comments

Comments
 (0)