use of org.opengis.referencing.crs.CoordinateReferenceSystem 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.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class DiffBoundsTest method testReprojectToTargetCRS.
@Test
public void testReprojectToTargetCRS() throws Exception {
DiffBounds cmd = geogig.command(DiffBounds.class).setOldVersion("HEAD^").setNewVersion("HEAD");
DiffSummary<BoundingBox, BoundingBox> defaultCrs = cmd.call();
CoordinateReferenceSystem target = CRS.decode("EPSG:26986");
cmd.setCRS(target);
DiffSummary<BoundingBox, BoundingBox> reprojected = cmd.call();
assertEquals(target, reprojected.getLeft().getCoordinateReferenceSystem());
assertEquals(target, reprojected.getRight().getCoordinateReferenceSystem());
assertEquals(target, reprojected.getMergedResult().get().getCoordinateReferenceSystem());
assertFalse(defaultCrs.getLeft().isEmpty());
assertFalse(defaultCrs.getRight().isEmpty());
assertFalse(defaultCrs.getMergedResult().get().isEmpty());
ReferencedEnvelope e = new ReferencedEnvelope(defaultCrs.getLeft());
ReferencedEnvelope expected = e.transform(target, true);
assertEquals(expected, reprojected.getLeft());
}
use of org.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class DiffBoundsTest method testReprojectToTargetBucketTree.
@Test
public void testReprojectToTargetBucketTree() throws Exception {
final int leftCount = RevTree.NORMALIZED_SIZE_LIMIT * 2;
final int rightCount = RevTree.NORMALIZED_SIZE_LIMIT * 3;
WorkingTree workingTree = geogig.getRepository().workingTree();
final String typeName = "newpoints";
final DefaultProgressListener listener = new DefaultProgressListener();
workingTree.insert(typeName, new TestFeatureIterator(typeName, leftCount), listener, null, null);
geogig.command(AddOp.class).call();
workingTree.insert(typeName, new TestFeatureIterator(typeName, rightCount), listener, null, null);
{
// sanity check
long diffFeatures = geogig.command(DiffCount.class).setOldVersion("STAGE_HEAD").setNewVersion("WORK_HEAD").call().featureCount();
assertEquals(rightCount - leftCount, diffFeatures);
}
DiffBounds cmd = geogig.command(DiffBounds.class).setOldVersion("STAGE_HEAD").setNewVersion("WORK_HEAD");
final CoordinateReferenceSystem nativeCrs = CRS.decode("EPSG:3857");
final DiffSummary<BoundingBox, BoundingBox> diffInNativeCrs = cmd.setCRS(nativeCrs).call();
CoordinateReferenceSystem targetcrs = CRS.decode("EPSG:4326", true);
cmd.setCRS(targetcrs);
DiffSummary<BoundingBox, BoundingBox> reprojected = cmd.call();
assertEquals(targetcrs, reprojected.getLeft().getCoordinateReferenceSystem());
assertEquals(targetcrs, reprojected.getRight().getCoordinateReferenceSystem());
assertEquals(targetcrs, reprojected.getMergedResult().get().getCoordinateReferenceSystem());
ReferencedEnvelope e = new ReferencedEnvelope(diffInNativeCrs.getRight());
ReferencedEnvelope expected = e.transform(targetcrs, true);
BoundingBox actual = reprojected.getRight();
assertEquals(expected, actual);
}
use of org.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class DiffBoundsTest method testPathFiltering.
private void testPathFiltering(String oldVersion, String newVersion, @Nullable BoundingBox expected, @Nullable String... pathFilters) {
List<String> filter = ImmutableList.<String>copyOf(pathFilters);
CoordinateReferenceSystem crs = DEFAULT_CRS;
if (expected != null) {
crs = expected.getCoordinateReferenceSystem();
}
DiffSummary<BoundingBox, BoundingBox> result = //
geogig.command(DiffBounds.class).setOldVersion(//
oldVersion).setNewVersion(//
newVersion).setPathFilters(//
filter).setCRS(//
crs).call();
BoundingBox actual = result.getMergedResult().get();
if (null == expected) {
assertTrue(actual.isEmpty());
} else {
assertEquals(expected, actual);
}
}
use of org.opengis.referencing.crs.CoordinateReferenceSystem 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());
}
Aggregations