Search in sources :

Example 6 with Feature

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

the class GeogigAPITest method testGetFeatureFromWorkingTree.

@Test
public void testGetFeatureFromWorkingTree() throws Exception {
    insert(points1);
    Feature feature = geogigAPI.getFeatureFromWorkingTree(NodeRef.appendChild(pointsName, idP1));
    assertNotNull(feature);
}
Also used : Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 7 with Feature

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

the class MergeOpTest method testMergeWithFeatureMerge.

@Test
public void testMergeWithFeatureMerge() throws Exception {
    // Create the following revision graph
    // o
    // |
    // o - Points 1 added
    // |\
    // | o - TestBranch - Points 1 modified and points 2 added
    // |
    // o - master - HEAD - Points 1 modifiedB
    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);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_1", new Integer(2000), "POINT(1 1)");
    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();
    geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
    String path = appendChild(pointsName, points1.getIdentifier().getID());
    Optional<RevFeature> feature = repo.command(RevObjectParse.class).setRefSpec(/*
                             * mergeCommit. getId ().toString () + ":" +
                             */
    "WORK_HEAD" + ":" + path).call(RevFeature.class);
    assertTrue(feature.isPresent());
    Feature mergedFeature = feature(pointsType, idP1, "StringProp1_2", new Integer(2000), "POINT(1 1)");
    RevFeature expected = RevFeatureBuilder.build(mergedFeature);
    assertEquals(expected, feature.get());
}
Also used : 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) RevFeature(org.locationtech.geogig.api.RevFeature) RefParse(org.locationtech.geogig.api.plumbing.RefParse) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 8 with Feature

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

the class LogOpTest method testPathFilterSingleFeature.

@Test
public void testPathFilterSingleFeature() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    List<RevCommit> allCommits = Lists.newArrayList();
    RevCommit expectedCommit = null;
    for (Feature f : features) {
        insertAndAdd(f);
        String id = f.getIdentifier().getID();
        final RevCommit commit = geogig.command(CommitOp.class).call();
        if (id.equals(lines1.getIdentifier().getID())) {
            expectedCommit = commit;
        }
        allCommits.add(commit);
    }
    String path = NodeRef.appendChild(linesName, lines1.getIdentifier().getID());
    List<RevCommit> feature2_1Commits = toList(logOp.addPath(path).call());
    assertEquals(1, feature2_1Commits.size());
    assertEquals(Collections.singletonList(expectedCommit), feature2_1Commits);
}
Also used : CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 9 with Feature

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

the class LogOpTest method testSkip.

@Test
public void testSkip() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    for (Feature f : features) {
        insertAndAdd(f);
        geogig.command(CommitOp.class).call();
    }
    logOp.setSkip(2).call();
    exception.expect(IllegalArgumentException.class);
    logOp.setSkip(-1).call();
}
Also used : CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) Test(org.junit.Test)

Example 10 with Feature

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

the class LogOpTest method testTemporalConstraint.

@Test
public void testTemporalConstraint() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    List<Long> timestamps = Arrays.asList(Long.valueOf(1000), Long.valueOf(2000), Long.valueOf(3000), Long.valueOf(4000), Long.valueOf(5000), Long.valueOf(6000));
    LinkedList<RevCommit> allCommits = new LinkedList<RevCommit>();
    for (int i = 0; i < features.size(); i++) {
        Feature f = features.get(i);
        Long timestamp = timestamps.get(i);
        insertAndAdd(f);
        final RevCommit commit = geogig.command(CommitOp.class).setCommitterTimestamp(timestamp).call();
        allCommits.addFirst(commit);
    }
    // test time range exclusive
    boolean minInclusive = false;
    boolean maxInclusive = false;
    Range<Date> commitRange = new Range<Date>(Date.class, new Date(2000), minInclusive, new Date(5000), maxInclusive);
    logOp.setTimeRange(commitRange);
    List<RevCommit> logged = toList(logOp.call());
    List<RevCommit> expected = allCommits.subList(2, 4);
    assertEquals(expected, logged);
    // test time range inclusive
    minInclusive = true;
    maxInclusive = true;
    commitRange = new Range<Date>(Date.class, new Date(2000), minInclusive, new Date(5000), maxInclusive);
    logOp = geogig.command(LogOp.class).setTimeRange(commitRange);
    logged = toList(logOp.call());
    expected = allCommits.subList(1, 5);
    assertEquals(expected, logged);
    // test reset time range
    logOp = geogig.command(LogOp.class).setTimeRange(commitRange).setTimeRange(null);
    logged = toList(logOp.call());
    expected = allCommits;
    assertEquals(expected, logged);
}
Also used : LogOp(org.locationtech.geogig.api.porcelain.LogOp) Range(org.geotools.util.Range) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Date(java.util.Date) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

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