ComplexHighwayAreaHelper(final Edge edge) { this.sourceEdge = edge; buildHighwayAreaBoundary(Route.forEdge(edge)).ifPresent(route -> { this.boundary = route.asPolyLine(); StreamSupport.stream(route.spliterator(), false).map(Edge::getIdentifier) .forEach(this.visitedEdgeIdentifiers::add); this.sourceEdge = edge.getAtlas().edge(this.visitedEdgeIdentifiers.first()); }); if (this.boundary == null) { this.oops = new CoreException("Unable to build boundary for edge {}", edge.getOsmIdentifier()); } }
protected ComplexTurnRestriction(final AtlasEntity source, final Predicate<Edge> validEdge) { super(source); try { this.turnRestriction = TurnRestriction.from((Relation) source) .orElseThrow(() -> new CoreException( "{} is not a turn restriction according to Atlas", source.getIdentifier())); final Route route = this.turnRestriction.route(); final int routeLength = route.size(); if (routeLength < 2) { throw new CoreException("Must have at least two edges in the route"); } final long filteredLength = StreamSupport.stream(route.spliterator(), false) .filter(validEdge).count(); if (filteredLength < routeLength) { throw new CoreException("{} invalid edges", routeLength - filteredLength); } } catch (final Exception oops) { logger.trace("Unable to create ComplexTurnRestriction from {}", source, oops); setInvalidReason("Couldn't create ComplexTurnRestriction", oops); } }