Search in sources :

Example 6 with Envelope

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

the class RevTreeBuilderTest method node.

/**
     * @return a feature node named {@code i}, with
     *         {@code id = ObjectId.forString(String.valueOf(i))}, null metadata id, and
     *         {@code bounds = [i, i+1, i, i+1]}
     */
private static Node node(int i) {
    String key = String.valueOf(i);
    ObjectId oid = ObjectId.forString(key);
    Envelope bounds = new Envelope(i, i + 1, i, i + 1);
    Node node = Node.create(key, oid, ObjectId.NULL, TYPE.FEATURE, bounds);
    return node;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 7 with Envelope

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

the class RevTreeBuilderPerformanceTest method createNode.

private static Node createNode(int i) {
    byte[] rawID = FAKE_ID.getRawValue();
    String key = "Feature." + i;
    ObjectId id = new ObjectId(rawID);
    Envelope env = new Envelope(0, 0, i, i);
    Node ref = Node.create(key, id, FAKE_ID, TYPE.FEATURE, env);
    return ref;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 8 with Envelope

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

the class ResponseWriter method writeTree.

public void writeTree(RevTree tree, String tag) throws XMLStreamException {
    out.writeStartElement(tag);
    writeElement("id", tree.getId().toString());
    writeElement("size", Long.toString(tree.size()));
    writeElement("numtrees", Integer.toString(tree.numTrees()));
    if (tree.trees().isPresent()) {
        ImmutableList<Node> trees = tree.trees().get();
        for (Node ref : trees) {
            writeNode(ref, "tree");
        }
    }
    if (tree.features().isPresent()) {
        ImmutableList<Node> features = tree.features().get();
        for (Node ref : features) {
            writeNode(ref, "feature");
        }
    } else if (tree.buckets().isPresent()) {
        Map<Integer, Bucket> buckets = tree.buckets().get();
        for (Entry<Integer, Bucket> entry : buckets.entrySet()) {
            Integer bucketIndex = entry.getKey();
            Bucket bucket = entry.getValue();
            out.writeStartElement("bucket");
            writeElement("bucketindex", bucketIndex.toString());
            writeElement("bucketid", bucket.id().toString());
            Envelope env = new Envelope();
            env.setToNull();
            bucket.expand(env);
            out.writeStartElement("bbox");
            writeElement("minx", Double.toString(env.getMinX()));
            writeElement("maxx", Double.toString(env.getMaxX()));
            writeElement("miny", Double.toString(env.getMinY()));
            writeElement("maxy", Double.toString(env.getMaxY()));
            out.writeEndElement();
            out.writeEndElement();
        }
    }
    out.writeEndElement();
}
Also used : DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Entry(java.util.Map.Entry) Bucket(org.locationtech.geogig.api.Bucket) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope) Map(java.util.Map)

Example 9 with Envelope

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

the class WorkingTreeInsertHelper method findOrCreateTree.

private NodeRef findOrCreateTree(final String treePath, final FeatureType type) {
    RevTree tree = context.command(FindOrCreateSubtree.class).setChildPath(treePath).setIndex(true).setParent(workHead).setParentPath(NodeRef.ROOT).call();
    ObjectId metadataId = ObjectId.NULL;
    if (type != null) {
        RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type);
        if (tree.isEmpty()) {
            indexDatabase.put(revFeatureType);
        }
        metadataId = revFeatureType.getId();
    }
    Envelope bounds = SpatialOps.boundsOf(tree);
    Node node = Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds);
    String parentPath = NodeRef.parentPath(treePath);
    return new NodeRef(node, parentPath, ObjectId.NULL);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FindOrCreateSubtree(org.locationtech.geogig.api.plumbing.FindOrCreateSubtree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree)

Example 10 with Envelope

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

the class FormatCommonV2 method readNode.

public static Node readNode(DataInput in) throws IOException {
    final int typeAndMasks = in.readByte() & 0xFF;
    final int nodeType = typeAndMasks & TYPE_READ_MASK;
    final int boundsMask = typeAndMasks & BOUNDS_READ_MASK;
    final int metadataMask = typeAndMasks & METADATA_READ_MASK;
    final RevObject.TYPE contentType = RevObject.TYPE.valueOf(nodeType);
    final String name = in.readUTF();
    final ObjectId objectId = readObjectId(in);
    ObjectId metadataId = ObjectId.NULL;
    if (metadataMask == METADATA_PRESENT_MASK) {
        metadataId = readObjectId(in);
    }
    @Nullable final Envelope bbox;
    if (boundsMask == BOUNDS_NULL_MASK) {
        bbox = null;
    } else if (boundsMask == BOUNDS_POINT_MASK) {
        bbox = readPointBoundingBox(in);
    } else if (boundsMask == BOUNDS_BOX2D_MASK) {
        bbox = readBoundingBox(in);
    } else {
        throw new IllegalStateException(String.format("Illegal bounds mask: %s, expected one of %s, %s, %s", toBinaryString(boundsMask), toBinaryString(BOUNDS_NULL_MASK), toBinaryString(BOUNDS_POINT_MASK), toBinaryString(BOUNDS_BOX2D_MASK)));
    }
    final Node node;
    node = Node.create(name, objectId, metadataId, contentType, bbox);
    return node;
}
Also used : TYPE(org.locationtech.geogig.api.RevObject.TYPE) RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Integer.toBinaryString(java.lang.Integer.toBinaryString) Envelope(com.vividsolutions.jts.geom.Envelope) Nullable(javax.annotation.Nullable)

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