use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class SquashOpTest method testSquash.
@Test
public void testSquash() throws Exception {
List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
List<RevCommit> commits = Lists.newArrayList();
for (Feature f : features) {
insertAndAdd(f);
final RevCommit commit = geogig.command(CommitOp.class).call();
commits.add(commit);
}
geogig.command(SquashOp.class).setSince(commits.get(1)).setUntil(commits.get(4)).call();
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
ArrayList<RevCommit> logentries = Lists.newArrayList(log);
assertEquals(3, logentries.size());
RevCommit headCommit = logentries.get(0);
RevCommit squashedCommit = logentries.get(1);
RevCommit presquashCommit = logentries.get(2);
assertEquals(commits.get(5).getTreeId(), headCommit.getTreeId());
assertEquals(commits.get(1).getMessage(), squashedCommit.getMessage());
assertEquals(commits.get(4).getAuthor().getTimestamp(), squashedCommit.getAuthor().getTimestamp());
assertEquals(commits.get(0).getTreeId(), presquashCommit.getTreeId());
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class SquashOpTest method testSquashAtHistoryOrigin.
@Test
public void testSquashAtHistoryOrigin() throws Exception {
List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
List<RevCommit> commits = Lists.newArrayList();
for (Feature f : features) {
insertAndAdd(f);
final RevCommit commit = geogig.command(CommitOp.class).call();
commits.add(commit);
}
try {
geogig.command(SquashOp.class).setSince(commits.get(0)).setUntil(commits.get(4)).call();
fail();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("no parents"));
}
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class IndexTest method testInsertIdenticalObjects.
// two features with the same content and different fid should point to the same object
@Test
public void testInsertIdenticalObjects() throws Exception {
ObjectId oId1 = insertAndAdd(points1);
Feature equalContentFeature = feature(pointsType, "DifferentId", ((SimpleFeature) points1).getAttributes().toArray());
ObjectId oId2 = insertAndAdd(equalContentFeature);
// BLOBS.print(repo.getRawObject(insertedId1), System.err);
// BLOBS.print(repo.getRawObject(insertedId2), System.err);
assertNotNull(oId1);
assertNotNull(oId2);
assertEquals(oId1, oId2);
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class SparseCloneTest method testSparseCloneOnlyFirstMatch.
@Test
public void testSparseCloneOnlyFirstMatch() throws Exception {
Map<String, String> filter = new HashMap<String, String>();
filter.put("default", "BBOX(pp,9, -80, 15, -70,'EPSG:4326')");
createFilterFile(filter);
// Commit several features to the remote
List<Feature> features = Arrays.asList(city1, city2, city3, road1, road2, road3);
LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
for (Feature f : features) {
ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
oids.put(f, oId);
final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
expected.addFirst(commit);
Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
assertTrue(childObject.isPresent());
}
// Make sure the remote has all of the commits
Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
List<RevCommit> logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expected, logged);
// Make sure the local repository has no commits prior to clone
logs = localGeogig.geogig.command(LogOp.class).call();
assertNotNull(logs);
assertFalse(logs.hasNext());
// clone from the remote
CloneOp clone = clone();
clone.setDepth(0);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
// Because only the first feature matches (Cities.1), the first commit should be the same,
// there will also be the commit that adds the "Roads" tree but no features, and finally an
// "Empty Placeholder Commit".
// Make sure the local repository got the correct commits
logs = localGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(3, logged.size());
assertEquals(AbstractMappedRemoteRepo.PLACEHOLDER_COMMIT_MESSAGE, logged.get(0).getMessage());
assertFalse(expected.get(0).getId().equals(logged.get(0).getId()));
assertEquals("Roads.1", logged.get(1).getMessage());
assertFalse(expected.get(2).getId().equals(logged.get(1).getId()));
assertEquals("Cities.1", logged.get(2).getMessage());
assertTrue(expected.get(5).getId().equals(logged.get(2).getId()));
assertExists(localGeogig, oids.get(city1));
assertNotExists(localGeogig, oids.get(city2), oids.get(city3), oids.get(road1), oids.get(road2), oids.get(road3));
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class SparseCloneTest method testFeatureMovingIntoAOI.
@Test
public void testFeatureMovingIntoAOI() throws Exception {
Map<String, String> filter = new HashMap<String, String>();
filter.put("Cities", "BBOX(pp,30, -125, 40, -110,'EPSG:4326')");
createFilterFile(filter);
// Commit several features to the remote
List<Feature> features = Arrays.asList(city2, city1, city3, city1_modified);
LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
for (Feature f : features) {
ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
oids.put(f, oId);
final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
expected.addFirst(commit);
Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
assertTrue(childObject.isPresent());
}
// Make sure the remote has all of the commits
Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
List<RevCommit> logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expected, logged);
// Make sure the local repository has no commits prior to clone
logs = localGeogig.geogig.command(LogOp.class).call();
assertNotNull(logs);
assertFalse(logs.hasNext());
// clone from the remote
CloneOp clone = clone();
clone.setDepth(0);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
// Cities.1 initially lies outside the filter, so the commit that adds it will not be part
// of the sparse clone. Later the feature is moved into the AOI so it will be added at that
// time.
// Make sure the local repository got the correct commits
logs = localGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(3, logged.size());
assertEquals("Cities.1", logged.get(0).getMessage());
assertFalse(expected.get(0).getId().equals(logged.get(0).getId()));
assertEquals("Cities.3", logged.get(1).getMessage());
assertFalse(expected.get(1).getId().equals(logged.get(1).getId()));
assertEquals("Cities.2", logged.get(2).getMessage());
assertTrue(expected.get(3).getId().equals(logged.get(2).getId()));
assertExists(localGeogig, oids.get(city2), oids.get(city3), oids.get(city1_modified));
assertNotExists(localGeogig, oids.get(city1));
}
Aggregations