Search in sources :

Example 1 with BogusShapeDistanceTraveled

use of org.opentripplanner.graph_builder.annotation.BogusShapeDistanceTraveled in project OpenTripPlanner by opentripplanner.

the class GTFSPatternHopFactory method getHopGeometryViaShapeDistTraveled.

private LineString getHopGeometryViaShapeDistTraveled(Graph graph, AgencyAndId shapeId, StopTime st0, StopTime st1) {
    double startDistance = st0.getShapeDistTraveled();
    double endDistance = st1.getShapeDistTraveled();
    ShapeSegmentKey key = new ShapeSegmentKey(shapeId, startDistance, endDistance);
    LineString geometry = _geometriesByShapeSegmentKey.get(key);
    if (geometry != null)
        return geometry;
    double[] distances = getDistanceForShapeId(shapeId);
    if (distances == null) {
        LOG.warn(graph.addBuilderAnnotation(new BogusShapeGeometry(shapeId)));
        return null;
    } else {
        LinearLocation startIndex = getSegmentFraction(distances, startDistance);
        LinearLocation endIndex = getSegmentFraction(distances, endDistance);
        if (equals(startIndex, endIndex)) {
            // bogus shape_dist_traveled
            graph.addBuilderAnnotation(new BogusShapeDistanceTraveled(st1));
            return createSimpleGeometry(st0.getStop(), st1.getStop());
        }
        LineString line = getLineStringForShapeId(shapeId);
        LocationIndexedLine lol = new LocationIndexedLine(line);
        geometry = getSegmentGeometry(graph, shapeId, lol, startIndex, endIndex, startDistance, endDistance, st0, st1);
        return geometry;
    }
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) BogusShapeGeometry(org.opentripplanner.graph_builder.annotation.BogusShapeGeometry) LinearLocation(com.vividsolutions.jts.linearref.LinearLocation) LocationIndexedLine(com.vividsolutions.jts.linearref.LocationIndexedLine) BogusShapeDistanceTraveled(org.opentripplanner.graph_builder.annotation.BogusShapeDistanceTraveled)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)1 LinearLocation (com.vividsolutions.jts.linearref.LinearLocation)1 LocationIndexedLine (com.vividsolutions.jts.linearref.LocationIndexedLine)1 BogusShapeDistanceTraveled (org.opentripplanner.graph_builder.annotation.BogusShapeDistanceTraveled)1 BogusShapeGeometry (org.opentripplanner.graph_builder.annotation.BogusShapeGeometry)1