Search in sources :

Example 1 with BogusShapeGeometry

use of org.opentripplanner.graph_builder.issues.BogusShapeGeometry in project OpenTripPlanner by opentripplanner.

the class GeometryAndBlockProcessor method getHopGeometryViaShapeDistTraveled.

private LineString getHopGeometryViaShapeDistTraveled(FeedScopedId 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) {
        issueStore.add(new BogusShapeGeometry(shapeId));
        return null;
    } else {
        LinearLocation startIndex = getSegmentFraction(distances, startDistance);
        LinearLocation endIndex = getSegmentFraction(distances, endDistance);
        if (equals(startIndex, endIndex)) {
            // bogus shape_dist_traveled
            issueStore.add(new BogusShapeDistanceTraveled(st1));
            return createSimpleGeometry(st0.getStop(), st1.getStop());
        }
        LineString line = getLineStringForShapeId(shapeId);
        LocationIndexedLine lol = new LocationIndexedLine(line);
        geometry = getSegmentGeometry(shapeId, lol, startIndex, endIndex, startDistance, endDistance, st0, st1);
        return geometry;
    }
}
Also used : LineString(org.locationtech.jts.geom.LineString) BogusShapeGeometry(org.opentripplanner.graph_builder.issues.BogusShapeGeometry) LinearLocation(org.locationtech.jts.linearref.LinearLocation) LocationIndexedLine(org.locationtech.jts.linearref.LocationIndexedLine) BogusShapeDistanceTraveled(org.opentripplanner.graph_builder.issues.BogusShapeDistanceTraveled)

Aggregations

LineString (org.locationtech.jts.geom.LineString)1 LinearLocation (org.locationtech.jts.linearref.LinearLocation)1 LocationIndexedLine (org.locationtech.jts.linearref.LocationIndexedLine)1 BogusShapeDistanceTraveled (org.opentripplanner.graph_builder.issues.BogusShapeDistanceTraveled)1 BogusShapeGeometry (org.opentripplanner.graph_builder.issues.BogusShapeGeometry)1