@Override protected Set<String> getKeys(final Edge edge) { final Set<String> result = new HashSet<>(); result.add(edge.highwayTag().getTagValue()); return result; }
/** * Validates given {@link AtlasObject} (assumed to be an {@link Edge}) whether it is a valid * crossing edge or not * * @param object * {@link AtlasObject} to test * @return {@code true} if given {@link AtlasObject} object is a valid crossing edge */ private boolean isValidCrossingEdge(final AtlasObject object) { if (Edge.isMasterEdgeIdentifier(object.getIdentifier()) && !TagPredicates.IS_AREA.test(object) && !this.isFlagged(object.getIdentifier())) { final Optional<HighwayTag> highway = HighwayTag.highwayTag(object); if (highway.isPresent()) { final HighwayTag highwayTag = highway.get(); return HighwayTag.isCarNavigableHighway(highwayTag) && !HighwayTag.CROSSING.equals(highwayTag) && highwayTag.isMoreImportantThanOrEqualTo(this.minimumHighwayType); } } return false; }
public String getTagValue() { return name().toLowerCase().intern(); }
/** * Checks if an {@link AtlasObject} is of an equal or greater priority than the minimum. The * minimum is supplied as a configuration parameter, the default is {@code "tertiary"}. * * @param object * an {@link AtlasObject} * @return {@code true} if this object is >= the minimum */ private boolean isMinimumHighway(final AtlasObject object) { final Optional<HighwayTag> result = HighwayTag.highwayTag(object); return result.isPresent() && result.get().isMoreImportantThanOrEqualTo(this.minimumHighwayType); }
if (!this.rampEdgeFilter.test(nextEdge) && HighwayTag.highwayTag(nextEdge) .orElse(HighwayTag.NO).isMoreImportantThanOrEqualTo(arterialMinimum)) else if (nextEdge.highwayTag().isIdenticalClassification(finalEdge.highwayTag()) && finalEdge.getMasterEdgeIdentifier() != nextEdge .getMasterEdgeIdentifier())
/** * 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(); }
/** * Function for {@link SimpleEdgeWalker} that gathers connected edges that are part of a * roundabout. * * @return {@link Function} for {@link SimpleEdgeWalker} */ private Function<Edge, Stream<Edge>> isRoundaboutEdge() { return edge -> edge.connectedEdges().stream() .filter(connected -> JunctionTag.isRoundabout(connected) && HighwayTag.isCarNavigableHighway(connected)); } }
@Override protected Optional<CheckFlag> flag(final AtlasObject object) return HighwayTag.highwayTag(object) if (tag.equals(HighwayTag.FOOTWAY)) tag.getTagValue());
@Test public void testMoreImportant() { Assert.assertTrue(HighwayTag.MOTORWAY.isMoreImportantThan(HighwayTag.TERTIARY)); Assert.assertTrue(HighwayTag.PRIMARY.isMoreImportantThan(HighwayTag.SECONDARY)); // Testing equivalence Assert.assertTrue(HighwayTag.PRIMARY.isMoreImportantThanOrEqualTo(HighwayTag.PRIMARY)); } }
@Test public void testIsHighwayArea() { final Map<String, String> tags = new HashMap<>(); tags.put(HighwayTag.KEY, HighwayTag.PEDESTRIAN.getTagValue()); tags.put(BuildingTag.KEY, BuildingTag.YES.name().toLowerCase()); Assert.assertTrue(HighwayTag.isHighwayArea(new TestTaggable(tags))); tags.put(HighwayTag.KEY, HighwayTag.FOOTWAY.getTagValue()); Assert.assertTrue(HighwayTag.isHighwayArea(new TestTaggable(tags))); tags.remove(BuildingTag.KEY); Assert.assertFalse(HighwayTag.isHighwayArea(new TestTaggable(tags))); tags.put(AreaTag.KEY, AreaTag.YES.name().toLowerCase()); Assert.assertTrue(HighwayTag.isHighwayArea(new TestTaggable(tags))); tags.put(HighwayTag.KEY, HighwayTag.TRACK.getTagValue()); Assert.assertFalse(HighwayTag.isHighwayArea(new TestTaggable(tags))); }
public boolean hasHighwayTag() { return HighwayTag.highwayTag(this).isPresent(); }
/** * Test if an {@link Edge} is a candidate for expanding a {@link BigNode}, potentially becoming * a Junction Edge in the process. This filters off all the {@link Edge}s that are less * important than {@link HighwayTag#RESIDENTIAL}. It also filters off all the edges that are * likely roundabouts and link Roads. * * @param edge * The candidate {@link Edge} * @return {@code true} if the {@link Edge} is a candidate for expanding a {@link BigNode} */ private boolean isCandidateJunctionEdge(final Edge edge) { final HighwayTag highwayTag = edge.highwayTag(); return isShortEnough(edge) && highwayTag.isMoreImportantThanOrEqualTo(HighwayTag.RESIDENTIAL) && !JunctionTag.isRoundabout(edge); }
private Predicate<Edge> intersectsCoreWayInvalidly(final Area building) { // An invalid intersection is determined by checking that its highway tag is car navigable // or core way based on the configuration value return edge -> (this.carNavigableEdgesOnly ? HighwayTag.isCarNavigableHighway(edge) : HighwayTag.isCoreWay(edge)) // And if the edge intersects the building polygon && edge.asPolyLine().intersects(building.asPolygon()) // And ignore intersections where edge has highway=service and building has // Amenity=fuel && !(HIGHWAY_SERVICE_TAG.test(edge) && Validators.isOfType(building, AmenityTag.class, AmenityTag.FUEL)) // And if the layers have the same layer value && LayerTag.getTaggedValue(edge).orElse(0L) .equals(LayerTag.getTaggedValue(building).orElse(0L)) // And if the building/edge intersection is not valid && !isValidIntersection(building, edge) // And if the edge has no Access = Private tag && !Validators.isOfType(edge, AccessTag.class, AccessTag.PRIVATE); }
@Test public void testLessImportant() { Assert.assertTrue(HighwayTag.SECONDARY.isLessImportantThan(HighwayTag.PRIMARY)); Assert.assertTrue(HighwayTag.TERTIARY.isLessImportantThan(HighwayTag.TRUNK)); // Testing equivalence Assert.assertTrue(HighwayTag.PRIMARY.isLessImportantThanOrEqualTo(HighwayTag.PRIMARY)); }
if (edge.highwayTag().isLessImportantThan(HighwayTag.TERTIARY))
@Test public void testClassificationMatch() { Assert.assertTrue(HighwayTag.MOTORWAY.isIdenticalClassification(HighwayTag.MOTORWAY)); Assert.assertFalse(HighwayTag.PRIMARY.isIdenticalClassification(HighwayTag.SECONDARY)); }
/** * @param edge * The {@link Edge} to look at * @return The most significant {@link HighwayTag} directly connected to this {@link Edge} * (including itself) */ private HighwayTag mostSignificantConnectedHighwayType(final Edge edge) { HighwayTag edgeTag = edge.highwayTag(); for (final Edge connected : edge.connectedEdges()) { final HighwayTag connectedTag = connected.highwayTag(); if (connectedTag.isMoreImportantThan(edgeTag)) { edgeTag = connectedTag; } } return edgeTag; }
private boolean isHighwayOrFerry(final Way way) { final TagMap taggableWay = new TagMap(way.getTags()); return HighwayTag.isCoreWay(taggableWay) || RouteTag.isFerry(taggableWay); }
@Override public boolean validCheckForObject(final AtlasObject object) { // We could go about this a couple of ways. Either check all buildings, all roads, or both. // Since intersections will be flagged for any feature, it makes sense to loop over the // smallest of the three sets - buildings (for most countries). This may change over time. return object instanceof Area && BuildingTag.isBuilding(object) && !HighwayTag.isHighwayArea(object) && !Validators.isOfType(object, AmenityTag.class, AmenityTag.PARKING) && !Validators.isOfType(object, BuildingTag.class, BuildingTag.ROOF) // Ignore buildings that have points withing it with Ameniity=Fuel && !object.getAtlas().pointsWithin(((Area) object).asPolygon(), point -> Validators.isOfType(point, AmenityTag.class, AmenityTag.FUEL)) .iterator().hasNext(); }
if (inEdge.highwayTag().isLessImportantThan(HighwayTag.RESIDENTIAL) || this.edgeDirectionComparator.isSameDirection(candidateRoute.start(), inEdge, false) if (outEdge.highwayTag().isMoreImportantThanOrEqualTo(HighwayTag.RESIDENTIAL) && this.edgeDirectionComparator.isOppositeDirection(inEdge, outEdge, false)