/** * Creates a new {@code NodeRef} with the updated {@link ObjectId} and {@link Envelope}. * * @param newId the updated {@link ObjectId} * @param newBounds the updated bounds * @return the newly created {@code NodeRef} */ public NodeRef update(final ObjectId newId, final @Nullable Envelope newBounds) { Node newNode = node.update(newId, newBounds); return NodeRef.create(parentPath, newNode, metadataId); }
@Test public void testHashCode() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef = NodeRef.create("Points", node); Node node2 = RevObjectFactory.defaultInstance().createNode("Lines.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0001"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef2 = new NodeRef(node2, "Lines", ObjectId.NULL); assertNotSame(nodeRef.hashCode(), nodeRef2.hashCode()); Node node3 = RevObjectFactory.defaultInstance().createNode(NodeRef.ROOT, ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef root = NodeRef.createRoot(node3); root.hashCode(); }
/** * Creates a new {@code NodeRef} with the updated {@link ObjectId} and {@link Envelope}. * * @param newId the updated {@link ObjectId} * @param newBounds the updated bounds * @return the newly created {@code NodeRef} */ public NodeRef update(final ObjectId newId, final @Nullable Envelope newBounds) { Node newNode = node.update(newId, newBounds); return NodeRef.create(parentPath, newNode, metadataId); }
private NodeRef newRef(NodeRef parent, Node lnode) { return NodeRef.create(parent.path(), lnode, parent.getMetadataId()); }
private NodeRef newRef(NodeRef parent, Node lnode) { return NodeRef.create(parent.path(), lnode, parent.getMetadataId()); }
private NodeRef featureNodeRef(String namePrefix, int index) { boolean randomIds = false; return NodeRef.create(NodeRef.ROOT, RevObjectTestSupport.featureNode(namePrefix, index, randomIds)); }
private NodeRef featureNodeRef(String namePrefix, int index) { boolean randomIds = false; return NodeRef.create(NodeRef.ROOT, RevObjectTestSupport.featureNode(namePrefix, index, randomIds)); }
private NodeRef featureNodeRef(String namePrefix, int index) { boolean randomIds = false; return NodeRef.create(NodeRef.ROOT, RevObjectTestSupport.featureNode(namePrefix, index, randomIds)); }
public static NodeRef featureNodeRef(String namePrefix, int index) { Node node = RevObjectTestSupport.featureNode(namePrefix, index, false); return NodeRef.create(NodeRef.ROOT, node); }
public static NodeRef featureNodeRef(String namePrefix, int index) { Node node = RevObjectTestSupport.featureNode(namePrefix, index, false); return NodeRef.create(NodeRef.ROOT, node); }
/** * Constructs a new {@code NodeRef} that points to the tree with the provided parameters. * * @param treePath the path of the tree * @param id the {@link ObjectId} of the tree * @param metadataId the metadata id of the tree * @return the newly constructed {@code NodeRef} */ public static NodeRef tree(String treePath, ObjectId id, ObjectId metadataId) { NodeRef.checkValidPath(treePath); checkNotNull(id); checkNotNull(metadataId); String parentPath = NodeRef.parentPath(treePath); String treeName = NodeRef.nodeFromPath(treePath); Node treeNode = Node.tree(treeName, id, metadataId); return NodeRef.create(parentPath, treeNode); } }
/** * Constructs a new {@code NodeRef} that points to the tree with the provided parameters. * * @param treePath the path of the tree * @param id the {@link ObjectId} of the tree * @param metadataId the metadata id of the tree * @return the newly constructed {@code NodeRef} */ public static NodeRef tree(String treePath, ObjectId id, ObjectId metadataId) { NodeRef.checkValidPath(treePath); checkNotNull(id); checkNotNull(metadataId); String parentPath = NodeRef.parentPath(treePath); String treeName = NodeRef.nodeFromPath(treePath); Node treeNode = RevObjectFactory.defaultInstance().createNode(treeName, id, metadataId, TYPE.TREE, null, null); return NodeRef.create(parentPath, treeNode); } }
private List<NodeRef> toNodeRef(List<Node> trees, String parentPath) { List<NodeRef> refs = new ArrayList<>(); for (Node treeNode : trees) { Optional<ObjectId> metadataId = treeNode.getMetadataId(); if (metadataId.isPresent()) { refs.add(NodeRef.create(parentPath, treeNode)); } else { // nested parent if (!treeNode.getObjectId().equals(RevTree.EMPTY_TREE_ID)) { String path = NodeRef.appendChild(parentPath, treeNode.getName()); RevTree subtree = source.getTree(treeNode.getObjectId()); List<NodeRef> subTrees = getSubTrees(subtree, path); refs.addAll(subTrees); } } } return refs; }
private void testGetFeatures(final Iterable<Node> nodes, final int expectedSize) { CountingListener listener = BulkOpListener.newCountingListener(); Stopwatch sw = Stopwatch.createStarted(); Iterator<NodeRef> refs = Iterators.transform(nodes.iterator(), (n) -> NodeRef.create("layer", n)); Iterator<ObjectInfo<RevFeature>> iterator = db.getObjects(refs, listener, RevFeature.class); final int returnedObjectCount = Iterators.size(iterator); sw.stop(); System.err.printf("----- %,d Features queried (%,d not found) with getObjects() in %,dms\n", listener.found(), listener.notFound(), sw.elapsed(TimeUnit.MILLISECONDS)); System.err.printf("----- %s\n", sharedCache); Assert.assertEquals(listener.toString(), expectedSize, listener.found()); assertEquals(expectedSize, returnedObjectCount); }
private NodeRef nodeRef(SimpleFeature f, String... extraAttributes) { Map<String, Object> extraData = new HashMap<>(); Map<String, Object> extraAtts = new HashMap<>(); if (extraAttributes != null) { for (String name : extraAttributes) { extraAtts.put(name, f.getAttribute(name)); } } extraData.put(IndexInfo.FEATURE_ATTRIBUTES_EXTRA_DATA, extraAtts); ObjectId id = RevFeatureBuilder.build(f).getId(); Envelope bounds = (Envelope) f.getBounds(); Node node = Node.create(f.getID(), id, ObjectId.NULL, TYPE.FEATURE, bounds, extraData); String typeName = f.getType().getTypeName(); NodeRef nodeRef = NodeRef.create(typeName, node); return nodeRef; }
private DiffEntry entry(String name, RevFeature l, RevFeature r) { //@formatter:off Node lnode = l == null? null: RevObjectFactory.defaultInstance().createNode(name, l.getId(), ObjectId.NULL, TYPE.FEATURE, SpatialOps.boundsOf(l), null); Node rnode = r == null? null: RevObjectFactory.defaultInstance().createNode(name, r.getId(), ObjectId.NULL, TYPE.FEATURE, SpatialOps.boundsOf(r), null); //@formatter:on NodeRef oldObject = lnode == null ? null : NodeRef.create(NodeRef.ROOT, lnode); NodeRef newObject = rnode == null ? null : NodeRef.create(NodeRef.ROOT, rnode); return new DiffEntry(oldObject, newObject); }
private NodeRef nodeRef(SimpleFeature f, String... extraAttributes) { Map<String, Object> extraData = new HashMap<>(); Map<String, Object> extraAtts = new HashMap<>(); if (extraAttributes != null) { for (String name : extraAttributes) { extraAtts.put(name, f.getAttribute(name)); } } extraData.put(IndexInfo.FEATURE_ATTRIBUTES_EXTRA_DATA, extraAtts); ObjectId id = RevFeature.builder().build(f).getId(); Envelope bounds = (Envelope) f.getBounds(); Node node = RevObjectFactory.defaultInstance().createNode(f.getID(), id, ObjectId.NULL, TYPE.FEATURE, bounds, extraData); String typeName = f.getType().getTypeName(); NodeRef nodeRef = NodeRef.create(typeName, node); return nodeRef; }
@Test public void testExpand() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, new Envelope(0, 1, 2, 3), null); NodeRef nodeRef = NodeRef.create("Points", node); Envelope env = new Envelope(1, 3, 1, 2); nodeRef.expand(env); assertEquals(new Envelope(0, 3, 1, 3), env); } }
@Test public void testIntersects() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, new Envelope(0, 1, 2, 3), null); NodeRef nodeRef = NodeRef.create("Points", node); assertTrue(nodeRef.intersects(new Envelope(0, 0.5, 2, 2.5))); assertFalse(nodeRef.intersects(new Envelope(2, 3, 2, 3))); }
@Test public void testCompareTo() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef = NodeRef.create("Points", node); assertFalse(nodeRef.equals(node)); Node node2 = RevObjectFactory.defaultInstance().createNode("Lines.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0001"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef2 = new NodeRef(node2, "Lines", ObjectId.NULL); assertTrue(nodeRef.compareTo(nodeRef2) > 0); assertTrue(nodeRef2.compareTo(nodeRef) < 0); assertTrue(nodeRef.compareTo(nodeRef) == 0); }