Search in sources :

Example 1 with Heading

use of org.openstreetmap.atlas.geography.Heading in project atlas-checks by osmlab.

the class SignPostCheck method findFirstRampEdge.

/**
 * Given a final {@link Edge}, hops back and finds the first edge that was forming the ramp.
 *
 * @param finalEdge
 *            {@link Edge} that is the last/final piece of the ramp
 * @return {@link Edge} that possibly is the first {@link Edge} forming the ramp
 */
private Edge findFirstRampEdge(final Edge finalEdge) {
    int count = 0;
    // Go back and collect edges
    Edge nextEdge = finalEdge;
    while (count < MAX_EDGE_COUNT_FOR_RAMP) {
        count++;
        // Break if edge has no heading
        final Optional<Heading> initialHeading = nextEdge.asPolyLine().initialHeading();
        if (!initialHeading.isPresent()) {
            break;
        }
        // Collect in edges and make sure there is not more than one
        final Set<Edge> inEdges = nextEdge.inEdges();
        if (inEdges.isEmpty() || inEdges.size() > 1) {
            break;
        }
        // Find the edge that precedes nextEdge
        final HighwayTag highwayTag = nextEdge.highwayTag();
        final Edge precedingEdge = inEdges.iterator().next();
        // Ignore if edge has a different classification
        if (!highwayTag.isIdenticalClassification(precedingEdge.highwayTag())) {
            break;
        }
        // Break if given edge has no heading
        final Optional<Heading> finalHeading = precedingEdge.asPolyLine().finalHeading();
        if (!finalHeading.isPresent() || initialHeading.get().asPositiveAngle().difference(finalHeading.get().asPositiveAngle()).isGreaterThan(this.rampAngleDifference)) {
            break;
        }
        nextEdge = precedingEdge;
    }
    return nextEdge;
}
Also used : Heading(org.openstreetmap.atlas.geography.Heading) HighwayTag(org.openstreetmap.atlas.tags.HighwayTag) Edge(org.openstreetmap.atlas.geography.atlas.items.Edge)

Aggregations

Heading (org.openstreetmap.atlas.geography.Heading)1 Edge (org.openstreetmap.atlas.geography.atlas.items.Edge)1 HighwayTag (org.openstreetmap.atlas.tags.HighwayTag)1