Search in sources :

Example 1 with TemporaryPartialStreetEdge

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);
    }
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) LineString(com.vividsolutions.jts.geom.LineString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) TemporaryPartialStreetEdge(org.opentripplanner.routing.edgetype.TemporaryPartialStreetEdge)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)1 TemporaryPartialStreetEdge (org.opentripplanner.routing.edgetype.TemporaryPartialStreetEdge)1 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)1