@Override public boolean validCheckForObject(final AtlasObject object) { return !this.isFlagged(object.getOsmIdentifier()) && TypePredicates.IS_EDGE.test(object) && isValidEdgeToConsider((Edge) object); }
/** * 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) { return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier()))); }
/** * Validates if given {@link AtlasObject} is actually an {@link Edge} and is a roundabout and * also corresponding OSM identifier shouldn't be flagged before (this is for avoiding duplicate * flags) */ @Override public boolean validCheckForObject(final AtlasObject object) { return object instanceof Edge && isAFormOfRoundabout(object) && !this.isFlagged(object.getOsmIdentifier()); }
@Override public boolean validCheckForObject(final AtlasObject object) { return (object instanceof Area || (object instanceof Edge && ((Edge) object).isMasterEdge())) && !this.isFlagged(object.getOsmIdentifier()); }
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; } }
/** * 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 (!isInMilitaryArea((LineItem) object)) { this.markAsFlagged(object.getOsmIdentifier()); return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier()))); } return Optional.empty(); }
/** * 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(); }
/** * 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()); } }
/** * 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()); }
/** * 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) { // Valid objects are items that were OSM nodes or ways (Equivalent to Atlas nodes, points, // edges, lines and areas) return !(object instanceof Relation) && !this.isFlagged(object.getOsmIdentifier()) && ((object.getTags().containsKey(ISOCountryTag.KEY) // Must have an ISO code that is in checkNameCountries... && this.checkNameCountries .contains(object.tag(ISOCountryTag.KEY).toUpperCase()) // And have a name tag && Validators.hasValuesFor(object, NameTag.class)) // Or it must have a specific language name tag from languageNameTags || this.languageNameTags.stream() .anyMatch(key -> object.getOsmTags().containsKey(key))); }
/** * Flags {@link AtlasObject}s that has names with abbreviations. */ @Override protected Optional<CheckFlag> flag(final AtlasObject object) { // Mark OSM identifier as we are processing it this.markAsFlagged(this.getUniqueOSMIdentifier((AtlasEntity) object)); // Fetch the name final Optional<String> optionalName = NameTag.getNameOf(object); if (!optionalName.isPresent()) { return Optional.empty(); } // Lowercase name and parse it into tokens final String name = optionalName.get(); final String lowercaseName = name.toLowerCase(this.getLocale()); final Set<String> tokens = Sets.newHashSet(NAME_SPLITTER.split(lowercaseName)); // Flag if it has any abbreviations if (tokens.stream().anyMatch(this.abbreviations::contains)) { final CheckFlag flag = this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier(), name)); return Optional.of(flag); } return Optional.empty(); }
this.getLocalizedInstruction(0, object.getOsmIdentifier())));
@Override protected Optional<CheckFlag> flag(final AtlasObject object) { final Edge edge = (Edge) object; // Mark edge (and all other edges that we may walk) as visited, irregardless // of whether it's a snake road or not this.markAsFlagged(object.getOsmIdentifier()); // Instantiate the network walk with the starting edge SnakeRoadNetworkWalk walk = initializeNetworkWalk(edge); // Walk the road walk = walkNetwork(edge, walk); // If we've found a snake road, create a flag if (networkWalkQualifiesAsSnakeRoad(walk)) { return Optional.of(createFlag(walk.getVisitedEdges(), this.getLocalizedInstruction(0, object.getOsmIdentifier()))); } return Optional.empty(); }
/** * 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) { final Area area = (Area) object; // this could be done in the ValidCheckForObject as well, doesn't change things too much if (Validators.isOfType(object, LeisureTag.class, LeisureTag.SWIMMING_POOL)) { final double surfaceArea = area.asPolygon().surface().asMeterSquared(); // we are purposefully separating our if statements to have more specific instructions if (surfaceArea > this.maximumSize) { return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, object.getOsmIdentifier(), surfaceArea, this.maximumSize))); } else if (surfaceArea < this.minimumSize) { return Optional.of(this.createFlag(object, this.getLocalizedInstruction(1, object.getOsmIdentifier(), surfaceArea, this.minimumSize))); } } return Optional.empty(); }
checkMessage = this.getLocalizedInstruction(0, object.getOsmIdentifier(), offendingAngles.get(0).getSecond()); checkMessage = this.getLocalizedInstruction(1, object.getOsmIdentifier(), offendingAngles.size());
this.markAsFlagged(object.getOsmIdentifier()); return Optional.of(createFlag(object, this.getLocalizedInstruction(0))); this.markAsFlagged(object.getOsmIdentifier()); return Optional.of(createFlag(object, this.getLocalizedInstruction(1)));
/** * 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()); }
/** * 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); }
/** * The primary function that will check to see if the current edge is a floating edge * * @param object * the {@link AtlasObject} you are checking * @return an Optional {@link CheckFlag} that contains the problem object and instructions on * how to fix it, or the reason the object was flagged */ @Override protected Optional<CheckFlag> flag(final AtlasObject object) { final Edge edge = (Edge) object; // Check the length of the edge and make sure that it is larger then the minimum distance // and shorter than the maximum distance. We also want to make sure it doesn't have any // connected edges and has not been cut on the border and contains a synthetic boundary tag. if (edge.length().isGreaterThanOrEqualTo(this.minimumDistance) && edge.length().isLessThanOrEqualTo(this.maximumDistance) && this.hasNoConnectedEdges(edge) && this.isNotOnSyntheticBoundary(edge)) { // return a flag created using the object and the flag that was either defined in the // configuration or above. return Optional.of(this.createFlag(edge, this.getLocalizedInstruction(0, object.getOsmIdentifier()))); } return Optional.empty(); }
@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(); }