public TemporaryOrderedNode(final Node node, final Ratio offset, final int occurrenceIndex) { this.nodeIdentifier = node.getIdentifier(); this.node = node; this.offset = offset; this.occurrenceIndex = occurrenceIndex; }
private DynamicNode newNode(final Node node) { return new DynamicNode(this, node.getIdentifier()); }
public long endNodeIdentifier() { return attribute(Edge::end).getIdentifier(); }
public long startNodeIdentifier() { return attribute(Edge::start).getIdentifier(); }
@Override public JsonObject geoJsonProperties() { final JsonObject properties = super.geoJsonProperties(); properties.addProperty("startNode", start().getIdentifier()); properties.addProperty("endNode", end().getIdentifier()); return properties; }
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())); }
/** * 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())); }
@Override public String toString() { return "[Edge" + ": id=" + this.getIdentifier() + ", startNode=" + start().getIdentifier() + ", endNode=" + end().getIdentifier() + ", polyLine=" + this.asPolyLine().toWkt() + ", " + tagString() + "]"; } }
public static AtlasPrimitiveLocationItem from(final Node node) { final AtlasPrimitiveLocationItem locationItem = new AtlasPrimitiveLocationItem( node.getIdentifier(), node.getLocation(), node.getTags()); return locationItem; }
@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() + "]"; }
@Override public Node end() { return new DynamicNode(dynamicAtlas(), subEdge().end().getIdentifier()); }
@Override public Node start() { return new DynamicNode(dynamicAtlas(), subEdge().start().getIdentifier()); }
/** * 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()); }
@Override public Node start() { return new MultiNode(multiAtlas(), masteriseNodeIdentifier(this.getSubEdge().start().getIdentifier())); }
@Override public Node end() { return new MultiNode(multiAtlas(), masteriseNodeIdentifier(this.getSubEdge().end().getIdentifier())); }
@Override public String toString() { return "[Node: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", inEdges=" + connectedEdgesIdentifiers(() -> inEdges()) + ", outEdges=" + connectedEdgesIdentifiers(() -> outEdges()) + ", " + tagString() + "]"; }
@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() + "]"; }
private String convertNode(final Node item) { final StringList list = new StringList(); list.add(item.getIdentifier()); list.add(item.getLocation().toCompactString()); list.add(convertTags(item)); return list.join(SEPARATOR); }
@Test public void spatialIndexTest() { final Rectangle ac2Box = Location.TEST_1.boxAround(Distance.ONE_METER); Assert.assertEquals(1, Iterables.size(this.multi.nodesWithin(ac2Box))); Assert.assertEquals(4L, this.multi.nodesWithin(ac2Box).iterator().next().getIdentifier()); Assert.assertEquals(2, Iterables.size(this.multi.edgesIntersecting(ac2Box))); final Iterator<Edge> edgeIterator = this.multi.edgesIntersecting(ac2Box).iterator(); Assert.assertEquals(6, edgeIterator.next().getIdentifier()); Assert.assertEquals(5, edgeIterator.next().getIdentifier()); Assert.assertFalse(edgeIterator.hasNext()); }
@Test public void addTurnRestrictions() { resetAndChange("addTurnRestrictions", new AtlasChangeGeneratorAddTurnRestrictions()); final Node via = this.changeAtlas.node(3985226613000000L); final Relation restriction = via.relations().iterator().next(); Assert.assertNotNull(restriction); final RelationBean members = new RelationBean(); members.addItem(221434099000002L, "from", ItemType.EDGE); members.addItem(via.getIdentifier(), "via", ItemType.NODE); members.addItem(634444999000000L, "to", ItemType.EDGE); members.addItem(-634444999000000L, "to", ItemType.EDGE); Assert.assertEquals(members, restriction.members().asBean()); }