Search in sources :

Example 41 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class WriteTree2Test method feature.

private Node feature(ObjectDatabase db, String idPrefix, int index) {
    final String id = idPrefix + "." + index;
    final Feature feature;
    try {
        feature = super.feature(pointsType, id, id, index, point(index));
    } catch (ParseException e) {
        throw Throwables.propagate(e);
    }
    RevFeature revFeature = RevFeatureBuilder.build(feature);
    db.put(revFeature);
    Envelope bounds = (Envelope) feature.getBounds();
    return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds);
}
Also used : RevFeature(org.locationtech.geogig.api.RevFeature) ParseException(com.vividsolutions.jts.io.ParseException) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature)

Example 42 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testModifiedSameFeatureIncompatible.

@Test
public void testModifiedSameFeatureIncompatible() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1Modified);
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1ModifiedB);
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(1, conflicts.getConflicts().size());
    assertEquals(0, conflicts.getUnconflicted().size());
    Boolean hasConflicts = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertTrue(hasConflicts.booleanValue());
}
Also used : ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 43 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ResetOpTest method testResetPathToHeadVersionFixesConflict.

@Test
public void testResetPathToHeadVersionFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    insertAndAdd(points1Modified);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    insertAndAdd(points1ModifiedB);
    insertAndAdd(points2);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
    try {
        geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(ResetOp.class).addPattern(pointsName + "/" + idP1).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
}
Also used : Ref(org.locationtech.geogig.api.Ref) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 44 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ResetOpTest method testResetPathFixesConflict.

@Test
public void testResetPathFixesConflict() throws Exception {
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insertAndAdd(points1);
    RevCommit resetCommit = geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    insertAndAdd(points1Modified);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    insertAndAdd(points1ModifiedB);
    insertAndAdd(points2);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
    try {
        geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
        fail();
    } catch (MergeConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(ResetOp.class).addPattern(pointsName + "/" + idP1).setCommit(Suppliers.ofInstance(resetCommit.getId())).call();
    List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
    assertTrue(conflicts.isEmpty());
}
Also used : Ref(org.locationtech.geogig.api.Ref) MergeConflictsException(org.locationtech.geogig.api.porcelain.MergeConflictsException) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) ResetOp(org.locationtech.geogig.api.porcelain.ResetOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 45 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class RepositoryTestCase method populate.

protected List<RevCommit> populate(boolean oneCommitPerFeature, List<Feature> features) throws Exception {
    List<RevCommit> commits = new ArrayList<RevCommit>();
    for (Feature f : features) {
        insertAndAdd(f);
        if (oneCommitPerFeature) {
            RevCommit commit = geogig.command(CommitOp.class).call();
            commits.add(commit);
        }
    }
    if (!oneCommitPerFeature) {
        RevCommit commit = geogig.command(CommitOp.class).call();
        commits.add(commit);
    }
    return commits;
}
Also used : ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit)

Aggregations

Feature (org.opengis.feature.Feature)128 Test (org.junit.Test)90 RevCommit (org.locationtech.geogig.api.RevCommit)52 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)43 SimpleFeature (org.opengis.feature.simple.SimpleFeature)38 ObjectId (org.locationtech.geogig.api.ObjectId)35 RevFeature (org.locationtech.geogig.api.RevFeature)32 NodeRef (org.locationtech.geogig.api.NodeRef)29 LinkedList (java.util.LinkedList)27 LogOp (org.locationtech.geogig.api.porcelain.LogOp)23 Ref (org.locationtech.geogig.api.Ref)21 RefParse (org.locationtech.geogig.api.plumbing.RefParse)19 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)18 ArrayList (java.util.ArrayList)16 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)16 RevObject (org.locationtech.geogig.api.RevObject)16 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Function (com.google.common.base.Function)13 Optional (com.google.common.base.Optional)12 HashMap (java.util.HashMap)12