use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.
the class DirectTransferAnalyzer method buildGraph.
@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra, DataImportIssueStore issueStore) {
/* Initialize graph index which is needed by the nearby stop finder. */
graph.index = new GraphIndex(graph);
LOG.info("Analyzing transfers (this can be time consuming)...");
List<TransferInfo> directTransfersTooLong = new ArrayList<>();
List<TransferInfo> directTransfersNotFound = new ArrayList<>();
DirectGraphFinder nearbyStopFinderEuclidian = new DirectGraphFinder(graph);
StreetGraphFinder nearbyStopFinderStreets = new StreetGraphFinder(graph);
int stopsAnalyzed = 0;
for (TransitStopVertex originStopVertex : Iterables.filter(graph.getVertices(), TransitStopVertex.class)) {
if (++stopsAnalyzed % 1000 == 0) {
LOG.info("{} stops analyzed", stopsAnalyzed);
}
/* Find nearby stops by euclidean distance */
Coordinate c0 = originStopVertex.getCoordinate();
Map<Stop, StopAtDistance> stopsEuclidean = nearbyStopFinderEuclidian.findClosestStops(c0.y, c0.x, radiusMeters).stream().filter(t -> t.stop instanceof Stop).collect(Collectors.toMap(t -> (Stop) t.stop, t -> t));
/* Find nearby stops by street distance */
Map<Stop, StopAtDistance> stopsStreets = nearbyStopFinderStreets.findClosestStops(c0.y, c0.x, radiusMeters * RADIUS_MULTIPLIER).stream().filter(t -> t.stop instanceof Stop).collect(Collectors.toMap(t -> (Stop) t.stop, t -> t));
Stop originStop = originStopVertex.getStop();
/* Get stops found by both street and euclidean search */
List<Stop> stopsConnected = stopsEuclidean.keySet().stream().filter(t -> stopsStreets.keySet().contains(t) && t != originStop).collect(Collectors.toList());
/* Get stops found by euclidean search but not street search */
List<Stop> stopsUnconnected = stopsEuclidean.keySet().stream().filter(t -> !stopsStreets.keySet().contains(t) && t != originStop).collect(Collectors.toList());
for (Stop destStop : stopsConnected) {
StopAtDistance euclideanStop = stopsEuclidean.get(destStop);
StopAtDistance streetStop = stopsStreets.get(destStop);
TransferInfo transferInfo = new TransferInfo(originStop, destStop, euclideanStop.distance, streetStop.distance);
/* Log transfer where the street distance is too long compared to the euclidean distance */
if (transferInfo.ratio > MIN_RATIO_TO_LOG && transferInfo.streetDistance > MIN_STREET_DISTANCE_TO_LOG) {
directTransfersTooLong.add(transferInfo);
}
}
for (Stop destStop : stopsUnconnected) {
StopAtDistance euclideanStop = stopsEuclidean.get(destStop);
/* Log transfers that are found by euclidean search but not by street search */
directTransfersNotFound.add(new TransferInfo(originStop, destStop, euclideanStop.distance, -1));
}
}
/* Sort by street distance to euclidean distance ratio before adding to issues */
directTransfersTooLong.sort(Comparator.comparingDouble(t -> t.ratio));
Collections.reverse(directTransfersTooLong);
for (TransferInfo transferInfo : directTransfersTooLong) {
issueStore.add(new TransferRoutingDistanceTooLong(transferInfo.origin, transferInfo.destination, transferInfo.directDistance, transferInfo.streetDistance, transferInfo.ratio));
}
/* Sort by direct distance before adding to issues */
directTransfersNotFound.sort(Comparator.comparingDouble(t -> t.directDistance));
for (TransferInfo transferInfo : directTransfersNotFound) {
issueStore.add(new TransferCouldNotBeRouted(transferInfo.origin, transferInfo.destination, transferInfo.directDistance));
}
LOG.info("Done analyzing transfers. {} transfers could not be routed and {} transfers had a too long routing" + " distance.", directTransfersNotFound.size(), directTransfersTooLong.size());
}
use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.
the class TestGeometryAndBlockProcessor method setUp.
public void setUp() throws Exception {
graph = new Graph();
this.issueStore = new DataImportIssueStore(true);
context = contextBuilder(ConstantsForTests.FAKE_GTFS).withIssueStoreAndDeduplicator(graph).build();
feedId = context.getFeedId().getId();
GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(context);
factory.run(graph, issueStore);
graph.putService(CalendarServiceData.class, context.getCalendarServiceData());
String[] stops = { feedId + ":A", feedId + ":B", feedId + ":C", feedId + ":D", feedId + ":E", feedId + ":entrance_a", feedId + ":entrance_b" };
for (int i = 0; i < stops.length; ++i) {
TransitStopVertex stop = (TransitStopVertex) (graph.getVertex(stops[i]));
IntersectionVertex front = new IntersectionVertex(graph, "near_1_" + stop.getStop().getId(), stop.getX() + 0.0001, stop.getY() + 0.0001);
IntersectionVertex back = new IntersectionVertex(graph, "near_2_" + stop.getStop().getId(), stop.getX() - 0.0001, stop.getY() - 0.0001);
StreetEdge street1 = new StreetEdge(front, back, GeometryUtils.makeLineString(stop.getX() + 0.0001, stop.getY() + 0.0001, stop.getX() - 0.0001, stop.getY() - 0.0001), "street", 100, StreetTraversalPermission.ALL, false);
StreetEdge street2 = new StreetEdge(back, front, GeometryUtils.makeLineString(stop.getX() - 0.0001, stop.getY() - 0.0001, stop.getX() + 0.0001, stop.getY() + 0.0001), "street", 100, StreetTraversalPermission.ALL, true);
}
StreetLinkerModule ttsnm = new StreetLinkerModule();
// Linkers aren't run otherwise
graph.hasStreets = true;
graph.hasTransit = true;
ttsnm.buildGraph(graph, new HashMap<Class<?>, Object>());
}
use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.
the class NetexLoaderSmokeTest method smokeTestOfNetexLoadData.
/**
* This test load a very simple Netex data set and do assertions on it.
* For each type we assert some of the most important fields for one element
* and then check the expected number of that type. This is not a replacement
* for unit tests on mappers. Try to focus on relation between entities and Netex
* import integration.
*/
@Test
public void smokeTestOfNetexLoadData() {
// Given
NetexBundle netexBundle = ConstantsForTests.createMinimalNetexBundle();
// Run the check to make sure it does not throw an exception
netexBundle.checkInputs();
// When
OtpTransitServiceBuilder transitBuilder = netexBundle.loadBundle(new Deduplicator(), new DataImportIssueStore(false));
// Then - smoke test model
OtpTransitService otpModel = transitBuilder.build();
assertAgencies(otpModel.getAllAgencies());
assertMultiModalStations(otpModel.getAllMultiModalStations());
assertOperators(otpModel.getAllOperators());
assertStops(otpModel.getAllStops());
assertStations(otpModel.getAllStations());
assertTripPatterns(otpModel.getTripPatterns());
assertTrips(otpModel.getAllTrips());
assertServiceIds(otpModel.getAllServiceIds());
assertNoticeAssignments(otpModel.getNoticeAssignments());
// And then - smoke test service calendar
assetServiceCalendar(transitBuilder.buildCalendarServiceData());
}
use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.
the class SimpleStreetSplitterTest method buildSpy.
@Before
public void buildSpy() {
Graph graph = new Graph();
SimpleStreetSplitter simpleStreetSplitter = new SimpleStreetSplitter(graph, null, null, false, new DataImportIssueStore(false));
spySimpleStreetSplitter = spy(simpleStreetSplitter);
}
use of org.opentripplanner.graph_builder.DataImportIssueStore in project OpenTripPlanner by opentripplanner.
the class BikeParkUpdater method setup.
@Override
public void setup(Graph graph) {
// Creation of network linker library will not modify the graph
linker = new SimpleStreetSplitter(graph, new DataImportIssueStore(false));
// Adding a bike park station service needs a graph writer runnable
bikeService = graph.getService(BikeRentalStationService.class, true);
}
Aggregations