use of org.geotools.geometry.jts.ReferencedEnvelope 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.geotools.geometry.jts.ReferencedEnvelope 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.geotools.geometry.jts.ReferencedEnvelope 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.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class ExtractBounds method visit.
@Override
public List<ReferencedEnvelope> visit(Literal literal, @Nullable Object data) {
Object value = literal.getValue();
if (value instanceof Geometry) {
Geometry geom = (Geometry) value;
Envelope literalEnvelope = geom.getEnvelopeInternal();
CoordinateReferenceSystem crs = nativeCrs;
if (geom.getUserData() instanceof CoordinateReferenceSystem) {
crs = (CoordinateReferenceSystem) geom.getUserData();
}
ReferencedEnvelope bbox = new ReferencedEnvelope(literalEnvelope, crs);
bounds.add(bbox);
}
return bounds;
}
use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class RemoteRepositoryTestCase method boundsOf.
/**
* Computes the aggregated bounds of {@code features} in the {@code targetCrs}
*/
protected ReferencedEnvelope boundsOf(CoordinateReferenceSystem targetCrs, Feature... features) throws Exception {
ReferencedEnvelope bounds = new ReferencedEnvelope(targetCrs);
for (int i = 0; i < features.length; i++) {
Feature f = features[i];
BoundingBox fbounds = f.getBounds();
if (!CRS.equalsIgnoreMetadata(targetCrs, fbounds)) {
fbounds = fbounds.toBounds(targetCrs);
}
bounds.include(fbounds);
}
return bounds;
}
Aggregations