use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffTreeTest method testMixedFilters.
/**
* Apply path, bounds, and changeType filtering all at once
*/
@Test
public void testMixedFilters() {
ObjectDatabase db = geogit.getContext().objectDatabase();
final RevTree tree1 = tree(1000, db);
final RevTree tree2 = tree(50, db);
final RevTree tree2Changed;
{
RevTreeBuilder builder = new RevTreeBuilder(db, tree2);
// add 10 changed features, and delete 10 more
for (int i = 0; i < 20; i++) {
if (i % 2 == 0) {
builder.remove(String.valueOf(i));
} else {
builder.put(feature(i, ObjectId.forString("changed" + i)));
}
}
tree2Changed = builder.build();
db.put(tree2Changed);
assertEquals(tree2.size() - 10, tree2Changed.size());
}
final RevTree root1 = createRoot(db, tree1, tree2);
final RevTree root2 = createRoot(db, tree1, tree2Changed);
final ObjectId rootId1 = root1.getId();
final ObjectId rootId2 = root2.getId();
CoordinateReferenceSystem crs = revtype.type().getCoordinateReferenceSystem();
// boundsFilter covers features 1-11
ReferencedEnvelope boundsFilter = new ReferencedEnvelope(1.9, 11.1, 1.9, 11.1, crs);
// first try with bounds only
diffTree.setBoundsFilter(boundsFilter);
assertEquals(10, Iterators.size(diffTree.setOldTree(rootId1).setNewTree(rootId2).call()));
assertChangeTypeFilter(rootId1, rootId2, 0, 5, 5);
assertChangeTypeFilter(rootId2, rootId1, 5, 0, 5);
// now add path filtering
diffTree.setPathFilter("tree1");
assertChangeTypeFilter(rootId1, rootId2, 0, 0, 0);
assertChangeTypeFilter(rootId2, rootId1, 0, 0, 0);
diffTree.setPathFilter("tree2");
assertChangeTypeFilter(rootId1, rootId2, 0, 5, 5);
assertChangeTypeFilter(rootId2, rootId1, 5, 0, 5);
// odd feature ids from 0 to 18 were removed from tree2
// tree2/0 and tree2/12 match path filter but don't match bounds filter
diffTree.setPathFilter(ImmutableList.of("tree2/0", "tree2/2", "tree2/4", "tree2/12"));
diffTree.setBoundsFilter(null);
assertChangeTypeFilter(rootId1, rootId2, 0, 4, 0);
assertChangeTypeFilter(rootId2, rootId1, 4, 0, 0);
diffTree.setBoundsFilter(boundsFilter);
assertChangeTypeFilter(rootId1, rootId2, 0, 2, 0);
assertChangeTypeFilter(rootId2, rootId1, 2, 0, 0);
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffTreeTest method createRoot.
private RevTree createRoot(ObjectDatabase db, final RevTree tree1, final RevTree tree2) {
RevTreeBuilder rootBuilder = new RevTreeBuilder(db);
rootBuilder.put(Node.create("tree1", tree1.getId(), metadataId, TYPE.TREE, SpatialOps.boundsOf(tree1)));
rootBuilder.put(Node.create("tree2", tree2.getId(), metadataId, TYPE.TREE, SpatialOps.boundsOf(tree2)));
RevTree root = rootBuilder.build();
db.put(root);
return root;
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class WriteBackTest method testSimple.
@Test
public void testSimple() {
RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
RevTree tree = new RevTreeBuilder(odb).put(blob("blob")).build();
ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("subtree").setTree(tree).call();
Optional<NodeRef> ref = new DepthSearch(odb).find(newRootId, "subtree");
assertTrue(ref.isPresent());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class WriteBackTest method testSingleNested.
@Test
public void testSingleNested() {
RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
RevTree tree = new RevTreeBuilder(odb).put(blob("blob")).build();
ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("level1/level2").setTree(tree).call();
// created the intermediate tree node?
Optional<NodeRef> ref;
DepthSearch depthSearch = new DepthSearch(odb);
ref = depthSearch.find(newRootId, "level1");
assertTrue(ref.isPresent());
ref = depthSearch.find(newRootId, "level1/level2");
assertTrue(ref.isPresent());
ref = depthSearch.find(newRootId, "level1/level2/blob");
assertTrue(ref.isPresent());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class WriteBackTest method testSingleLevel.
@Test
public void testSingleLevel() {
RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
RevTree tree = new RevTreeBuilder(odb).put(blob("blob")).build();
ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("level1").setTree(tree).call();
// created the intermediate tree node?
Optional<NodeRef> ref;
DepthSearch depthSearch = new DepthSearch(odb);
ref = depthSearch.find(newRootId, "level1");
assertTrue(ref.isPresent());
ref = depthSearch.find(newRootId, "level1/blob");
assertTrue(ref.isPresent());
}
Aggregations