Search in sources :

Example 11 with CoordinateReferenceSystem

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());
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) RevTree(org.locationtech.geogig.api.RevTree) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 12 with CoordinateReferenceSystem

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());
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) BoundingBox(org.opengis.geometry.BoundingBox) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 13 with CoordinateReferenceSystem

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);
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) WorkingTree(org.locationtech.geogig.repository.WorkingTree) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) BoundingBox(org.opengis.geometry.BoundingBox) DefaultProgressListener(org.locationtech.geogig.api.DefaultProgressListener) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 14 with CoordinateReferenceSystem

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);
    }
}
Also used : BoundingBox(org.opengis.geometry.BoundingBox) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 15 with CoordinateReferenceSystem

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());
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) RevTree(org.locationtech.geogig.api.RevTree) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Aggregations

CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)210 Test (org.junit.Test)80 MathTransform (org.opengis.referencing.operation.MathTransform)32 FactoryException (org.opengis.referencing.FactoryException)25 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)24 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)23 Geometry (com.vividsolutions.jts.geom.Geometry)21 TransformException (org.opengis.referencing.operation.TransformException)21 DependsOnMethod (org.apache.sis.test.DependsOnMethod)19 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)13 Geometry (org.locationtech.jts.geom.Geometry)11 FactoryException (org.opengis.util.FactoryException)11 SimpleFeature (org.opengis.feature.simple.SimpleFeature)9 DirectPosition (org.opengis.geometry.DirectPosition)9 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)9 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)9 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)9 ArrayList (java.util.ArrayList)8 GeometryType (org.opengis.feature.type.GeometryType)8 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)7