Search in sources :

Example 1 with BoundingBox

use of org.opengis.geometry.BoundingBox in project GeoGig by boundlessgeo.

the class WorkingTreeInsertHelper method put.

public Node put(final ObjectId revFeatureId, final Feature feature) {
    final RevTreeBuilder2 treeBuilder = getTreeBuilder(feature);
    String fid = feature.getIdentifier().getID();
    BoundingBox bounds = feature.getBounds();
    FeatureType type = feature.getType();
    final Node node = treeBuilder.putFeature(revFeatureId, fid, bounds, type);
    return node;
}
Also used : FeatureType(org.opengis.feature.type.FeatureType) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) BoundingBox(org.opengis.geometry.BoundingBox) Node(org.locationtech.geogig.api.Node)

Example 2 with BoundingBox

use of org.opengis.geometry.BoundingBox 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 3 with BoundingBox

use of org.opengis.geometry.BoundingBox in project GeoGig by boundlessgeo.

the class DiffBoundsTest method testDiffBetweenDifferentTrees.

@Test
public void testDiffBetweenDifferentTrees() {
    String oldRefSpec = "HEAD~3";
    String newRefSpec = "HEAD";
    DiffSummary<BoundingBox, BoundingBox> diffBounds = geogig.command(DiffBounds.class).setOldVersion(oldRefSpec).setNewVersion(newRefSpec).setCRS(pointsType.getCoordinateReferenceSystem()).call();
    BoundingBox bounds = diffBounds.getMergedResult().get();
    assertEquals(1.0, bounds.getMinX(), 0.0);
    assertEquals(1.0, bounds.getMinY(), 0.0);
    assertEquals(10.0, bounds.getMaxX(), 0.0);
    assertEquals(220.0, bounds.getMaxY(), 0.0);
}
Also used : BoundingBox(org.opengis.geometry.BoundingBox) Test(org.junit.Test)

Example 4 with BoundingBox

use of org.opengis.geometry.BoundingBox 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 5 with BoundingBox

use of org.opengis.geometry.BoundingBox in project GeoGig by boundlessgeo.

the class DiffBoundsTest method testPathFiltering.

@Test
public void testPathFiltering() throws Exception {
    insertAndAdd(l1Modified);
    geogig.command(CommitOp.class).call();
    insert(l2Modified);
    testPathFiltering("HEAD~3", "HEAD", l1Modified.getBounds(), linesName);
    testPathFiltering("HEAD", "WORK_HEAD", l2Modified.getBounds(), linesName);
    testPathFiltering("HEAD~3", "HEAD~2", null, linesName);
    testPathFiltering("HEAD~3", "HEAD~2", null, linesName);
    String head = points1_modified_commit.getId().toString();
    BoundingBox expected = points1.getBounds();
    expected.include(points1_modified.getBounds());
    testPathFiltering(head + "^", head, expected, pointsName);
    testPathFiltering(head + "^", head, null, linesName);
    testPathFiltering("HEAD^", "HEAD", null, pointsName);
}
Also used : BoundingBox(org.opengis.geometry.BoundingBox) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Test(org.junit.Test)

Aggregations

BoundingBox (org.opengis.geometry.BoundingBox)11 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)6 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)5 Test (org.junit.Test)4 Feature (org.opengis.feature.Feature)2 Optional (com.google.common.base.Optional)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 Point (com.vividsolutions.jts.geom.Point)1 ConsoleReader (jline.console.ConsoleReader)1 DefaultProgressListener (org.locationtech.geogig.api.DefaultProgressListener)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 Node (org.locationtech.geogig.api.Node)1 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)1 RevTree (org.locationtech.geogig.api.RevTree)1 DiffBounds (org.locationtech.geogig.api.plumbing.DiffBounds)1 DiffCount (org.locationtech.geogig.api.plumbing.DiffCount)1 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)1 DiffObjectCount (org.locationtech.geogig.api.plumbing.diff.DiffObjectCount)1 PathFilteringDiffConsumer (org.locationtech.geogig.api.plumbing.diff.PathFilteringDiffConsumer)1