Search in sources :

Example 1 with BogusShapeGeometryCaught

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

the class GeometryAndBlockProcessor method createStraightLineHopeGeometries.

private LineString[] createStraightLineHopeGeometries(List<StopTime> stopTimes, FeedScopedId shapeId) {
    LineString[] geoms = new LineString[stopTimes.size() - 1];
    StopTime st0;
    for (int i = 0; i < stopTimes.size() - 1; ++i) {
        st0 = stopTimes.get(i);
        StopTime st1 = stopTimes.get(i + 1);
        LineString geometry = createSimpleGeometry(st0.getStop(), st1.getStop());
        geoms[i] = geometry;
        // this warning is not strictly correct, but will do
        issueStore.add(new BogusShapeGeometryCaught(shapeId, st0, st1));
    }
    return geoms;
}
Also used : BogusShapeGeometryCaught(org.opentripplanner.graph_builder.issues.BogusShapeGeometryCaught) LineString(org.locationtech.jts.geom.LineString) ShapePoint(org.opentripplanner.model.ShapePoint) StopTime(org.opentripplanner.model.StopTime)

Example 2 with BogusShapeGeometryCaught

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

the class GeometryAndBlockProcessor method getSegmentGeometry.

private LineString getSegmentGeometry(FeedScopedId shapeId, LocationIndexedLine locationIndexedLine, LinearLocation startIndex, LinearLocation endIndex, double startDistance, double endDistance, StopTime st0, StopTime st1) {
    ShapeSegmentKey key = new ShapeSegmentKey(shapeId, startDistance, endDistance);
    LineString geometry = geometriesByShapeSegmentKey.get(key);
    if (geometry == null) {
        geometry = (LineString) locationIndexedLine.extractLine(startIndex, endIndex);
        // Pack the resulting line string
        CoordinateSequence sequence = new PackedCoordinateSequence.Double(geometry.getCoordinates(), 2);
        geometry = geometryFactory.createLineString(sequence);
        if (!isValid(geometry, st0.getStop(), st1.getStop())) {
            issueStore.add(new BogusShapeGeometryCaught(shapeId, st0, st1));
            // fall back to trivial geometry
            geometry = createSimpleGeometry(st0.getStop(), st1.getStop());
        }
        geometriesByShapeSegmentKey.put(key, geometry);
    }
    return geometry;
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) PackedCoordinateSequence(org.opentripplanner.common.geometry.PackedCoordinateSequence) BogusShapeGeometryCaught(org.opentripplanner.graph_builder.issues.BogusShapeGeometryCaught) LineString(org.locationtech.jts.geom.LineString)

Aggregations

LineString (org.locationtech.jts.geom.LineString)2 BogusShapeGeometryCaught (org.opentripplanner.graph_builder.issues.BogusShapeGeometryCaught)2 CoordinateSequence (org.locationtech.jts.geom.CoordinateSequence)1 PackedCoordinateSequence (org.opentripplanner.common.geometry.PackedCoordinateSequence)1 ShapePoint (org.opentripplanner.model.ShapePoint)1 StopTime (org.opentripplanner.model.StopTime)1