use of org.opentripplanner.routing.edgetype.TemporaryPartialStreetEdge in project OpenTripPlanner by opentripplanner.
the class RoutingContext method makePartialEdgeAlong.
/**
* Creates a PartialStreetEdge along the input StreetEdge iff its direction makes this possible.
*/
private void makePartialEdgeAlong(StreetEdge streetEdge, TemporaryStreetLocation from, TemporaryStreetLocation to) {
LineString parent = streetEdge.getGeometry();
LineString head = GeometryUtils.getInteriorSegment(parent, streetEdge.getFromVertex().getCoordinate(), from.getCoordinate());
LineString tail = GeometryUtils.getInteriorSegment(parent, to.getCoordinate(), streetEdge.getToVertex().getCoordinate());
if (parent.getLength() > head.getLength() + tail.getLength()) {
LineString partial = GeometryUtils.getInteriorSegment(parent, from.getCoordinate(), to.getCoordinate());
double lengthRatio = partial.getLength() / parent.getLength();
double length = streetEdge.getDistance() * lengthRatio;
// TODO: localize this
String name = from.getLabel() + " to " + to.getLabel();
new TemporaryPartialStreetEdge(streetEdge, from, to, partial, new NonLocalizedString(name), length);
}
}
Aggregations