/** * @return The absolute valence, considering all {@link Edge}s, irrespective of * bi-directionality. */ public long absoluteValence() { return this.connectedEdges().size(); }
/** * Create a full copy of the given node. * * @param node * the {@link Node} to deep copy * @return the new {@link CompleteNode} */ public static CompleteNode from(final Node node) { return new CompleteNode(node.getIdentifier(), node.getLocation(), node.getTags(), node.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), node.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), node.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
private void setGreatestValence(final Node node) { final long valence = node.valence(); if (valence > this.greatestEncounteredValence) { this.greatestEncounteredValence = valence; } }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Node: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", inEdges=" + connectedEdgesIdentifiers(() -> inEdges()) + ", outEdges=" + connectedEdgesIdentifiers(() -> outEdges()) + ", relations=(" + relationsString + "), " + tagString() + "]"; }
public static AtlasPrimitiveLocationItem from(final Node node) { final AtlasPrimitiveLocationItem locationItem = new AtlasPrimitiveLocationItem( node.getIdentifier(), node.getLocation(), node.getTags()); return locationItem; }
if (node.connectedEdges().stream().anyMatch(connectedEdge -> matchedEdgeIdentifiers .contains(connectedEdge.getIdentifier()))) final Long nodeIdentifier = node.getIdentifier(); if (builder.peek().node(nodeIdentifier) == null) builder.addNode(nodeIdentifier, node.getLocation(), node.getTags()); node.getIdentifier(), AtlasCutType.HARD_CUT_ALL); if (builder.peek().node(matchedEdge.start().getIdentifier()) != null && builder.peek().node(matchedEdge.end().getIdentifier()) != null)
private boolean differentNodes(final Node baseNode, final Node alterNode) { try { if (!baseNode.getLocation().equals(alterNode.getLocation())) { return true; } if (differentEdgeSet(baseNode.inEdges(), alterNode.inEdges())) { return true; } if (differentEdgeSet(baseNode.outEdges(), alterNode.outEdges())) { return true; } return false; } catch (final Exception e) { throw new CoreException("Unable to compare nodes {} and {}", baseNode, alterNode, e); } }
final RelationBean parentMembers = new RelationBean(); Rectangle parentBounds = null; for (final Node node : atlas.nodes(node -> node.valence() > 3)) final SortedSet<Edge> inEdges = node.inEdges(); final SortedSet<Edge> outEdges = node.outEdges(); for (final Edge inEdge : inEdges) inEdge.reversed().ifPresent(reversed -> members .addItem(reversed.getIdentifier(), "from", ItemType.EDGE)); members.addItem(node.getIdentifier(), "via", ItemType.NODE); members.addItem(outEdge.getIdentifier(), "to", ItemType.EDGE); outEdge.reversed().ifPresent(reversed -> members mergeRelationMembers(node.relations(), relationIdentifier)))); result.add(FeatureChange.add(CompleteEdge.shallowFrom(outEdge) .withRelationIdentifiers(mergeRelationMembers(outEdge.relations(),
protected void validateNodeToEdgeLocationAccuracy() { for (final Node node : this.atlas.nodes()) { final Location nodeLocation = node.getLocation(); for (final Edge edge : node.outEdges()) { final Location edgeStartLocation = edge.asPolyLine().first(); if (!nodeLocation.equals(edgeStartLocation)) { throw new CoreException( "Edge {} with start location {} does not match with its start Node {} at location: {}", edge.getIdentifier(), edgeStartLocation, edge.start().getIdentifier(), nodeLocation); } } for (final Edge edge : node.inEdges()) { final Location edgeEndLocation = edge.asPolyLine().last(); if (!nodeLocation.equals(edgeEndLocation)) { throw new CoreException( "Edge {} with end location {} does not match with its end Node {} at location: {}", edge.getIdentifier(), edgeEndLocation, edge.end().getIdentifier(), nodeLocation); } } } } }
@Override public String toString() { return "[TemporaryOrderedNode: id = " + this.nodeIdentifier + " (" + this.node.getLocation() + "), offset = " + this.offset + ", occurrence = " + this.occurrenceIndex + "]"; } }
protected void validateNodeToEdgeConnectivity() { for (final Node node : this.atlas.nodes()) { for (final Edge edge : node.inEdges()) { if (edge == null) { throw new CoreException( "Node {} is logically disconnected from some referenced in edge.", node.getIdentifier()); } } for (final Edge edge : node.outEdges()) { if (edge == null) { throw new CoreException("Node {} is logically disconnected from some out edge.", node.getIdentifier()); } } } }
public TemporaryOrderedNode(final Node node, final Ratio offset, final int occurrenceIndex) { this.nodeIdentifier = node.getIdentifier(); this.node = node; this.offset = offset; this.occurrenceIndex = occurrenceIndex; }
/** * Create a shallow copy of a given node. All fields (except the identifier and the geometry) * are left null until updated by a with() call. * * @param node * the {@link Node} to copy * @return the new {@link CompleteNode} */ public static CompleteNode shallowFrom(final Node node) { return new CompleteNode(node.getIdentifier()) .withInitialBounds(node.getLocation().bounds()); }
/** * @return All the {@link Edge}s connected and pointing out of the end {@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> outEdges() { return this.end().outEdges(); }
private Optional<Route> buildHighwayAreaBoundary(final Route boundary) { for (final Edge edge : boundary.end().end().connectedEdges()) { if (canAddEdgeToBoundary(edge, boundary)) { final Route extendedBoundary = boundary.append(edge); if (extendedBoundary.end().end().getLocation() .equals(extendedBoundary.start().start().getLocation())) { return Optional.of(extendedBoundary); } else { return buildHighwayAreaBoundary(extendedBoundary); } } } return Optional.empty(); }
@Test public void testNode() { final Node node1 = this.atlas.node(123); final Node node2 = this.atlas.node(1234); final Node node3 = this.atlas.node(12345); logger.trace(node1.toString()); logger.trace(node2.toString()); logger.trace(node3.toString()); Assert.assertEquals(node1.getLocation(), Location.TEST_6); Assert.assertEquals(node2.getLocation(), Location.TEST_5); Assert.assertEquals(node3.getLocation(), Location.TEST_2); Assert.assertEquals("turning_circle", node1.getTags().get("highway")); Assert.assertEquals("turning_circle", node2.getTags().get("highway")); Assert.assertEquals("turning_circle", node3.getTags().get("highway")); }
final Node source = atlas.node(1); final CompleteNode result = CompleteNode.shallowFrom(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); result.withLocation(Location.CENTER); Assert.assertEquals(Rectangle.forLocated(source.bounds(), Location.CENTER), result.bounds()); final Map<String, String> tags = Maps.hashMap("key", "value"); Assert.assertEquals(outEdgeIdentifiers, result.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); result.withRelationIdentifiers(source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) Assert.assertEquals(Rectangle.forLocated(source.bounds(), Location.COLOSSEUM), result.bounds());
.append(node1.getIdentifier(), node2.getIdentifier()) .toComparison()); bigNodeCandidate.nodeIdentifiers final BigNode bigNode = new BigNode(sourceNode, nodes, Type.DUAL_CARRIAGEWAY); nodes.stream() .forEach(node -> this.bigNodeIdentifiers.add(node.getIdentifier())); return bigNode; if (!this.bigNodeIdentifiers.contains(candidateNode.getIdentifier())) if (candidateNode.connectedEdges().stream() .anyMatch(HighwayTag::isCarNavigableHighway)) this.bigNodeIdentifiers.add(candidateNode.getIdentifier()); return new BigNode(candidateNode);
final Location masterLocation = master.getLocation(); bounds.add(master.bounds());