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 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))); }
@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(); }
@Override public boolean validCheckForObject(final AtlasObject object) { // Object is an instance of Point return object instanceof Point // And does not have an Associated Street Relation && !hasAssociatedStreetRelation(object) // And has an AddressHouseNumberTag && object.getTag(AddressHousenumberTag.KEY).isPresent() // And either doesn't have the addr:street tag, has the tag but has a null value, // or has the tag but has no value && Strings.isNullOrEmpty(object.tag(AddressStreetTag.KEY)); }
/** * 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()); }
/** * 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(); }
/** * Atlas objects contain OSM tags plus tags inserted during Atlas generation. This function will * remove all but the OSM tags. * * @return All the OSM tags for the object */ default Map<String, String> getOsmTags() { return this.getTags(tag -> !AtlasTag.TAGS_FROM_OSM.contains(tag) && !AtlasTag.TAGS_FROM_ATLAS.contains(tag)); } }
.stream(object.getAtlas().areasIntersecting(aoiBounds, area -> area.getIdentifier() != aoi.getIdentifier() && !this.isFlagged(area.getIdentifier()) flag.addInstruction(this.getLocalizedInstruction(0, object.getOsmIdentifier(), area.getOsmIdentifier())); this.markAsFlagged(area.getIdentifier()); this.markAsFlagged(object.getIdentifier()); return Optional.of(flag);
@Override public boolean validCheckForObject(final AtlasObject object) { return !this.isFlagged(object.getOsmIdentifier()) && TypePredicates.IS_EDGE.test(object) && isValidEdgeToConsider((Edge) object); }
final Map<String, String> osmTags = object.getOsmTags(); if (this.checkNameCountries.contains(object.tag(ISOCountryTag.KEY).toUpperCase()) && Validators.hasValuesFor(object, NameTag.class) && isMixedCase(osmTags.get(NameTag.KEY))) this.markAsFlagged(object.getOsmIdentifier()); object.getOsmIdentifier(), String.join(", ", mixedCaseNameTags))));
final Optional<String> nameValue = object.getTag(nameKey); if (nameValue.isPresent()) this.getLocalizedInstruction(0, object.getOsmIdentifier())));
final Rectangle checkingBounds = checking.bounds(); .addAll(Iterables.asSet(checking.getAtlas().areasIntersecting(checkingBounds, area -> this.neighboringPart(area, checking, connectedParts)))); if (!this.relationSpatialIndices.containsKey(checking.getAtlas())) this.relationSpatialIndices.put(checking.getAtlas(), this.buildRelationSpatialIndex(checking.getAtlas())); .asSet(this.relationSpatialIndices.get(checking.getAtlas()).get(checkingBounds, relation -> this.neighboringPart(relation, checking, connectedParts))));
final Iterable<Area> possiblyIntersectingBuildings = object.getAtlas().areasIntersecting( building.bounds(), area -> BuildingTag.isBuilding(area) object.getOsmIdentifier(), otherBuilding.getOsmIdentifier())); otherBuilding.getOsmIdentifier(), object.getOsmIdentifier())); object.getOsmIdentifier(), otherBuilding.getOsmIdentifier())); object.getOsmIdentifier(), otherBuilding.getOsmIdentifier())); this.markAsFlagged(uniqueIdentifier); hadIntersection = true;
/** * Checks if an {@link AtlasObject} has tags indicating it is off the ground. * * @param object * {@link AtlasObject} to check * @return true if the area is off the ground */ private boolean isOffGround(final AtlasObject object) { Double minHeight; Double minLevel; try { minHeight = Double .parseDouble(object.getOsmTags().getOrDefault(MinHeightTag.KEY, ZERO_STRING)); minLevel = Double.parseDouble( object.getOsmTags().getOrDefault(BuildingMinLevelTag.KEY, ZERO_STRING)); } // We want to flag if there is a bad value catch (final NumberFormatException badTagValue) { minHeight = 1.0; minLevel = 1.0; } return minHeight > 0 || minLevel > 0; }
@Override protected Optional<CheckFlag> flag(final AtlasObject object) { final Point point = (Point) object; final List<Point> duplicates = Iterables .asList(object.getAtlas().pointsAt(point.getLocation())); if (duplicates.size() > 1) { this.markAsFlagged(point.getLocation()); final List<Long> duplicateIdentifiers = duplicates.stream() .map(AtlasEntity::getOsmIdentifier).collect(Collectors.toList()); return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, duplicateIdentifiers, point.getLocation()))); } return Optional.empty(); } }
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; }
/** * 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()); } }
private String initCountry(final AtlasObject object) { final Map<String, String> tags = object.getTags(); if (tags.containsKey(ISOCountryTag.KEY)) { return tags.get(ISOCountryTag.KEY); } return ISOCountryTag.COUNTRY_MISSING; }
/** * 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()))); }
/** * 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) { // We only need to check for Point's because by definition a Node will be connected to an // Edge. return object instanceof Point && object.getOsmTags().size() == 0 && ((Point) object).relations().size() == 0; }