@Override public Map<String, String> getTags() { return subNode().getTags(); }
@Override public Map<String, String> getTags() { return getRepresentativeSubNode().getTags(); }
/** * Print a warning for nodes that have the same location but different tags. * * @param master * The master node * @param slaves * The slave nodes */ private void warnIfNodesHaveDifferentTags(final Node master, final Set<Node> slaves) { final Node origin = master; final Map<String, String> tags = master.getTags(); for (final Node node : slaves) { if (!tags.equals(node.getTags())) { logger.warn("Nodes overlap but have different tags: {} and {}", origin.getIdentifier(), node.getIdentifier()); } } } }
/** * 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())); }
public static AtlasPrimitiveLocationItem from(final Node node) { final AtlasPrimitiveLocationItem locationItem = new AtlasPrimitiveLocationItem( node.getIdentifier(), node.getLocation(), node.getTags()); return locationItem; }
/** * @return an {@link Atlas} made up of {@link Node}s and {@link Edge}s comprising this * {@link BigNode}, in order to run routing algorithms on it. */ private Atlas buildBigNodeAtlas() { final Set<Edge> edges = edges(); final Set<Node> extendedNodes = new HashSet<>(); edges.forEach(edge -> { extendedNodes.add(edge.start()); extendedNodes.add(edge.end()); }); final PackedAtlasBuilder builder = new PackedAtlasBuilder() .withSizeEstimates(new AtlasSize(edges.size(), extendedNodes.size(), 0, 0, 0, 0)); extendedNodes.forEach( node -> builder.addNode(node.getIdentifier(), node.getLocation(), node.getTags())); edges.forEach( edge -> builder.addEdge(edge.getIdentifier(), edge.asPolyLine(), edge.getTags())); return builder.get(); }
fixBuilder.addNode(nodeEntry.getKey(), node.getLocation(), node.getTags());
@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")); }
node -> builder.addNode(node.getIdentifier(), node.getLocation(), node.getTags())); atlas.edges().forEach( edge -> builder.addEdge(edge.getIdentifier(), edge.asPolyLine(), edge.getTags()));
@Test public void testFull() { final Atlas atlas = this.rule.getAtlas(); final Node source = atlas.node(1); final CompleteNode result = CompleteNode.from(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.getLocation(), result.getLocation()); Assert.assertEquals( source.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), result.inEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); Assert.assertEquals( source.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new)), result.outEdges().stream().map(Edge::getIdentifier) .collect(Collectors.toCollection(TreeSet::new))); Assert.assertEquals(source.getTags(), result.getTags()); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); }
private void writeNodesToBuilder(final Atlas atlas, final ProtoAtlas.Builder protoAtlasBuilder) { long numberOfNodes = 0; for (final Node node : atlas.nodes()) { final ProtoNode.Builder protoNodeBuilder = ProtoNode.newBuilder(); protoNodeBuilder.setId(node.getIdentifier()); protoNodeBuilder.setLocation( ProtoAtlasBuilder.PROTOLOCATION_CONVERTER.backwardConvert(node.getLocation())); final Map<String, String> tags = node.getTags(); protoNodeBuilder .addAllTags(ProtoAtlasBuilder.PROTOTAG_LIST_CONVERTER.backwardConvert(tags)); numberOfNodes++; protoAtlasBuilder.addNodes(protoNodeBuilder.build()); } protoAtlasBuilder.setNumberOfNodes(numberOfNodes); }
final Map<String, String> nodeTags = node.getTags(); Assert.assertTrue(getField(deserialized, PackedAtlas.FIELD_NODE_TAGS) != null); logger.info("Got Node tags {}", nodeTags);
if (builder.peek().node(nodeIdentifier) == null) builder.addNode(nodeIdentifier, node.getLocation(), node.getTags());