Search in sources :

Example 1 with Station

use of org.opentripplanner.model.Station in project OpenTripPlanner by opentripplanner.

the class LegacyGraphQLNodeTypeResolver method getType.

@Override
public GraphQLObjectType getType(TypeResolutionEnvironment environment) {
    Object o = environment.getObject();
    GraphQLSchema schema = environment.getSchema();
    if (o instanceof Agency)
        return schema.getObjectType("Agency");
    if (o instanceof TransitAlert)
        return schema.getObjectType("Alert");
    if (o instanceof BikePark)
        return schema.getObjectType("BikePark");
    if (o instanceof BikeRentalStation)
        return schema.getObjectType("BikeRentalStation");
    // if (o instanceof Cluster) return schema.getObjectType("Cluster");
    if (o instanceof PatternAtStop)
        return schema.getObjectType("DepartureRow");
    if (o instanceof TripPattern)
        return schema.getObjectType("Pattern");
    if (o instanceof PlaceAtDistance)
        return schema.getObjectType("placeAtDistance");
    if (o instanceof Route)
        return schema.getObjectType("Route");
    if (o instanceof Stop)
        return schema.getObjectType("Stop");
    if (o instanceof Station)
        return schema.getObjectType("Stop");
    if (o instanceof TripTimeShort)
        return schema.getObjectType("Stoptime");
    if (o instanceof StopAtDistance)
        return schema.getObjectType("stopAtDistance");
    if (o instanceof FareRuleSet)
        return schema.getObjectType("TicketType");
    if (o instanceof Trip)
        return schema.getObjectType("Trip");
    return null;
}
Also used : TransitAlert(org.opentripplanner.routing.alertpatch.TransitAlert) Trip(org.opentripplanner.model.Trip) Agency(org.opentripplanner.model.Agency) Stop(org.opentripplanner.model.Stop) PatternAtStop(org.opentripplanner.routing.graphfinder.PatternAtStop) PlaceAtDistance(org.opentripplanner.routing.graphfinder.PlaceAtDistance) FareRuleSet(org.opentripplanner.routing.core.FareRuleSet) BikePark(org.opentripplanner.routing.bike_park.BikePark) GraphQLSchema(graphql.schema.GraphQLSchema) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) TripPattern(org.opentripplanner.model.TripPattern) Station(org.opentripplanner.model.Station) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) TripTimeShort(org.opentripplanner.model.TripTimeShort) PatternAtStop(org.opentripplanner.routing.graphfinder.PatternAtStop) StopAtDistance(org.opentripplanner.routing.graphfinder.StopAtDistance) Route(org.opentripplanner.model.Route)

Example 2 with Station

use of org.opentripplanner.model.Station in project OpenTripPlanner by opentripplanner.

the class StopAndStationMapper method mapStopPlaceAllVersionsToStation.

private Station mapStopPlaceAllVersionsToStation(List<StopPlace> stopPlaceAllVersions) {
    // Map the highest priority StopPlace version to station
    StopPlace selectedStopPlace = first(stopPlaceAllVersions);
    Station station = stationMapper.map(selectedStopPlace);
    if (selectedStopPlace.getParentSiteRef() != null) {
        resultStationByMultiModalStationRfs.put(selectedStopPlace.getParentSiteRef().getRef(), station);
    }
    resultStations.add(station);
    return station;
}
Also used : Station(org.opentripplanner.model.Station) StopPlace(org.rutebanken.netex.model.StopPlace)

Example 3 with Station

use of org.opentripplanner.model.Station in project OpenTripPlanner by opentripplanner.

the class StopAndStationMapper method mapParentAndChildStops.

/**
 * @param stopPlaces all stop places including multiple versions of each.
 */
void mapParentAndChildStops(final Collection<StopPlace> stopPlaces) {
    // Prioritize StopPlace versions. Highest priority first.
    // TODO OTP2 - This should pushed up into the ReadOnlyHierarchicalVersionMapById as part of
    // - Issue: Netex import resolve version for all entities , not just stops #2781
    List<StopPlace> stopPlaceAllVersions = sortStopPlacesByValidityAndVersionDesc(stopPlaces);
    Station station = mapStopPlaceAllVersionsToStation(stopPlaceAllVersions);
    List<FareZone> fareZones = mapTariffZones(stopPlaceAllVersions);
    // never versions of the StopPlace
    for (StopPlace stopPlace : stopPlaceAllVersions) {
        for (Quay quay : listOfQuays(stopPlace)) {
            addNewStopToParentIfNotPresent(quay, station, fareZones);
        }
    }
}
Also used : Station(org.opentripplanner.model.Station) StopPlace(org.rutebanken.netex.model.StopPlace) Quay(org.rutebanken.netex.model.Quay) FareZone(org.opentripplanner.model.FareZone)

Example 4 with Station

use of org.opentripplanner.model.Station in project OpenTripPlanner by opentripplanner.

the class NetexLoaderSmokeTest method assertStations.

private void assertStations(Collection<Station> stations) {
    Map<FeedScopedId, Station> map = stations.stream().collect(Collectors.toMap(Station::getId, s -> s));
    Station station = map.get(fId("NSR:StopPlace:5825"));
    assertEquals("Bergkrystallen T", station.getName());
    assertEquals(59.866297, station.getLat(), 0.000001);
    assertEquals(10.821484, station.getLon(), 0.000001);
    assertEquals(5, stations.size());
}
Also used : MultiModalStation(org.opentripplanner.model.MultiModalStation) Station(org.opentripplanner.model.Station) StopTimeKey(org.opentripplanner.model.StopTimeKey) Trip(org.opentripplanner.model.Trip) MultiModalStation(org.opentripplanner.model.MultiModalStation) Multimap(com.google.common.collect.Multimap) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) ArrayList(java.util.ArrayList) TransitEntity(org.opentripplanner.model.TransitEntity) Map(java.util.Map) ConstantsForTests(org.opentripplanner.ConstantsForTests) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Assert.fail(org.junit.Assert.fail) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) FeedScopedId(org.opentripplanner.model.FeedScopedId) Station(org.opentripplanner.model.Station) Operator(org.opentripplanner.model.Operator) TripPattern(org.opentripplanner.model.TripPattern) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Notice(org.opentripplanner.model.Notice) Agency(org.opentripplanner.model.Agency) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) OtpTransitService(org.opentripplanner.model.OtpTransitService) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) Assert.assertEquals(org.junit.Assert.assertEquals) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 5 with Station

use of org.opentripplanner.model.Station in project OpenTripPlanner by opentripplanner.

the class StopAndStationMapperTest method mapStopPlaceAndQuays.

@Test
public void mapStopPlaceAndQuays() {
    Collection<StopPlace> stopPlaces = new ArrayList<>();
    StopPlace stopPlaceNew = createStopPlace("NSR:StopPlace:1", "Oslo S", "2", 59.909584, 10.755165, VehicleModeEnumeration.TRAM);
    StopPlace stopPlaceOld = createStopPlace("NSR:StopPlace:1", "Oslo S", "1", 59.909584, 10.755165, VehicleModeEnumeration.TRAM);
    stopPlaces.add(stopPlaceNew);
    stopPlaces.add(stopPlaceOld);
    Quay quay1a = createQuay("NSR:Quay:1", "", "1", 59.909323, 10.756205, "a");
    Quay quay1b = createQuay("NSR:Quay:1", "", "2", 59.909911, 10.753008, "A");
    Quay quay2 = createQuay("NSR:Quay:2", "", "1", 59.909911, 10.753008, "B");
    Quay quay3 = createQuay("NSR:Quay:3", "", "1", 59.909911, 10.753008, "C");
    stopPlaceNew.setQuays(new Quays_RelStructure().withQuayRefOrQuay(quay1b).withQuayRefOrQuay(quay2));
    stopPlaceOld.setQuays(new Quays_RelStructure().withQuayRefOrQuay(quay1a).withQuayRefOrQuay(quay3));
    HierarchicalVersionMapById<Quay> quaysById = new HierarchicalVersionMapById<>();
    quaysById.add(quay1a);
    quaysById.add(quay1a);
    quaysById.add(quay2);
    quaysById.add(quay3);
    StopAndStationMapper stopMapper = new StopAndStationMapper(MappingSupport.ID_FACTORY, quaysById, null, new DataImportIssueStore(false));
    stopMapper.mapParentAndChildStops(stopPlaces);
    Collection<Stop> stops = stopMapper.resultStops;
    Collection<Station> stations = stopMapper.resultStations;
    assertEquals(3, stops.size());
    assertEquals(1, stations.size());
    Station parentStop = stations.stream().filter(s -> s.getId().getId().equals("NSR:StopPlace:1")).findFirst().get();
    Stop childStop1 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:1")).findFirst().get();
    Stop childStop2 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:2")).findFirst().get();
    Stop childStop3 = stops.stream().filter(s -> s.getId().getId().equals("NSR:Quay:3")).findFirst().get();
    assertEquals("NSR:StopPlace:1", parentStop.getId().getId());
    assertEquals("NSR:Quay:1", childStop1.getId().getId());
    assertEquals("NSR:Quay:2", childStop2.getId().getId());
    assertEquals("NSR:Quay:3", childStop3.getId().getId());
    assertEquals(59.909911, childStop1.getLat(), 0.0001);
    assertEquals(10.753008, childStop1.getLon(), 0.0001);
    assertEquals("A", childStop1.getCode());
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) HierarchicalVersionMapById(org.opentripplanner.netex.loader.util.HierarchicalVersionMapById) Stop(org.opentripplanner.model.Stop) ArrayList(java.util.ArrayList) Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) Station(org.opentripplanner.model.Station) Quay(org.rutebanken.netex.model.Quay) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Test(org.junit.Test)

Aggregations

Station (org.opentripplanner.model.Station)12 Stop (org.opentripplanner.model.Stop)9 FeedScopedId (org.opentripplanner.model.FeedScopedId)5 MultiModalStation (org.opentripplanner.model.MultiModalStation)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 TripTimeShort (org.opentripplanner.model.TripTimeShort)3 RoutingService (org.opentripplanner.routing.RoutingService)3 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)2 Stream (java.util.stream.Stream)2 Test (org.junit.Test)2 Agency (org.opentripplanner.model.Agency)2 BoardingArea (org.opentripplanner.model.BoardingArea)2 StopTimesInPattern (org.opentripplanner.model.StopTimesInPattern)2 Trip (org.opentripplanner.model.Trip)2 TripPattern (org.opentripplanner.model.TripPattern)2 StopPlace (org.rutebanken.netex.model.StopPlace)2