Search in sources :

Example 6 with RevTree

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());
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 7 with RevTree

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);
}
Also used : OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) File(java.io.File) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 8 with RevTree

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"));
}
Also used : OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) File(java.io.File) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 9 with RevTree

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);
}
Also used : OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) File(java.io.File) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 10 with RevTree

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);
}
Also used : OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) File(java.io.File) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Aggregations

RevTree (org.locationtech.geogig.api.RevTree)214 Test (org.junit.Test)120 ObjectId (org.locationtech.geogig.api.ObjectId)91 NodeRef (org.locationtech.geogig.api.NodeRef)73 Node (org.locationtech.geogig.api.Node)56 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)47 RevCommit (org.locationtech.geogig.api.RevCommit)36 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)29 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)27 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)24 RevObject (org.locationtech.geogig.api.RevObject)21 RevFeature (org.locationtech.geogig.api.RevFeature)18 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)18 Bucket (org.locationtech.geogig.api.Bucket)17 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)17 File (java.io.File)16 Ref (org.locationtech.geogig.api.Ref)16 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)15 GeoGIG (org.locationtech.geogig.api.GeoGIG)14 OSMImportOp (org.locationtech.geogig.osm.internal.OSMImportOp)14