Skip to content

Commit

Permalink
Inject transit model instead of transit service
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jun 20, 2024
1 parent 4bbe43e commit a714a53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.site.StopLocationsGroup;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.TransitModel;
import org.opentripplanner.transit.service.TransitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LuceneIndex implements Serializable {

private static final Logger LOG = LoggerFactory.getLogger(LuceneIndex.class);

private static final String TYPE = "type";
private static final String ID = "id";
private static final String SECONDARY_IDS = "secondary_ids";
Expand All @@ -70,7 +68,14 @@ public class LuceneIndex implements Serializable {
private final SuggestIndexSearcher searcher;
private final StopClusterMapper stopClusterMapper;

public LuceneIndex(
public LuceneIndex(TransitModel transitModel, StopConsolidationService stopConsolidationService) {
this(new DefaultTransitService(transitModel), stopConsolidationService);
}

/**
* This method is only visible for testing.
*/
LuceneIndex(
TransitService transitService,
@Nullable StopConsolidationService stopConsolidationService
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.opentripplanner.ext.geocoder.LuceneIndex;
import org.opentripplanner.ext.stopconsolidation.StopConsolidationService;
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.transit.service.TransitService;
import org.opentripplanner.transit.service.TransitModel;

/**
* This module builds the Lucene geocoder based on whether the feature flag is on or off.
Expand All @@ -19,11 +19,11 @@ public class GeocoderModule {
@Singleton
@Nullable
LuceneIndex luceneIndex(
TransitService service,
TransitModel transitModel,
@Nullable StopConsolidationService stopConsolidationService
) {
if (OTPFeature.SandboxAPIGeocoder.isOn()) {
return new LuceneIndex(service, stopConsolidationService);
return new LuceneIndex(transitModel, stopConsolidationService);
} else {
return null;
}
Expand Down

0 comments on commit a714a53

Please sign in to comment.