Search in sources :

Example 1 with MultiModalStation

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

the class MultiModalStationMapper method map.

MultiModalStation map(StopPlace stopPlace, Collection<Station> childStations) {
    MultiModalStation multiModalStation = new MultiModalStation(idFactory.createId(stopPlace.getId()), childStations);
    if (stopPlace.getName() != null) {
        multiModalStation.setName(stopPlace.getName().getValue());
    } else {
        multiModalStation.setName("N/A");
    }
    WgsCoordinate coordinate = WgsCoordinateMapper.mapToDomain(stopPlace.getCentroid());
    if (coordinate == null) {
        LOG.warn("MultiModal station {} does not contain any coordinates.", multiModalStation.getId());
    } else {
        multiModalStation.setCoordinate(coordinate);
    }
    return multiModalStation;
}
Also used : WgsCoordinate(org.opentripplanner.model.WgsCoordinate) MultiModalStation(org.opentripplanner.model.MultiModalStation)

Example 2 with MultiModalStation

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

the class PlaceAtDistanceType method getStopPlaces.

private static Stream<PlaceAtDistance> getStopPlaces(PlaceAtDistance p, String multiModalMode, RoutingService routingService) {
    Station stopPlace = ((Stop) p.place).getParentStation();
    if (stopPlace == null) {
        return Stream.of();
    }
    List<PlaceAtDistance> res = new ArrayList<>();
    MultiModalStation multiModalStation = routingService.getMultiModalStationForStations().get(stopPlace);
    if ("child".equals(multiModalMode) || "all".equals(multiModalMode) || multiModalStation == null) {
        res.add(new PlaceAtDistance(new MonoOrMultiModalStation(stopPlace, multiModalStation), p.distance));
    }
    if (multiModalStation == null) {
        return res.stream();
    }
    if ("parent".equals(multiModalMode) || "all".equals(multiModalMode)) {
        res.add(new PlaceAtDistance(new MonoOrMultiModalStation(multiModalStation), p.distance));
    }
    return res.stream();
}
Also used : Station(org.opentripplanner.model.Station) MultiModalStation(org.opentripplanner.model.MultiModalStation) Stop(org.opentripplanner.model.Stop) PlaceAtDistance(org.opentripplanner.routing.graphfinder.PlaceAtDistance) ArrayList(java.util.ArrayList) MultiModalStation(org.opentripplanner.model.MultiModalStation)

Example 3 with MultiModalStation

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

the class MultiModalStationMapper method map.

MultiModalStation map(StopPlace stopPlace, Collection<Station> childStations) {
    MultiModalStation multiModalStation = new MultiModalStation(idFactory.createId(stopPlace.getId()), childStations);
    if (stopPlace.getName() != null) {
        multiModalStation.setName(stopPlace.getName().getValue());
    } else {
        multiModalStation.setName("N/A");
    }
    WgsCoordinate coordinate = WgsCoordinateMapper.mapToDomain(stopPlace.getCentroid());
    if (coordinate == null) {
        issueStore.add("MultiModalStationWithoutCoordinates", "MultiModal station {} does not contain any coordinates.", multiModalStation.getId());
    } else {
        multiModalStation.setCoordinate(coordinate);
    }
    return multiModalStation;
}
Also used : WgsCoordinate(org.opentripplanner.model.WgsCoordinate) MultiModalStation(org.opentripplanner.model.MultiModalStation)

Example 4 with MultiModalStation

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

the class NetexLoaderSmokeTest method assertMultiModalStations.

private void assertMultiModalStations(Collection<MultiModalStation> multiModalStations) {
    Map<FeedScopedId, MultiModalStation> map = multiModalStations.stream().collect(Collectors.toMap(MultiModalStation::getId, s -> s));
    MultiModalStation multiModalStation = map.get(fId("NSR:StopPlace:58243"));
    assertEquals("Bergkrystallen", multiModalStation.getName());
    assertEquals(59.866603, multiModalStation.getLat(), 0.000001);
    assertEquals(10.821614, multiModalStation.getLon(), 0.000001);
    assertEquals(3, multiModalStations.size());
}
Also used : 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) MultiModalStation(org.opentripplanner.model.MultiModalStation)

Example 5 with MultiModalStation

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

the class StopPlaceType method fetchStopPlaces.

public static Collection<MonoOrMultiModalStation> fetchStopPlaces(double minLat, double minLon, double maxLat, double maxLon, String authority, Boolean filterByInUse, String multiModalMode, DataFetchingEnvironment environment) {
    final RoutingService routingService = GqlUtil.getRoutingService(environment);
    Stream<Station> stations = routingService.getStopsByBoundingBox(minLat, minLon, maxLat, maxLon).stream().map(StopLocation::getParentStation).filter(Objects::nonNull).distinct();
    if (authority != null) {
        stations = stations.filter(s -> s.getId().getFeedId().equalsIgnoreCase(authority));
    }
    if (TRUE.equals(filterByInUse)) {
        stations = stations.filter(s -> isStopPlaceInUse(s, routingService));
    }
    // "child" - Only mono modal children stop places, not their multi modal parent stop
    if ("child".equals(multiModalMode)) {
        return stations.map(s -> {
            MultiModalStation parent = routingService.getMultiModalStationForStations().get(s);
            return new MonoOrMultiModalStation(s, parent);
        }).collect(Collectors.toList());
    } else // "all" - Both multiModal parents and their mono modal child stop places
    if ("all".equals(multiModalMode)) {
        Set<MonoOrMultiModalStation> result = new HashSet<>();
        stations.forEach(it -> {
            MultiModalStation p = routingService.getMultiModalStationForStations().get(it);
            result.add(new MonoOrMultiModalStation(it, p));
            if (p != null) {
                result.add(new MonoOrMultiModalStation(p));
            }
        });
        return result;
    } else // mono modal stop places if they have no parent stop place
    if ("parent".equals(multiModalMode)) {
        Set<MonoOrMultiModalStation> result = new HashSet<>();
        stations.forEach(it -> {
            MultiModalStation p = routingService.getMultiModalStationForStations().get(it);
            if (p != null) {
                result.add(new MonoOrMultiModalStation(p));
            } else {
                result.add(new MonoOrMultiModalStation(it, null));
            }
        });
        return result;
    } else {
        throw new IllegalArgumentException("Unexpected multiModalMode: " + multiModalMode);
    }
}
Also used : MultiModalStation(org.opentripplanner.model.MultiModalStation) Station(org.opentripplanner.model.Station) DataFetchingEnvironment(graphql.schema.DataFetchingEnvironment) RoutingService(org.opentripplanner.routing.RoutingService) Trip(org.opentripplanner.model.Trip) MultiModalStation(org.opentripplanner.model.MultiModalStation) StopTimesInPattern(org.opentripplanner.model.StopTimesInPattern) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLInterfaceType(graphql.schema.GraphQLInterfaceType) TRANSPORT_MODE(org.opentripplanner.ext.transmodelapi.model.EnumTypes.TRANSPORT_MODE) HashSet(java.util.HashSet) Scalars(graphql.Scalars) TransitMode(org.opentripplanner.model.TransitMode) JourneyWhiteListed(org.opentripplanner.ext.transmodelapi.model.plan.JourneyWhiteListed) GraphQLObjectType(graphql.schema.GraphQLObjectType) FeedScopedId(org.opentripplanner.model.FeedScopedId) ArrivalDeparture(org.opentripplanner.routing.stoptimes.ArrivalDeparture) Station(org.opentripplanner.model.Station) TRANSPORT_SUBMODE(org.opentripplanner.ext.transmodelapi.model.EnumTypes.TRANSPORT_SUBMODE) EnumTypes(org.opentripplanner.ext.transmodelapi.model.EnumTypes) GqlUtil(org.opentripplanner.ext.transmodelapi.support.GqlUtil) GraphQLNonNull(graphql.schema.GraphQLNonNull) Stop(org.opentripplanner.model.Stop) StopCollection(org.opentripplanner.model.StopCollection) Collection(java.util.Collection) Set(java.util.Set) GraphQLOutputType(graphql.schema.GraphQLOutputType) GraphQLArgument(graphql.schema.GraphQLArgument) TransmodelTransportSubmode(org.opentripplanner.ext.transmodelapi.model.TransmodelTransportSubmode) Collectors(java.util.stream.Collectors) StopLocation(org.opentripplanner.model.StopLocation) Objects(java.util.Objects) List(java.util.List) GraphQLList(graphql.schema.GraphQLList) Stream(java.util.stream.Stream) GraphQLTypeReference(graphql.schema.GraphQLTypeReference) TripTimeOnDate(org.opentripplanner.model.TripTimeOnDate) TRUE(java.lang.Boolean.TRUE) HashSet(java.util.HashSet) Set(java.util.Set) RoutingService(org.opentripplanner.routing.RoutingService) MultiModalStation(org.opentripplanner.model.MultiModalStation) StopLocation(org.opentripplanner.model.StopLocation) HashSet(java.util.HashSet)

Aggregations

MultiModalStation (org.opentripplanner.model.MultiModalStation)8 Station (org.opentripplanner.model.Station)6 Stop (org.opentripplanner.model.Stop)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 FeedScopedId (org.opentripplanner.model.FeedScopedId)3 Trip (org.opentripplanner.model.Trip)3 Multimap (com.google.common.collect.Multimap)2 Serializable (java.io.Serializable)2 Map (java.util.Map)2 Set (java.util.Set)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNull (org.junit.Assert.assertNull)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Assert.fail (org.junit.Assert.fail)2 Test (org.junit.Test)2 ConstantsForTests (org.opentripplanner.ConstantsForTests)2 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)2