use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class PostOrderDiffWalkTest method testSameChildTree.
@Test
public void testSameChildTree() {
RevTree left = createFeaturesTree(leftSource, "f", 10).build();
RevTree right = left;
PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
Consumer consumer = mock(Consumer.class);
visitor.walk(consumer);
verifyNoMoreInteractions(consumer);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class RevTreeBuilderTest method testNodeOrderPassSplitThreshold.
@Test
public void testNodeOrderPassSplitThreshold() {
final int splitThreshold = RevTree.NORMALIZED_SIZE_LIMIT;
List<Node> expectedOrder = nodes(splitThreshold + 1);
Collections.sort(expectedOrder, new NodeStorageOrder());
final List<Node> flat = expectedOrder.subList(0, splitThreshold);
RevTreeBuilder flatTreeBuilder = new RevTreeBuilder(odb);
RevTreeBuilder bucketTreeBuilder = new RevTreeBuilder(odb);
for (Node n : flat) {
flatTreeBuilder.put(n);
bucketTreeBuilder.put(n);
}
bucketTreeBuilder.put(expectedOrder.get(expectedOrder.size() - 1));
RevTree flatTree = flatTreeBuilder.build();
RevTree bucketTree = bucketTreeBuilder.build();
assertFalse(flatTree.buckets().isPresent());
assertTrue(bucketTree.buckets().isPresent());
odb.put(flatTree);
odb.put(bucketTree);
List<Node> flatNodes = lstree(flatTree);
assertEquals(flat, flatNodes);
List<Node> splitNodes = lstree(bucketTree);
assertEquals(expectedOrder, splitNodes);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class ImportOpTest method testImportTable.
@Test
public void testImportTable() throws Exception {
ImportOp importOp = geogig.command(ImportOp.class);
importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
importOp.setAll(false);
importOp.setTable("table1");
RevTree newWorkingTree = importOp.call();
Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature1").setIndex(true).call();
assertTrue(ref.isPresent());
ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature2").setIndex(true).call();
assertTrue(ref.isPresent());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class ImportOpTest method testImportAll.
@Test
public void testImportAll() throws Exception {
ImportOp importOp = geogig.command(ImportOp.class);
importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
importOp.setAll(true);
RevTree newWorkingTree = importOp.call();
Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature1").setIndex(true).call();
assertTrue(ref.isPresent());
ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature2").setIndex(true).call();
assertTrue(ref.isPresent());
ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table2/feature3").setIndex(true).call();
assertTrue(ref.isPresent());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMMapTest method testMappingWithPolygons.
@Test
public void testMappingWithPolygons() throws Exception {
// test a mapping with a a mapping rule that uses the polygon geometry type
String filename = OSMImportOp.class.getResource("closed_ways.xml").getFile();
File file = new File(filename);
cli.execute("osm", "import", file.getAbsolutePath());
cli.execute("add");
cli.execute("commit", "-m", "message");
Optional<RevTree> tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:node").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
String mappingFilename = OSMMap.class.getResource("polygons_mapping.json").getFile();
File mappingFile = new File(mappingFilename);
cli.execute("osm", "map", mappingFile.getAbsolutePath());
Iterator<NodeRef> iter = cli.getGeogig().command(LsTreeOp.class).setReference("HEAD:areas").call();
assertTrue(iter.hasNext());
Optional<RevFeatureType> ft = cli.getGeogig().command(ResolveFeatureType.class).setRefSpec("HEAD:" + iter.next().path()).call();
assertTrue(ft.isPresent());
assertEquals(Polygon.class, ft.get().sortedDescriptors().get(1).getType().getBinding());
}
Aggregations