use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class OverlayGraph method addEdge.
public void addEdge(Edge e) {
Vertex fromv = e.getFromVertex();
Vertex tov = e.getToVertex();
addOutgoing(fromv, e);
addIncoming(tov, e);
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class GraphGeographicFilter method findHull.
public void findHull() {
LOG.info("finding hull of graph...");
LOG.debug("using only stops? {}", useOnlyStops);
if (bufferMeters < prototypeRoutingRequest.maxWalkDistance)
LOG.warn("geographic filter buffer is smaller than max walk distance, this will probably yield incorrect results.");
Graph graph = graphService.getRouter(prototypeRoutingRequest.routerId).graph;
List<Geometry> geometries = new ArrayList<Geometry>();
for (Vertex v : graph.getVertices()) {
if (useOnlyStops && !(v instanceof TransitStop))
continue;
Point pt = gf.createPoint(v.getCoordinate());
Geometry geom = crudeProjectedBuffer(pt, bufferMeters);
geometries.add(geom);
}
Geometry multiGeom = gf.buildGeometry(geometries);
LOG.info("unioning hull...");
hull = multiGeom.union();
LOG.trace("hull is {}", hull.toText());
// may lead to false rejections
// DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier();
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class GraphVisualizer method checkGraph.
protected void checkGraph() {
HashSet<Vertex> seenVertices = new HashSet<Vertex>();
Collection<Vertex> allVertices = getGraph().getVertices();
Vertex v = allVertices.iterator().next();
System.out.println("initial vertex: " + v);
Queue<Vertex> toExplore = new LinkedList<Vertex>();
toExplore.add(v);
seenVertices.add(v);
while (!toExplore.isEmpty()) {
Vertex src = toExplore.poll();
for (Edge e : src.getOutgoing()) {
Vertex tov = e.getToVertex();
if (!seenVertices.contains(tov)) {
seenVertices.add(tov);
toExplore.add(tov);
}
}
}
System.out.println("After investigation, visited " + seenVertices.size() + " of " + allVertices.size());
/* now, let's find an unvisited vertex */
for (Vertex u : allVertices) {
if (!seenVertices.contains(u)) {
System.out.println("unvisited vertex" + u);
break;
}
}
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class GraphVisualizer method verticesSelected.
public void verticesSelected(final List<Vertex> selected) {
// sort vertices by name
Collections.sort(selected, new Comparator<Vertex>() {
@Override
public int compare(Vertex arg0, Vertex arg1) {
return arg0.getLabel().compareTo(arg1.getLabel());
}
});
ListModel<DisplayVertex> data = new VertexList(selected);
nearbyVertices.setModel(data);
// pick out an intersection vertex and find the path
// if the spt is already available
Vertex target = null;
for (Vertex vv : selected) {
if (vv instanceof IntersectionVertex) {
target = vv;
break;
}
}
if (target != null && spt != null) {
List<GraphPath> paths = spt.getPaths(target, true);
showPathsInPanel(paths);
}
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class ShowGraph method buildSpatialIndex.
/*
* Iterate through all vertices and their (outgoing) edges. If they are of 'interesting' types,
* add them to the corresponding spatial index.
*/
public synchronized void buildSpatialIndex() {
vertexIndex = new STRtree();
edgeIndex = new STRtree();
Envelope env;
// int xminx, xmax, ymin, ymax;
for (Vertex v : graph.getVertices()) {
Coordinate c = v.getCoordinate();
env = new Envelope(c);
vertexIndex.insert(env, v);
for (Edge e : v.getOutgoing()) {
if (e.getGeometry() == null)
continue;
if (e instanceof PatternEdge || e instanceof StreetTransitLink || e instanceof StreetEdge || e instanceof PathwayEdge || e instanceof SimpleTransfer) {
env = e.getGeometry().getEnvelopeInternal();
edgeIndex.insert(env, e);
}
}
}
vertexIndex.build();
edgeIndex.build();
}
Aggregations