/** * Predicate to check an {@link AtlasObject} against the list of ids. * * @param <T> * Object type * @return {@link Predicate} */ private <T extends AtlasObject> Predicate<T> identifierCheck() { return object -> this.identifiers.contains(object.getIdentifier()); }
protected SnakeRoadNetworkWalk(final Edge edge, final Angle threshold) { this.isSnakeRoad = false; this.roadName = edge.getTag(NameTag.KEY); this.refTag = edge.getTag(ReferenceTag.KEY); this.greatestEncounteredValence = 0; // We use a TreeSet here to order the edges by their Atlas identifier. This helps us easily // grab the first and last Edge making up the road and check connections for false // positives. this.visitedEdges = new TreeSet<AtlasObject>((one, two) -> { return Long.compare(one.getIdentifier(), two.getIdentifier()); }); this.visitedEdges.add(edge); this.directConnections = new LinkedList<>(); this.oneLayerRemovedConnections = new HashSet<>(); this.edgeHeadingDifferenceThreshold = threshold; }
/** * Similar to {@link BaseCheck#getUniqueOSMIdentifier(AtlasObject)} except instead of using the * OSM identifier we use the Atlas identifier * * @param object * {@link AtlasObject} to generate unique identifier for * @return unique object identifier among different types */ protected String getUniqueObjectIdentifier(final AtlasObject object) { if (object instanceof AtlasEntity) { return String.format("%s%s", ((AtlasEntity) object).getType().toShortString(), object.getIdentifier()); } else { return String.format("%s%s", object.getClass().getSimpleName(), object.getIdentifier()); } }
/** * Constructor for multiple {@link AtlasObject}s * * @param objects * a {@code Set} of {@link AtlasObject}s used to form the {@code identifier} */ public TaskIdentifier(final Set<AtlasObject> objects) { if (objects == null || objects.isEmpty()) { throw new CoreException("items can't be empty"); } final Set<String> orderedSet = new TreeSet<>( objects.stream().map(item -> String.valueOf(item.getIdentifier())) .collect(EnhancedCollectors.toUnmodifiableSortedSet())); this.identifier = StringUtils.join(orderedSet, CommonConstants.EMPTY_STRING); }
@Override public boolean validCheckForObject(final AtlasObject object) { return object instanceof Edge // Check to see that the Edge is a master Edge && Edge.isMasterEdgeIdentifier(object.getIdentifier()) // Check to see that the edge has not already been seen && !this.isFlagged(object.getIdentifier()) // Check to see that the edge is car navigable && HighwayTag.isCarNavigableHighway(object) // The edge is not part of an area && !object.getTag(AreaTag.KEY).isPresent(); }
private Map<String, String> initProperties(final AtlasObject object) { final Map<String, String> tags = object.getTags(); tags.put(ITEM_IDENTIFIER_TAG, object.getIdentifier() + ""); tags.put(OSM_IDENTIFIER_TAG, object.getOsmIdentifier() + ""); if (object instanceof Area) { tags.put(ITEM_TYPE_TAG, AREA_TAG); } else if (object instanceof Line) { tags.put(ITEM_TYPE_TAG, LINE_TAG); } else if (object instanceof Edge) { tags.put(ITEM_TYPE_TAG, EDGE_TAG); } else if (object instanceof Node) { tags.put(ITEM_TYPE_TAG, NODE_TAG); } else if (object instanceof Point) { tags.put(ITEM_TYPE_TAG, POINT_TAG); } return tags; } }
@Override public Optional<CheckFlag> check(final AtlasObject object) { try { if (this.checkObjectFilter().test(object)) { return this.flag(object); } } catch (final Exception oops) { logger.error(String.format("%s failed on feature %s.", this.getCheckName(), object.getIdentifier()), oops); } return Optional.empty(); }
/** * 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) { // Object must be either a MultiPolygon Relation with at least one member, or an Area with // a place=islet, place=island, place=archipelago, or natural=water tag return (object instanceof Relation && IS_MULTIPOLYGON_WATER_RELATION.test(object) && ((Relation) object).members().size() >= 2) || (object instanceof Area && (TagPredicates.IS_WATER_BODY.test(object) || IS_ISLET.test(object) || IS_ISLAND.test(object)) && !this.isFlagged(object.getIdentifier())); }
if (polledMember instanceof Relation) if (relationsSeen.contains(polledMember.getIdentifier())) relationsSeen.add(polledMember.getIdentifier());
/** * 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) { // Checks for areas, that are not flagged, and pass any of the TaggableFilters in // aoiFilters. aoiFiltersTest() and aoiFilters is used in place of a single TaggableFilter // so that each filter may be tested separately later. return object instanceof Area && !this.isFlagged(object.getIdentifier()) && aoiFiltersTest(object); }
/** * Generates a unique identifier given an {@link AtlasObject}. OSM/Atlas objects with different * types can share the identifier (way 12345 - node 12345). This method makes sure we generate a * truly unique identifier, based on the OSM identifier, among different types for an * {@link AtlasObject}. If the AtlasObject is an instanceof AtlasEntity then it will simply use * the type for the first part of the identifier, otherwise it will use the simple class name. * * @param object * {@link AtlasObject} to generate unique identifier for * @return unique object identifier among different types */ protected String getUniqueOSMIdentifier(final AtlasObject object) { if (object instanceof AtlasEntity) { return String.format("%s%s", ((AtlasEntity) object).getType().toShortString(), object.getOsmIdentifier()); } else { return String.format("%s%s", object.getClass().getSimpleName(), object.getIdentifier()); } }
/** * 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; }
/** * This is the actual function that will check to see whether the object needs to be flagged. * * @param object * the atlas object supplied by the Atlas-Checks framework for evaluation * @return an optional {@link CheckFlag} object that */ @Override protected Optional<CheckFlag> flag(final AtlasObject object) { if (this.isChecked.contains(object.getIdentifier()) || !partOfTollBooth(object)) { this.markAsFlagged(object.getOsmIdentifier()); return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier()))); } return Optional.empty(); }
@Override public boolean validCheckForObject(final AtlasObject object) { return this.validEdge(object) && !this.isFlagged(object.getIdentifier()) && ((Edge) object) .highwayTag().isMoreImportantThanOrEqualTo(this.minimumHighwayType); }
@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. Objects * passed to this function have already been filtered by the tags.filter parameter in the * configuration file. * * @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 AccessTag.isNo(object) && ((object instanceof Edge) || (object instanceof Line)) && Edge.isMasterEdgeIdentifier(object.getIdentifier()) && !this.isFlagged(object.getOsmIdentifier()) && isMinimumHighway(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 !this.isFlagged(object.getIdentifier()) && (object instanceof Area || (object instanceof Relation && ((Relation) object).isMultiPolygon())) && this.hasMinKey(object) && (this.isBuildingOrPart(object) || this.isBuildingRelationMember(object)); }
@Override protected Optional<CheckFlag> flag(final AtlasObject object) { // Use EdgeWalker to gather all connected invalid crossings. The use of the walker prevents // edges from being flagged more than once. final Set<Edge> collectedEdges = new EdgeCrossingEdgeWalker((Edge) object, this.getInvalidCrossingEdges()).collectEdges(); if (collectedEdges.size() > 1) { final CheckFlag newFlag = new CheckFlag(getTaskIdentifier(object)); this.markAsFlagged(object.getIdentifier()); newFlag.addObject(object); newFlag.addInstruction(this.getLocalizedInstruction(0, object.getOsmIdentifier())); collectedEdges.forEach(invalidEdge -> { this.markAsFlagged(invalidEdge.getIdentifier()); newFlag.addObject(invalidEdge); newFlag.addInstruction( this.getLocalizedInstruction(1, invalidEdge.getOsmIdentifier())); }); return Optional.of(newFlag); } return Optional.empty(); }
: MULTI_POLYGON_CONVERTER.convert((Relation) object); return !checked.contains(object) && !this.isFlagged(object.getIdentifier()) && (this.isBuildingOrPart(object) || this.isBuildingRelationMember(object))