use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class MergeOpTest method testMergeFastForward.
@Test
public void testMergeFastForward() throws Exception {
// Create the following revision graph
// o
// |
// o - master - HEAD - Points 1 added
// .\
// . o - branch1 - Points 2 added
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
// checkout master
geogig.command(CheckoutOp.class).setSource("master").call();
// Merge branch1 into master to create the following revision graph
// o
// |
// o - Points 1 added
// |
// o - master - HEAD - branch1 - Points 2 added
Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
final MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).call();
RevTree mergedTree = repo.getTree(mergeReport.getMergeCommit().getTreeId());
String path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(pointsName, points2.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// Commit 2
RevCommit logC2 = log.next();
assertEquals(c2.getAuthor(), logC2.getAuthor());
assertEquals(c2.getCommitter(), logC2.getCommitter());
assertEquals(c2.getMessage(), logC2.getMessage());
assertEquals(c2.getTreeId(), logC2.getTreeId());
// Commit 1
RevCommit logC1 = log.next();
assertEquals(c1.getAuthor(), logC1.getAuthor());
assertEquals(c1.getCommitter(), logC1.getCommitter());
assertEquals(c1.getMessage(), logC1.getMessage());
assertEquals(c1.getTreeId(), logC1.getTreeId());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportSLTest method testExportWithMapping.
@Test
public void testExportWithMapping() throws Exception {
String filename = OSMImportOp.class.getResource("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("mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.sqlite");
cli.execute("osm", "export-sl", "--database", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertTrue(exportFile.exists());
cli.execute("sl", "import", "-t", "onewaystreets", "--database", exportFile.getAbsolutePath());
long unstaged = cli.getGeogig().getRepository().workingTree().countUnstaged("onewaystreets").count();
assertTrue(unstaged > 0);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportShpTest method testExportToShapefileWithMappingWithoutGeometry.
@Test
public void testExportToShapefileWithMappingWithoutGeometry() throws Exception {
String filename = OSMImportOp.class.getResource("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("no_geometry_mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.shp");
cli.execute("osm", "export-shp", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertNotNull(cli.exception);
assertTrue(cli.exception.getMessage().startsWith("The mapping rule does not define a geometry field"));
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportShpTest method testExportToShapefileWithMapping.
@Test
public void testExportToShapefileWithMapping() throws Exception {
String filename = OSMImportOp.class.getResource("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("mapping.json").getFile();
File mappingFile = new File(mappingFilename);
File exportFile = new File(tempFolder.getRoot(), "export.shp");
cli.execute("osm", "export-shp", exportFile.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
assertTrue(exportFile.exists());
cli.execute("shp", "import", "-d", "mapped", exportFile.getAbsolutePath());
long unstaged = cli.getGeogig().getRepository().workingTree().countUnstaged("mapped").count();
assertTrue(unstaged > 0);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class OSMExportTest method testExportFromWorkingHead.
@Test
public void testExportFromWorkingHead() throws Exception {
String filename = OSMImportOp.class.getResource("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);
File exportFile = new File(tempFolder.getRoot(), "export.xml");
cli.execute("osm", "export", exportFile.getAbsolutePath(), "WORK_HEAD");
cli.execute("rm", "-r", "node");
cli.execute("rm", "-r", "way");
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("WORK_HEAD:node").call(RevTree.class);
assertFalse(tree.isPresent());
tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("WORK_HEAD:way").call(RevTree.class);
assertFalse(tree.isPresent());
cli.execute("osm", "import", exportFile.getAbsolutePath());
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);
}
Aggregations