use of org.opentripplanner.routing.vertextype.TemporarySplitterVertex in project OpenTripPlanner by opentripplanner.
the class SimpleStreetSplitter method split.
/**
* Split the street edge at the given fraction
*
* @param edge to be split
* @param ll fraction at which to split the edge
* @param temporarySplit if true this is temporary split at origin/destinations search and only temporary edges vertices are created
* @param endVertex if this is temporary edge this is true if this is end vertex otherwise it doesn't matter
* @return Splitter vertex with added new edges
*/
private SplitterVertex split(StreetEdge edge, LinearLocation ll, boolean temporarySplit, boolean endVertex) {
LineString geometry = edge.getGeometry();
// create the geometries
Coordinate splitPoint = ll.getCoordinate(geometry);
// every edge can be split exactly once, so this is a valid label
SplitterVertex v;
if (temporarySplit) {
v = new TemporarySplitterVertex(graph, "split from " + edge.getId(), splitPoint.x, splitPoint.y, edge, endVertex);
if (edge.isWheelchairAccessible()) {
((TemporarySplitterVertex) v).setWheelchairAccessible(true);
} else {
((TemporarySplitterVertex) v).setWheelchairAccessible(false);
}
} else {
v = new SplitterVertex(graph, "split from " + edge.getId(), splitPoint.x, splitPoint.y, edge);
}
// make the edges
// TODO this is using the StreetEdge implementation of split, which will discard elevation information
// on edges that have it
P2<StreetEdge> edges = edge.split(v, !temporarySplit);
if (destructiveSplitting) {
// update indices of new edges
idx.insert(edges.first.getGeometry(), edges.first);
idx.insert(edges.second.getGeometry(), edges.second);
// (no need to remove original edge, we filter it when it comes out of the index)
// remove original edge from the graph
edge.getToVertex().removeIncoming(edge);
edge.getFromVertex().removeOutgoing(edge);
}
return v;
}
Aggregations