static Long getTaggedOrImpliedValue(final Taggable taggable, final Long impliedValue) { final Optional<Long> taggedValue = getTaggedValue(taggable); return taggedValue.isPresent() ? taggedValue.get() : impliedValue; }
private long getLayerTagValueForPoint(final Atlas atlas, final long identifier) { return LayerTag.getTaggedOrImpliedValue(atlas.point(identifier), 0L); }
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); }
private boolean locationPartOfMultipleWaysWithDifferentLayerTags(final Atlas atlas, final Location location) { final long distinctLayerTagValues = StreamSupport .stream(atlas.linesContaining(location).spliterator(), false) .map(line -> LayerTag.getTaggedOrImpliedValue(atlas.line(line.getIdentifier()), 0L)) .distinct().count(); return distinctLayerTagValues > 1; }
final Optional<Long> layerTagValue = LayerTag.getTaggedValue(object); final boolean isTagValueValid = layerTagValue.isPresent();
/** * Determines whether the given {@link Line} has any intersecting {@link Line}s, with the same * layer tag value that meet the definition of an {@link Edge}, running through it at the given * {@link Location}. * * @param location * The {@link Location} to use * @param line * The {@link Line} to use * @return {@code true} if there is at least one {@link Edge} with the same layer tag value * intersecting the given line at the given location */ private boolean locationIsPartOfAnIntersectingEdgeOfTheSameLayer(final Location location, final Line line) { final long targetLayerValue = LayerTag.getTaggedOrImpliedValue(line, 0L); return Iterables // Find all intersecting edges .stream(this.rawAtlas.linesContaining(location, target -> target.getIdentifier() != line.getIdentifier() && isAtlasEdge(target) && target.asPolyLine().contains(location))) // Check whether that edge has the same layer value as the line we're looking at .anyMatch(candidate -> { final long layerValue = LayerTag.getTaggedOrImpliedValue(candidate, 0L); return targetLayerValue == layerValue; }); }
? LayerTag.getTaggedValue(edge) : Optional.of(OSM_LAYER_DEFAULT); final Optional<Long> crossingEdgeLayer = Validators .hasValuesFor(crossingEdge, LayerTag.class) ? LayerTag.getTaggedValue(crossingEdge) : Optional.of(OSM_LAYER_DEFAULT); return edgeAsPolyLine.intersections(crossingEdgeAsPolyLine).stream()
final Location location, final Line line) final long targetLayerValue = LayerTag.getTaggedOrImpliedValue(line, 0L); final long layerValue = LayerTag.getTaggedOrImpliedValue(candidate, 0L); final boolean edgesOnDifferentLayers = targetLayerValue != layerValue; final PolyLine candidatePolyline = candidate.asPolyLine();