Search in sources :

Example 61 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.

the class RevTreeSerializationTest method assertTreesAreEqual.

private void assertTreesAreEqual(RevTree a, RevTree b) {
    assertTrue(a.getId().equals(b.getId()));
    assertTrue(a.buckets().equals(b.buckets()));
    assertTrue(a.features().equals(b.features()));
    assertTrue(a.trees().equals(b.trees()));
    assertTrue(a.numTrees() == b.numTrees());
    assertTrue(a.size() == b.size());
    Iterator<? extends Bounded> ia;
    Iterator<? extends Bounded> ib;
    if (a.buckets().isPresent()) {
        ia = a.buckets().get().values().iterator();
        ib = b.buckets().get().values().iterator();
    } else {
        ia = a.children();
        ib = b.children();
    }
    // bounds are not part of the Bounded.equals(Object) contract as its auxiliary information
    while (ia.hasNext()) {
        Bounded ba = ia.next();
        Bounded bb = ib.next();
        Envelope ea = new Envelope();
        Envelope eb = new Envelope();
        ba.expand(ea);
        bb.expand(eb);
        assertEquals(ea.getMinX(), eb.getMinX(), 1e-7D);
        assertEquals(ea.getMinY(), eb.getMinY(), 1e-7D);
        assertEquals(ea.getMaxX(), eb.getMaxX(), 1e-7D);
        assertEquals(ea.getMaxY(), eb.getMaxY(), 1e-7D);
    }
}
Also used : Bounded(org.locationtech.geogig.api.Bounded) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 62 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.

the class FeatureNodeRefFromRefspec method _call.

@Override
protected Optional<NodeRef> _call() {
    Optional<RevFeature> feature = getFeatureFromRefSpec();
    if (feature.isPresent()) {
        RevFeatureType featureType = getFeatureTypeFromRefSpec();
        RevFeature feat = feature.get();
        Envelope bounds = SpatialOps.boundsOf(feat);
        Node node = Node.create(NodeRef.nodeFromPath(ref), feat.getId(), featureType.getId(), TYPE.FEATURE, bounds);
        return Optional.of(new NodeRef(node, NodeRef.parentPath(ref), featureType.getId()));
    } else {
        return Optional.absent();
    /*
             * new NodeRef(Node.create("", ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE), "",
             * ObjectId.NULL);
             */
    }
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Node(org.locationtech.geogig.api.Node) RevFeature(org.locationtech.geogig.api.RevFeature) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType)

Example 63 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.

the class RevTreeBuilderTest method checkTreeBounds.

private void checkTreeBounds(int size) {
    RevTree tree;
    Envelope bounds;
    tree = tree(size).build();
    bounds = SpatialOps.boundsOf(tree);
    Envelope expected = new Envelope(0, size, 0, size);
    assertEquals(expected, bounds);
}
Also used : Envelope(com.vividsolutions.jts.geom.Envelope) RevTree(org.locationtech.geogig.api.RevTree)

Example 64 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.

the class ChangesetScannerTest method testParseChangeset.

@Test
public void testParseChangeset() throws Exception {
    Changeset changeset = parse("1100.xml");
    assertNotNull(changeset);
    assertFalse(changeset.isOpen());
    assertEquals(1100L, changeset.getId());
    assertEquals(parseDateTime("2009-10-10T20:02:09Z"), changeset.getCreated());
    assertTrue(changeset.getClosed().isPresent());
    assertEquals(parseDateTime("2009-10-10T20:02:21Z"), changeset.getClosed().get().longValue());
    assertEquals(26L, changeset.getUserId());
    assertEquals("BMO_2009", changeset.getUserName());
    assertTrue(changeset.getComment().isPresent());
    assertEquals("second test upload of BMO data - see http://wiki.openstreetmap.org/wiki/BMO", changeset.getComment().get());
    assertEquals(ImmutableMap.of("created_by", "bulk_upload.py/17742 Python/2.5.2"), changeset.getTags());
    Envelope bounds = parseWGS84Bounds("48.4031818", "-4.4631203", "48.4058698", "-4.4589401");
    assertTrue(changeset.getWgs84Bounds().isPresent());
    assertEquals(bounds, changeset.getWgs84Bounds().get());
}
Also used : Envelope(com.vividsolutions.jts.geom.Envelope) Test(org.junit.Test)

Example 65 with Envelope

use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.

the class Bucket method toString.

@Override
public String toString() {
    Envelope bounds = new Envelope();
    expand(bounds);
    return getClass().getSimpleName() + "[" + id() + "] " + bounds;
}
Also used : Envelope(com.vividsolutions.jts.geom.Envelope)

Aggregations

Envelope (com.vividsolutions.jts.geom.Envelope)111 Coordinate (com.vividsolutions.jts.geom.Coordinate)21 Node (org.locationtech.geogig.api.Node)16 Geometry (com.vividsolutions.jts.geom.Geometry)13 ObjectId (org.locationtech.geogig.api.ObjectId)13 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)12 STRtree (com.vividsolutions.jts.index.strtree.STRtree)11 ArrayList (java.util.ArrayList)11 Vertex (org.opentripplanner.routing.graph.Vertex)11 Test (org.junit.Test)9 NodeRef (org.locationtech.geogig.api.NodeRef)9 Edge (org.opentripplanner.routing.graph.Edge)9 LineString (com.vividsolutions.jts.geom.LineString)8 RevTree (org.locationtech.geogig.api.RevTree)8 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)7 Map (java.util.Map)6 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)6 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)6 RevFeature (org.locationtech.geogig.api.RevFeature)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5