Skip to content

Commit

Permalink
Merge pull request #6165 from entur/rename_stop_model
Browse files Browse the repository at this point in the history
Rename StopModel to SiteRepository
  • Loading branch information
vpaturet authored Oct 22, 2024
2 parents 0ae34a8 + 029d96c commit 06d969d
Show file tree
Hide file tree
Showing 118 changed files with 529 additions and 495 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

public class AtlantaFareServiceTest implements PlanTestConstants {

Expand Down Expand Up @@ -262,20 +262,20 @@ private static Leg createLeg(String agencyId, String shortName, long startTimeMi
}

private static Itinerary createItinerary(String agencyId, String shortName, long startTimeMins) {
var stopModelBuilder = StopModel.of();
var siteRepositoryBuilder = SiteRepository.of();
Agency agency = Agency
.of(new FeedScopedId(FEED_ID, agencyId))
.withName(agencyId)
.withTimezone(ZoneIds.NEW_YORK.getId())
.build();

// Set up stops
RegularStop firstStop = stopModelBuilder
RegularStop firstStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(FEED_ID, "1"))
.withCoordinate(new WgsCoordinate(1, 1))
.withName(new NonLocalizedString("first stop"))
.build();
RegularStop lastStop = stopModelBuilder
RegularStop lastStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(FEED_ID, "2"))
.withCoordinate(new WgsCoordinate(1, 2))
.withName(new NonLocalizedString("last stop"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.FareZone;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.StopModelBuilder;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.SiteRepositoryBuilder;

public class FareModelForTest {

Expand All @@ -25,40 +25,40 @@ public class FareModelForTest {
.of(FeedScopedId.ofNullable("F2", "other-feed-zone"))
.build();

private static final StopModelBuilder STOP_MODEL_BUILDER = StopModel.of();
private static final SiteRepositoryBuilder SITE_REPOSITORY_BUILDER = SiteRepository.of();

static final RegularStop AIRPORT_STOP = STOP_MODEL_BUILDER
static final RegularStop AIRPORT_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("airport"))
.withCoordinate(new WgsCoordinate(1, 1))
.addFareZones(AIRPORT_ZONE)
.withName(I18NString.of("Airport"))
.build();

static final RegularStop CITY_CENTER_A_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_A_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-a"))
.withCoordinate(new WgsCoordinate(1, 2))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop A"))
.build();
static final RegularStop CITY_CENTER_B_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_B_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-b"))
.withCoordinate(new WgsCoordinate(1, 3))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop B"))
.build();
static final RegularStop CITY_CENTER_C_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_C_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-c"))
.withCoordinate(new WgsCoordinate(1, 4))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop C"))
.build();
static final RegularStop SUBURB_STOP = STOP_MODEL_BUILDER
static final RegularStop SUBURB_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("suburb"))
.withCoordinate(new WgsCoordinate(1, 4))
.withName(I18NString.of("Suburb"))
.build();

static final RegularStop OTHER_FEED_STOP = STOP_MODEL_BUILDER
static final RegularStop OTHER_FEED_STOP = SITE_REPOSITORY_BUILDER
.regularStop(FeedScopedId.ofNullable("F2", "other-feed-stop"))
.withCoordinate(new WgsCoordinate(1, 5))
.withName(I18NString.of("Other feed stop"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

public class OrcaFareServiceTest {

Expand Down Expand Up @@ -662,15 +662,15 @@ private static Itinerary createItinerary(
.withTimezone(ZoneIds.NEW_YORK.getId())
.build();

var stopModelBuilder = StopModel.of();
var siteRepositoryBuilder = SiteRepository.of();

// Set up stops
RegularStop firstStop = stopModelBuilder
RegularStop firstStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(agencyId, "1"))
.withCoordinate(new WgsCoordinate(1, 1))
.withName(new NonLocalizedString(firstStopName))
.build();
RegularStop lastStop = stopModelBuilder
RegularStop lastStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(agencyId, "2"))
.withCoordinate(new WgsCoordinate(1, 2))
.withName(new NonLocalizedString(lastStopName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

class AreaStopsToVerticesMapperTest {
Expand All @@ -33,13 +33,13 @@ class AreaStopsToVerticesMapperTest {
.areaStop("berlin")
.withGeometry(Polygons.BERLIN)
.build();
public static final StopModel STOP_MODEL = TEST_MODEL
.stopModelBuilder()
public static final SiteRepository SITE_REPOSITORY = TEST_MODEL
.siteRepositoryBuilder()
.withAreaStop(AreaStopsToVerticesMapperTest.BERLIN_AREA_STOP)
.build();

public static final TimetableRepository TRANSIT_MODEL = new TimetableRepository(
STOP_MODEL,
SITE_REPOSITORY,
new Deduplicator()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static void addGtfsToGraph(
.buildGraph();

timetableRepository.index();
graph.index(timetableRepository.getStopModel());
graph.index(timetableRepository.getSiteRepository());
}

private Itinerary getItinerary(GenericLocation from, GenericLocation to, int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

public final class FlexIntegrationTestData {
Expand Down Expand Up @@ -43,7 +43,7 @@ public static TestOtpModel cobbOsm() {
private static TestOtpModel buildFlexGraph(File file) {
var deduplicator = new Deduplicator();
var graph = new Graph(deduplicator);
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
GtfsBundle gtfsBundle = new GtfsBundle(file);
GtfsModule module = new GtfsModule(
List.of(gtfsBundle),
Expand All @@ -54,7 +54,7 @@ private static TestOtpModel buildFlexGraph(File file) {
OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, true));
module.buildGraph();
timetableRepository.index();
graph.index(timetableRepository.getStopModel());
graph.index(timetableRepository.getSiteRepository());
OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, false));
assertTrue(timetableRepository.hasFlexTrips());
return new TestOtpModel(graph, timetableRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.opentripplanner.model.StopTime;
import org.opentripplanner.model.impl.OtpTransitServiceBuilder;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

class FlexTripsMapperTest {

@Test
void defaultTimePenalty() {
var builder = new OtpTransitServiceBuilder(StopModel.of().build(), NOOP);
var builder = new OtpTransitServiceBuilder(SiteRepository.of().build(), NOOP);
var stopTimes = List.of(stopTime(0), stopTime(1));
builder.getStopTimesSortedByTrip().addAll(stopTimes);
var trips = FlexTripsMapper.createFlexTrips(builder, NOOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class LuceneIndexTest {

@BeforeAll
static void setup() {
var stopModel = TEST_MODEL.stopModelBuilder();
var siteRepository = TEST_MODEL.siteRepositoryBuilder();
List
.of(
ALEXANDERPLATZ_BUS,
Expand All @@ -122,11 +122,11 @@ static void setup() {
MERIDIAN_N2,
MERIDIAN_AVE
)
.forEach(stopModel::withRegularStop);
.forEach(siteRepository::withRegularStop);
List
.of(ALEXANDERPLATZ_STATION, BERLIN_HAUPTBAHNHOF_STATION, FIVE_POINTS_STATION)
.forEach(stopModel::withStation);
var timetableRepository = new TimetableRepository(stopModel.build(), new Deduplicator());
.forEach(siteRepository::withStation);
var timetableRepository = new TimetableRepository(siteRepository.build(), new Deduplicator());
timetableRepository.index();
var transitService = new DefaultTransitService(timetableRepository) {
private final Multimap<StopLocation, TransitMode> modes = ImmutableMultimap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

class StopClusterMapperTest {
Expand All @@ -22,12 +22,12 @@ class StopClusterMapperTest {
private static final RegularStop STOP_B = TEST_MODEL.stop("B").build();
private static final RegularStop STOP_C = TEST_MODEL.stop("C").build();
private static final List<RegularStop> STOPS = List.of(STOP_A, STOP_B, STOP_C);
private static final StopModel STOP_MODEL = TEST_MODEL
.stopModelBuilder()
private static final SiteRepository SITE_REPOSITORY = TEST_MODEL
.siteRepositoryBuilder()
.withRegularStops(STOPS)
.build();
private static final TimetableRepository TRANSIT_MODEL = new TimetableRepository(
STOP_MODEL,
SITE_REPOSITORY,
new Deduplicator()
);
private static final List<StopLocation> LOCATIONS = STOPS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class TestStopConsolidationModel {
.build();

static TimetableRepository buildTimetableRepository() {
var stopModelBuilder = testModel.stopModelBuilder();
List.of(STOP_A, STOP_B, STOP_C, STOP_D).forEach(stopModelBuilder::withRegularStop);
return new TimetableRepository(stopModelBuilder.build(), new Deduplicator());
var siteRepositoryBuilder = testModel.siteRepositoryBuilder();
List.of(STOP_A, STOP_B, STOP_C, STOP_D).forEach(siteRepositoryBuilder::withRegularStop);
return new TimetableRepository(siteRepositoryBuilder.build(), new Deduplicator());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

class AreaStopPropertyMapperTest {

private static final TimetableRepositoryForTest MODEL = new TimetableRepositoryForTest(
StopModel.of()
SiteRepository.of()
);
private static final AreaStop STOP = MODEL.areaStop("123").build();
private static final Route ROUTE_WITH_COLOR = TimetableRepositoryForTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.StopModelBuilder;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.opentripplanner.transit.service.TimetableRepository;

class AreaStopsLayerBuilderTest {
Expand Down Expand Up @@ -46,16 +46,16 @@ class AreaStopsLayerBuilderTest {
.layers()
.getFirst();

private final StopModelBuilder stopModelBuilder = StopModel.of();
private final SiteRepositoryBuilder siteRepositoryBuilder = SiteRepository.of();

private final AreaStop AREA_STOP = stopModelBuilder
private final AreaStop AREA_STOP = siteRepositoryBuilder
.areaStop(ID)
.withName(NAME)
.withGeometry(Polygons.BERLIN)
.build();

private final TimetableRepository timetableRepository = new TimetableRepository(
stopModelBuilder.withAreaStop(AREA_STOP).build(),
siteRepositoryBuilder.withAreaStop(AREA_STOP).build(),
new Deduplicator()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.site.Station;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

public class DigitransitStationPropertyMapperTest {

@Test
void map() {
var deduplicator = new Deduplicator();
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
timetableRepository.index();
var transitService = new TestTransitService(timetableRepository);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

public class RealtimeStopsLayerTest {
Expand All @@ -40,7 +40,7 @@ public void setUp() {
var name = I18NString.of("name");
var desc = I18NString.of("desc");
stop =
StopModel
SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(name)
Expand All @@ -49,7 +49,7 @@ public void setUp() {
.withTimeZone(ZoneIds.HELSINKI)
.build();
stop2 =
StopModel
SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(name)
Expand All @@ -62,7 +62,7 @@ public void setUp() {
@Test
void realtimeStopLayer() {
var deduplicator = new Deduplicator();
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
timetableRepository.initTimeZone(ZoneIds.HELSINKI);
timetableRepository.index();
var transitService = new DefaultTransitService(timetableRepository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.Station;
import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

public class StopsLayerTest {
Expand Down Expand Up @@ -47,7 +47,7 @@ public class StopsLayerTest {
.withCoordinate(WgsCoordinate.GREENWICH)
.withName(I18NString.of("A Station"))
.build();
private static final RegularStop STOP = StopModel
private static final RegularStop STOP = SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(NAME_TRANSLATIONS)
Expand All @@ -59,7 +59,7 @@ public class StopsLayerTest {
@Test
public void digitransitStopPropertyMapperTest() {
var deduplicator = new Deduplicator();
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
timetableRepository.index();
var transitService = new TestTransitService(timetableRepository);

Expand All @@ -81,7 +81,7 @@ public void digitransitStopPropertyMapperTest() {
@Test
public void digitransitStopPropertyMapperTranslationTest() {
var deduplicator = new Deduplicator();
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
timetableRepository.index();
var transitService = new DefaultTransitService(timetableRepository);

Expand Down
Loading

0 comments on commit 06d969d

Please sign in to comment.