@Override public boolean test(final Edge edge) { return edge.isMasterEdge() && edge.getOsmIdentifier() == this.osmIdentifier; } }
/** * This function will validate if the supplied atlas object is valid for the check. * * @param object * the atlas object supplied by the Atlas-Checks framework for evaluation * @return {@code true} if this object should be checked */ @Override public boolean validCheckForObject(final AtlasObject object) { final Map<String, String> osmTags = object.getOsmTags(); return object instanceof Edge && ((Edge) object).isMasterEdge() && HighwayTag.isCarNavigableHighway(object) && this.nameKeys.stream().anyMatch(osmTags::containsKey); }
/** * Returns all connected master, non-visited {@link Edge}s that are a continuation of the same * OSM way * * @param edge * the {@link Edge} from which we're seeking connections * @return a set of {@link Edge}s */ protected Set<Edge> getConnectedMasterEdgeOfTheSameWay(final Edge edge) { return edge.connectedEdges().stream() .filter(connection -> connection.isMasterEdge() && connection.getOsmIdentifier() == edge.getOsmIdentifier() && !this.visitedEdges.contains(connection)) .collect(Collectors.toSet()); }
private static boolean validEdge(final Edge edge) { return Validators.isNotOfType(edge, HighwayTag.class, HighwayTag.NO) && Validators.isOfType(edge, AreaTag.class, AreaTag.YES) && edge.isMasterEdge(); }
private void processEntity(final AtlasEntity entity, final List<PolyLine> candidates, final List<Polygon> alreadyFormed) { if (entity instanceof Area) { // Easy alreadyFormed.add(((Area) entity).asPolygon()); } else if (entity instanceof LineItem) { // In case an Edge is an outer/inner, make sure to not double count it by looking at the // master edge only. if (!(entity instanceof Edge) || ((Edge) entity).isMasterEdge()) { candidates.add(((LineItem) entity).asPolyLine()); } } } }
@Override public boolean validCheckForObject(final AtlasObject object) { return (object instanceof Area || (object instanceof Edge && ((Edge) object).isMasterEdge())) && !this.isFlagged(object.getOsmIdentifier()); }
if (this.source.isMasterEdge()) if (!this.source.isMasterEdge())
/** * Checks if the supplied object is of {@link ItemType} {@link Edge} and that it is the * MasterEdge and whether a car can navigate on the edge. So we would ignore any pedestrian * paths in this particular check. An {@link Edge} contains a master edge and a reserve edge, * unless it is a oneway edge in which case it will only contain the master edge. Either way we * want to ignore the reverse edge so that we don't produce duplicate flags for what is * essentially the same feature. * * @param object * the {@link AtlasObject} you are checking * @return {@code true} if matches the restrictions described above */ @Override public boolean validCheckForObject(final AtlasObject object) { // Consider navigable master edges return TypePredicates.IS_EDGE.test(object) && ((Edge) object).isMasterEdge() && HighwayTag.isCarNavigableHighway(object) && isMinimumHighwayType(object); }
/** * @return the master for this {@link Edge}, which may or may not be the master. */ public Edge getMasterEdge() { return this.isMasterEdge() ? this : this.reversed() .orElseThrow(() -> new CoreException( "Reverse edge should be available for edge {}", this.getIdentifier())); }
/** * Validate if given {@link AtlasObject} is actually an {@link Edge} and make sure the edge has * one of the following tags: tunnel, bridge, layer */ @Override public boolean validCheckForObject(final AtlasObject object) { return object instanceof Edge // must be highway navigable && HighwayTag.isCarNavigableHighway(object) // and one of the following && ALLOWED_TAGS.test(object) // removes one of two bi-directional edge candidates && ((Edge) object).isMasterEdge() // remove way sectioned duplicates && !this.isFlagged(object.getOsmIdentifier()); }
@Override public boolean validCheckForObject(final AtlasObject object) { // We check that the object is an instance of Edge return object instanceof Edge // Make sure that the edges are instances of roundabout && JunctionTag.isRoundabout(object) // And that the Edge has not already been marked as flagged && !this.isFlagged(object.getIdentifier()) // Make sure that we are only looking at master edges && ((Edge) object).isMasterEdge() // Check for excluded highway types && HighwayTag.isCarNavigableHighway(object); }
@Override public boolean validCheckForObject(final AtlasObject object) { // We check that the object is an instance of Edge return object instanceof Edge // Make sure that the object has an iso_country_code && object.getTag(ISOCountryTag.KEY).isPresent() // Make sure that the edges are instances of roundabout && JunctionTag.isRoundabout(object) // And that the Edge has not already been marked as flagged && !this.isFlagged(object.getIdentifier()) // Make sure that we are only looking at master edges && ((Edge) object).isMasterEdge() // Check for excluded highway types && !this.isExcludedHighway(object); }
/** * This function will validate if the supplied atlas object is valid for the check. * * @param object * the atlas object supplied by the Atlas-Checks framework for evaluation * @return {@code true} if this object should be checked */ @Override public boolean validCheckForObject(final AtlasObject object) { return Validators.hasValuesFor(object, LanesTag.class) && HighwayTag.isCarNavigableHighway(object) && object instanceof Edge && ((Edge) object).isMasterEdge() && !this.lanesFilter.test(object) && !this.isFlagged(object.getOsmIdentifier()); }
/** * Checks to see whether the atlas object has the prerequisites to be evaluated. It uses a * function {@link BaseCheck#isFlagged(Object)} that looks through a list of elements that have * been flagged by the check algorithm, and if the check has already looked at a specific * feature it can skip it here. This is useful if you are walking the graph in your check * algorithm and then can flag each feature that you visit while walking the graph. * * @param object * the {@link AtlasObject} you are checking * @return {@code true} if object should be checked */ @Override public boolean validCheckForObject(final AtlasObject object) { // Master edges with building tags or with eligible highway tags return object instanceof Edge && ((Edge) object).isMasterEdge() && (Validators.hasValuesFor(object, BuildingTag.class) || ((Edge) object) .highwayTag().isMoreImportantThanOrEqualTo(this.minimumHighwayType)) // Areas || object instanceof Area // Lines excluding ineligible highway tags || object instanceof Line // Exclude waterway tags && !Validators.hasValuesFor(object, WaterwayTag.class); }
/** * Validates whether a given {@link Edge} should be considered as a candidate to be part of a * snake road. The criteria used: * <ul> * <li>1) {@link HighwayTag} is equal to or more significant than Residential * <li>2) {@link HighwayTag}} is less important than trunk_link * <li>3) {@link Edge} is not a roundabout * <li>4) {@link Edge} is not an Open Highway Area * <li>5) {@link Edge} is way-sectioned * <li>6) {@link Edge} is the master edge * </ul> * * @param candidate * {@link Edge} to test * @return {@code true} if given {@link Edge} can be part of a snake road */ private static boolean isValidEdgeToConsider(final Edge candidate) { return candidate.isMasterEdge() && candidate.highwayTag().isMoreImportantThanOrEqualTo(HighwayTag.RESIDENTIAL) && candidate.highwayTag().isLessImportantThan(HighwayTag.TRUNK_LINK) && !JunctionTag.isRoundabout(candidate) && !TagPredicates.IS_HIGHWAY_AREA.test(candidate) && candidate.isWaySectioned(); }
/** * Returns all connected master {@link Edge}s that are NOT part of the same way as the given * target {@link Edge} * * @param edge * the target {@link Edge} for which we're seeking connections * @return the {@link Set} of {@link Edge}s we found */ private Set<Edge> getMasterEdgesForConnectedEdgesOfDifferentWays(final Edge edge) { return Iterables.stream(edge.connectedEdges()).filter(candidate -> candidate.isMasterEdge() && candidate.getOsmIdentifier() != edge.getOsmIdentifier()).collectToSet(); }
if (!edge.isMasterEdge() || OneWayTag.isExplicitlyTwoWay(edge))
protected void validateReverseEdgesHaveForwardMatchingCounterpart() .filter(featureChange -> !((Edge) featureChange.getReference()).isMasterEdge()) .filter(featureChange -> featureChange.getChangeType() != ChangeType.REMOVE) .forEach(backwardFeatureChange ->
@Test public void removeAllReverseEdges() { resetAndChange("removeAllReverseEdges", new AtlasChangeGeneratorRemoveReverseEdges()); final long changeAtlasReverseEdges = Iterables .size(this.changeAtlas.edges(edge -> !edge.isMasterEdge())); final long subAtlasReverseEdges = Iterables .size(this.subAtlas.edges(edge -> !edge.isMasterEdge())); final long atlasReverseEdges = Iterables .size(this.atlas.edges(edge -> !edge.isMasterEdge())); Assert.assertEquals(48, changeAtlasReverseEdges); Assert.assertEquals(166, subAtlasReverseEdges); // The reverse edges from the subAtlas (marked for removal) plus the ones from the // changeAtlas = all the initial reverse edges. Assert.assertEquals(changeAtlasReverseEdges + subAtlasReverseEdges, atlasReverseEdges); }
protected void validateReverseEdgePolyLineUpdated() { for (final Edge edge : this.atlas .edges(edge -> edge.hasReverseEdge() && edge.isMasterEdge())) { final Edge reversed = edge.reversed().orElseThrow(() -> new CoreException( "Edge {} should have a reverse, but does not.", edge.getIdentifier())); final PolyLine forward = edge.asPolyLine(); final PolyLine backward = reversed.asPolyLine(); if (!forward.equals(backward.reversed())) { throw new CoreException( "Edge {} and its reverse {} have mismatching PolyLines: Forward = {}, Backward = {}", edge.getIdentifier(), reversed.getIdentifier(), forward, backward); } } } }