use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffTreeTest method testBoundsFilteringReprojecting.
@Test
public void testBoundsFilteringReprojecting() throws Exception {
ObjectDatabase db = geogit.getContext().objectDatabase();
RevTree tree1 = tree(1000, db);
RevTree tree2 = tree(50, db);
RevTree root = createRoot(db, tree1, tree2);
CoordinateReferenceSystem nativeCrs = revtype.type().getCoordinateReferenceSystem();
CoordinateReferenceSystem queryCrs = CRS.decode("EPSG:4326", true);
ReferencedEnvelope nativeFilter = new ReferencedEnvelope(49.9, 51.1, 49.9, 51.1, nativeCrs);
ReferencedEnvelope queryFilter = nativeFilter.transform(queryCrs, true);
List<DiffEntry> diffs;
diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId());
diffTree.setBoundsFilter(queryFilter);
diffs = ImmutableList.copyOf(diffTree.call());
assertEquals(2, diffs.size());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffTreeTest method testBoundsFiltering.
@Test
public void testBoundsFiltering() {
ObjectDatabase db = geogit.getContext().objectDatabase();
RevTree tree1 = tree(1000, db);
RevTree tree2 = tree(50, db);
RevTree root = createRoot(db, tree1, tree2);
CoordinateReferenceSystem crs = revtype.type().getCoordinateReferenceSystem();
ReferencedEnvelope filter;
List<DiffEntry> diffs;
diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId());
filter = new ReferencedEnvelope(50, 51, 50, 51, crs);
diffTree.setBoundsFilter(filter);
diffs = ImmutableList.copyOf(diffTree.call());
assertEquals(2, diffs.size());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class OSMHistoryImportTest method test.
@Test
public void test() throws Exception {
cli.execute("config", "user.name", "Gabriel Roldan");
cli.execute("config", "user.email", "groldan@boundlessgeo.com");
cli.execute("osm", "import-history", fakeOsmApiUrl, "--to", "10");
GeoGIG geogig = cli.getGeogig();
List<DiffEntry> changes = ImmutableList.copyOf(geogig.command(DiffOp.class).setOldVersion("HEAD~2").setNewVersion("HEAD~1").call());
assertEquals(1, changes.size());
DiffEntry entry = changes.get(0);
assertEquals(ChangeType.MODIFIED, entry.changeType());
assertEquals("node/20", entry.getOldObject().path());
assertEquals("node/20", entry.getNewObject().path());
Optional<RevFeature> oldRevFeature = geogig.command(RevObjectParse.class).setObjectId(entry.getOldObject().objectId()).call(RevFeature.class);
Optional<RevFeature> newRevFeature = geogig.command(RevObjectParse.class).setObjectId(entry.getNewObject().objectId()).call(RevFeature.class);
assertTrue(oldRevFeature.isPresent());
assertTrue(newRevFeature.isPresent());
Optional<RevFeatureType> type = geogig.command(RevObjectParse.class).setObjectId(entry.getOldObject().getMetadataId()).call(RevFeatureType.class);
assertTrue(type.isPresent());
FeatureType featureType = type.get().type();
CoordinateReferenceSystem expected = CRS.decode("EPSG:4326", true);
CoordinateReferenceSystem actual = featureType.getCoordinateReferenceSystem();
assertTrue(actual.toString(), CRS.equalsIgnoreMetadata(expected, actual));
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class BlameOp method _call.
@Override
protected BlameReport _call() {
String fullPath = (commit != null ? commit.toString() : Ref.HEAD) + ":" + path;
Optional<ObjectId> id = command(RevParse.class).setRefSpec(fullPath).call();
if (!id.isPresent()) {
throw new BlameException(StatusCode.FEATURE_NOT_FOUND);
}
TYPE type = command(ResolveObjectType.class).setObjectId(id.get()).call();
if (!type.equals(TYPE.FEATURE)) {
throw new BlameException(StatusCode.PATH_NOT_FEATURE);
}
Optional<RevFeatureType> featureType = command(ResolveFeatureType.class).setRefSpec(path).call();
BlameReport report = new BlameReport(featureType.get());
Iterator<RevCommit> log = command(LogOp.class).addPath(path).setUntil(commit).call();
RevCommit commit = log.next();
RevObjectParse revObjectParse = command(RevObjectParse.class);
DiffOp diffOp = command(DiffOp.class);
DiffFeature diffFeature = command(DiffFeature.class);
while (!report.isComplete()) {
if (!log.hasNext()) {
String refSpec = commit.getId().toString() + ":" + path;
RevFeature feature = revObjectParse.setRefSpec(refSpec).call(RevFeature.class).get();
report.setFirstVersion(feature, commit);
break;
}
RevCommit commitB = log.next();
Iterator<DiffEntry> diffs = diffOp.setNewVersion(commit.getId()).setOldVersion(commitB.getId()).setReportTrees(false).call();
while (diffs.hasNext()) {
DiffEntry diff = diffs.next();
if (path.equals(diff.newPath())) {
if (diff.isAdd()) {
String refSpec = commit.getId().toString() + ":" + path;
RevFeature feature = revObjectParse.setRefSpec(refSpec).call(RevFeature.class).get();
report.setFirstVersion(feature, commit);
break;
}
FeatureDiff featureDiff = diffFeature.setNewVersion(Suppliers.ofInstance(diff.getNewObject())).setOldVersion(Suppliers.ofInstance(diff.getOldObject())).call();
Map<PropertyDescriptor, AttributeDiff> attribDiffs = featureDiff.getDiffs();
Iterator<PropertyDescriptor> iter = attribDiffs.keySet().iterator();
while (iter.hasNext()) {
PropertyDescriptor key = iter.next();
Optional<?> value = attribDiffs.get(key).getNewValue();
String attribute = key.getName().toString();
report.addDiff(attribute, value, commit);
}
}
}
commit = commitB;
}
return report;
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOp method _call.
/**
* Executes the diff operation.
*
* @return an iterator to a set of differences between the two trees
* @see DiffEntry
*/
@Override
protected Iterator<DiffEntry> _call() {
checkArgument(cached && oldRefSpec == null || !cached, String.format("compare index allows only one revision to check against, got %s / %s", oldRefSpec, newRefSpec));
checkArgument(newRefSpec == null || oldRefSpec != null, "If new rev spec is specified then old rev spec is mandatory");
Iterator<DiffEntry> iterator;
if (cached) {
// compare the tree-ish (default to HEAD) and the index
DiffIndex diffIndex = command(DiffIndex.class).addFilter(this.pathFilter).setReportTrees(reportTrees);
if (oldRefSpec != null) {
diffIndex.setOldVersion(oldRefSpec);
}
iterator = diffIndex.call();
} else if (newRefSpec == null) {
DiffWorkTree workTreeIndexDiff = command(DiffWorkTree.class).setFilter(pathFilter).setReportTrees(reportTrees);
if (oldRefSpec != null) {
workTreeIndexDiff.setOldVersion(oldRefSpec);
}
iterator = workTreeIndexDiff.call();
} else {
iterator = command(DiffTree.class).setOldVersion(oldRefSpec).setNewVersion(newRefSpec).setPathFilter(pathFilter).setReportTrees(reportTrees).call();
}
return iterator;
}
Aggregations