Search in sources :

Example 96 with Feature

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

the class HashObjectTest method setUpInternal.

@Override
protected void setUpInternal() throws Exception {
    featureType1 = RevFeatureTypeImpl.build(pointsType);
    featureType2 = RevFeatureTypeImpl.build(linesType);
    featureType1Duplicate = RevFeatureTypeImpl.build(pointsType);
    pointFeature1 = RevFeatureBuilder.build(points1);
    pointFeature2 = RevFeatureBuilder.build(points2);
    pointFeature1Duplicate = RevFeatureBuilder.build(points1);
    CommitBuilder b = new CommitBuilder();
    b.setAuthor("groldan");
    b.setAuthorEmail("groldan@boundlessgeo.com");
    b.setCommitter("jdeolive");
    b.setCommitterEmail("jdeolive@boundlessgeo.com");
    b.setMessage("cool this works");
    b.setCommitterTimestamp(1000);
    b.setCommitterTimeZoneOffset(5);
    ObjectId treeId = ObjectId.forString("fake tree content");
    b.setTreeId(treeId);
    ObjectId parentId1 = ObjectId.forString("fake parent content 1");
    ObjectId parentId2 = ObjectId.forString("fake parent content 2");
    List<ObjectId> parentIds = ImmutableList.of(parentId1, parentId2);
    b.setParentIds(parentIds);
    commit1 = b.build();
    commit1Duplicate = b.build();
    b.setMessage(null);
    b.setAuthor(null);
    b.setAuthorEmail(null);
    b.setCommitterTimestamp(-1000);
    b.setCommitterTimeZoneOffset(-5);
    b.setParentIds(ImmutableList.of(parentId1, ObjectId.NULL));
    commit2 = b.build();
    Object boolArray = new boolean[] { true, false, true, true, false };
    Object byteArray = new byte[] { 100, 127, -110, 26, 42 };
    Object charArray = new char[] { 'a', 'b', 'c', 'd', 'e' };
    Object doubleArray = new double[] { 1.5, 1.6, 1.7, 1.8 };
    Object floatArray = new float[] { 1.1f, 3.14f, 6.0f, 0.0f };
    Object intArray = new int[] { 5, 7, 9, 11, 32 };
    Object longArray = new long[] { 100, 200, 300, 400 };
    TestSerializableObject serializableObject = new TestSerializableObject();
    serializableObject.words = "words to serialize";
    SimpleFeatureType coverageFeatureType = DataUtilities.createType("http://geoserver.org/test", "TestType", "str:String," + "str2:String," + "bool:Boolean," + "byte:java.lang.Byte," + "doub:Double," + "bdec:java.math.BigDecimal," + "flt:Float," + "int:Integer," + "bint:java.math.BigInteger," + "boolArray:java.lang.Object," + "byteArray:java.lang.Object," + "charArray:java.lang.Object," + "doubleArray:java.lang.Object," + "floatArray:java.lang.Object," + "intArray:java.lang.Object," + "longArray:java.lang.Object," + "serialized:java.io.Serializable," + "randomClass:java.lang.Object," + "pp:Point:srid=4326," + "lng:java.lang.Long," + "uuid:java.util.UUID");
    coverageRevFeatureType = RevFeatureTypeImpl.build(coverageFeatureType);
    Feature coverageFeature = feature(coverageFeatureType, "TestType.Coverage.1", "StringProp1_1", null, Boolean.TRUE, Byte.valueOf("18"), new Double(100.01), new BigDecimal("1.89e1021"), new Float(12.5), new Integer(1000), new BigInteger("90000000"), boolArray, byteArray, charArray, doubleArray, floatArray, intArray, longArray, serializableObject, new SomeRandomClass(), "POINT(1 1)", new Long(800000), UUID.fromString("bd882d24-0fe9-11e1-a736-03b3c0d0d06d"));
    coverageRevFeature = RevFeatureBuilder.build(coverageFeature);
    hashCommand = new HashObject();
    Context mockCommandLocator = mock(Context.class);
    hashCommand.setContext(mockCommandLocator);
    when(mockCommandLocator.command(eq(DescribeFeatureType.class))).thenReturn(new DescribeFeatureType());
}
Also used : Context(org.locationtech.geogig.api.Context) ObjectId(org.locationtech.geogig.api.ObjectId) CommitBuilder(org.locationtech.geogig.api.CommitBuilder) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature) BigDecimal(java.math.BigDecimal) BigInteger(java.math.BigInteger) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) BigInteger(java.math.BigInteger)

Example 97 with Feature

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

the class DiffBoundsTest method setUpInternal.

@Override
protected void setUpInternal() throws Exception {
    // create one commit per feature
    ArrayList<RevCommit> commits = Lists.newArrayList(populate(true, points1, points3, points1_modified));
    this.points1_modified_commit = commits.get(2);
    Feature p1ModifiedAgain = feature(pointsType, idP1, "StringProp1_1a", new Integer(1001), // used to be POINT(1 2)
    "POINT(10 20)");
    insertAndAdd(p1ModifiedAgain);
    commits.add(geogig.command(CommitOp.class).call());
    points1B_modified = feature(pointsType, idP1, "StringProp1B_1a", new Integer(2000), "POINT(10 220)");
    insertAndAdd(points1B_modified);
    commits.add(geogig.command(CommitOp.class).call());
    l1Modified = feature(linesType, idL1, "StringProp2_1", new Integer(1000), // used to be LINESTRING (1 1, 2 2)
    "LINESTRING (1 1, -2 -2)");
    l2Modified = feature(linesType, idL2, "StringProp2_2", new Integer(2000), // used to be LINESTRING (3 3, 4 4)
    "LINESTRING (3 3, 4 4)");
}
Also used : Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit)

Example 98 with Feature

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

the class LogOpTest method testMultiplePaths.

@Test
public void testMultiplePaths() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    List<RevCommit> allCommits = Lists.newArrayList();
    RevCommit expectedLineCommit = null;
    RevCommit expectedPointCommit = 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())) {
            expectedLineCommit = commit;
        } else if (id.equals(points1.getIdentifier().getID())) {
            expectedPointCommit = commit;
        }
        allCommits.add(commit);
    }
    String linesPath = NodeRef.appendChild(linesName, lines1.getIdentifier().getID());
    String pointsPath = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    List<RevCommit> feature2_1Commits = toList(logOp.addPath(linesPath).call());
    List<RevCommit> featureCommits = toList(logOp.addPath(pointsPath).call());
    assertEquals(1, feature2_1Commits.size());
    assertEquals(2, featureCommits.size());
    assertEquals(Collections.singletonList(expectedLineCommit), feature2_1Commits);
    assertEquals(true, featureCommits.contains(expectedPointCommit) && featureCommits.contains(expectedLineCommit));
}
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 99 with Feature

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

the class LogOpTest method testHeadWithMultipleCommits.

@Test
public void testHeadWithMultipleCommits() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    for (Feature f : features) {
        insertAndAdd(f);
        final RevCommit commit = geogig.command(CommitOp.class).call();
        expected.addFirst(commit);
    }
    Iterator<RevCommit> logs = logOp.call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
}
Also used : ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 100 with Feature

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

the class LogOpTest method testPathFilterByTypeName.

@Test
public void testPathFilterByTypeName() throws Exception {
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    LinkedList<RevCommit> commits = Lists.newLinkedList();
    LinkedList<RevCommit> typeName1Commits = Lists.newLinkedList();
    for (Feature f : features) {
        insertAndAdd(f);
        final RevCommit commit = geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
        commits.addFirst(commit);
        if (pointsName.equals(f.getType().getName().getLocalPart())) {
            typeName1Commits.addFirst(commit);
        }
    }
    // path to filter commits on type1
    String path = pointsName;
    List<RevCommit> logCommits = toList(logOp.addPath(path).call());
    assertEquals(typeName1Commits.size(), logCommits.size());
    assertEquals(typeName1Commits, logCommits);
}
Also used : Feature(org.opengis.feature.Feature) 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