@Override public Node start() { return this.source.start(); } }
@Override public List<Node> nodes() { final List<Node> result = new ArrayList<>(); result.add(this.edge.start()); result.add(this.edge.end()); return result; }
public Set<Node> connectedNodes() { final Set<Node> result = new HashSet<>(); result.add(this.start()); result.add(this.end()); return result; }
/** * @return All the {@link Edge}s connected and pointing to the start {@link Node} of this * {@link Edge}. If this {@link Edge} is a two-way road, then the reversed {@link Edge} * will be included in the set. */ public Set<Edge> inEdges() { return this.start().inEdges(); }
protected Stream<Edge> inEdgesStream() { return edges().stream().filter(edge -> !nodes().contains(edge.start())); }
protected Stream<Edge> junctionEdgesStream() { return edges().stream() .filter(edge -> nodes().contains(edge.start()) && nodes().contains(edge.end())); }
protected Stream<Edge> exteriorEdgesStream() { return edges().stream() .filter(edge -> !nodes().contains(edge.end()) || !nodes().contains(edge.start())); }
@Override public JsonObject geoJsonProperties() { final JsonObject properties = super.geoJsonProperties(); properties.addProperty("startNode", start().getIdentifier()); properties.addProperty("endNode", end().getIdentifier()); return properties; }
/** * Note: The start and end {@link Node}s of the {@link Route} are part of the hash code to * reduce the probability of a collision. There are other candidates to add here, like distance * between start/end, but start/end by themselves are the least computationally intensive to * derive. */ @Override public int hashCode() { return new HashCodeBuilder().append(this.start().start().getLocation()) .append(this.end().end().getLocation()).append(Iterables.asList(this)).hashCode(); }
public static CompleteEdge from(final Edge edge) { return new CompleteEdge(edge.getIdentifier(), edge.asPolyLine(), edge.getTags(), edge.start().getIdentifier(), edge.end().getIdentifier(), edge.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
/** * A {@link SyntheticBoundaryNodeTag} is a special tag that is placed on any tag that has been * cut on the border of the particular Atlas file or shard that you are processing. The cutting * process has the potential to create floating edges at the border that are in reality not * floating edges. * * @param edge * the edge that is currently be processed * @return {@code true} if the edge contains a synthetic boundary tag */ private boolean isNotOnSyntheticBoundary(final Edge edge) { return !(SyntheticBoundaryNodeTag.isBoundaryNode(edge.start()) || SyntheticBoundaryNodeTag.isBoundaryNode(edge.end())); }
/** * Adds the given {@link Edge} to the visited set and updates the greatest valence value * * @param comingFrom * the {@link Edge} we are coming from * @param comingTo * the {@link Edge} we are coming to */ protected void visitEdge(final Edge comingFrom, final Edge comingTo) { this.visitedEdges.add(comingTo); this.setGreatestValence(comingTo.start()); this.setGreatestValence(comingTo.end()); checkIfEdgeHeadingDifferenceExceedsThreshold(comingFrom, comingTo); }
@Override public Node start() { return new DynamicNode(dynamicAtlas(), subEdge().start().getIdentifier()); }
@Override public boolean equals(final Object other) { if (other instanceof Route) { final Route that = (Route) other; if (this.size() == that.size()) { return new EqualsBuilder() .append(this.start().start().getLocation(), that.start().start().getLocation()) .append(this.end().end().getLocation(), that.end().end().getLocation()) .append(Iterables.asList(this), Iterables.asList(that)).isEquals(); } } return false; }
@Override public Node start() { return new MultiNode(multiAtlas(), masteriseNodeIdentifier(this.getSubEdge().start().getIdentifier())); }
public Route prepend(final Route route) { if (!start().start().equals(route.end().end())) { throw new CoreException("Cannot prepend a disconnected route."); } return new MultiRoute(route, this); }
@Override public String toString() { return "[Edge" + ": id=" + this.getIdentifier() + ", startNode=" + start().getIdentifier() + ", endNode=" + end().getIdentifier() + ", polyLine=" + this.asPolyLine().toWkt() + ", " + tagString() + "]"; } }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Edge" + ": id=" + this.getIdentifier() + ", startNode=" + start().getIdentifier() + ", endNode=" + end().getIdentifier() + ", polyLine=" + this.asPolyLine().toWkt() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
@Test public void connectivityTest() { this.multi.forEach(atlasItem -> logger.trace(atlasItem.toString())); // Out edges of CC2: 987 Assert.assertEquals(1, this.multi.edge(6).end().outEdges().size()); Assert.assertEquals(987, this.multi.edge(6).end().outEdges().iterator().next().getIdentifier()); Assert.assertEquals(2, this.multi.edge(-9).end().outEdges().size()); Assert.assertEquals(2, this.multi.edge(-9).end().inEdges().size()); Assert.assertEquals(2, this.multi.edge(987).start().inEdges().size()); }
private boolean canAddEdgeToBoundary(final Edge edge, final Route boundary) { return edge.getIdentifier() != -boundary.end().getIdentifier() && edge.getOsmIdentifier() == boundary.end().getOsmIdentifier() && boundary.end().end().getLocation().equals(edge.start().getLocation()) && !boundary.includes(edge); } }