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;
}
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();
}
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;
}
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());
}
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);
}
}
Aggregations