Search in sources :

Example 11 with Envelope

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

the class FormatCommonV2 method readBucketBody.

/**
     * Reads a bucket body (i.e assumes the head unsigned int "index" has been read already)
     */
private static final Bucket readBucketBody(DataInput in) throws IOException {
    ObjectId objectId = readObjectId(in);
    final int boundsMask = in.readByte() & 0xFF;
    @Nullable final Envelope bounds;
    if (BOUNDS_POINT_MASK == boundsMask) {
        bounds = readPointBoundingBox(in);
    } else if (BOUNDS_BOX2D_MASK == boundsMask) {
        bounds = readBoundingBox(in);
    } else {
        bounds = null;
    }
    return Bucket.create(objectId, bounds);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Envelope(com.vividsolutions.jts.geom.Envelope) Nullable(javax.annotation.Nullable)

Example 12 with Envelope

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

the class WorkingTree method putInDatabase.

/**
     * Adds a single feature to the staging database.
     * 
     * @param feature the feature to add
     * @param metadataId
     * @return the Node for the inserted feature
     */
private Node putInDatabase(final Feature feature, final ObjectId metadataId) {
    checkNotNull(feature);
    checkNotNull(metadataId);
    final RevFeature newFeature = RevFeatureBuilder.build(feature);
    final ObjectId objectId = newFeature.getId();
    final Envelope bounds = (ReferencedEnvelope) feature.getBounds();
    final String nodeName = feature.getIdentifier().getID();
    indexDatabase.put(newFeature);
    Node newObject = Node.create(nodeName, objectId, metadataId, TYPE.FEATURE, bounds);
    return newObject;
}
Also used : ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) RevFeature(org.locationtech.geogig.api.RevFeature) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 13 with Envelope

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

the class RevTreeBuilder2 method putFeature.

public Node putFeature(final ObjectId id, final String name, @Nullable final BoundingBox bounds, final FeatureType type) {
    Envelope bbox;
    if (bounds == null) {
        bbox = null;
    } else if (bounds instanceof Envelope) {
        bbox = (Envelope) bounds;
    } else {
        bbox = new Envelope(bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1));
    }
    RevFeatureType revFeatureType = revFeatureTypes.get(type.getName());
    if (null == revFeatureType) {
        revFeatureType = RevFeatureTypeImpl.build(type);
        revFeatureTypes.put(type.getName(), revFeatureType);
    }
    ObjectId metadataId = revFeatureType.getId().equals(defaultMetadataId) ? ObjectId.NULL : revFeatureType.getId();
    Node node = Node.create(name, id, metadataId, TYPE.FEATURE, bbox);
    put(node);
    return node;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType)

Example 14 with Envelope

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

the class FormatCommonV1 method readBucket.

public static final Bucket readBucket(DataInput in) throws IOException {
    final byte[] hash = new byte[20];
    in.readFully(hash);
    ObjectId objectId = ObjectId.createNoClone(hash);
    Envelope bounds = readBBox(in);
    return Bucket.create(objectId, bounds);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 15 with Envelope

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

the class WriteBack method writeBack.

private ObjectId writeBack(RevTreeBuilder ancestor, final String ancestorPath, final RevTree childTree, final String childPath, final ObjectDatabase targetDatabase, final ObjectId metadataId) {
    final ObjectId treeId = childTree.getId();
    targetDatabase.put(childTree);
    final boolean isDirectChild = NodeRef.isDirectChild(ancestorPath, childPath);
    if (isDirectChild) {
        Envelope treeBounds = null;
        if (!metadataId.isNull()) {
            // only include bounds for trees with a default feature type
            treeBounds = SpatialOps.boundsOf(childTree);
        }
        String childName = childPath;
        Node treeNode = Node.create(childName, treeId, metadataId, TYPE.TREE, treeBounds);
        ancestor.put(treeNode);
        RevTree newAncestor = ancestor.build();
        targetDatabase.put(newAncestor);
        return newAncestor.getId();
    }
    final String parentPath = NodeRef.parentPath(childPath);
    Optional<NodeRef> parentRef = getTreeChild(ancestor, parentPath);
    RevTreeBuilder parentBuilder;
    ObjectId parentMetadataId = ObjectId.NULL;
    if (parentRef.isPresent()) {
        ObjectId parentId = parentRef.get().objectId();
        parentMetadataId = parentRef.get().getMetadataId();
        parentBuilder = getTree(parentId, targetDatabase).builder(targetDatabase);
    } else {
        parentBuilder = RevTree.EMPTY.builder(targetDatabase);
    }
    String childName = NodeRef.nodeFromPath(childPath);
    Envelope treeBounds = null;
    if (!metadataId.isNull()) {
        // only include bounds for trees with a default feature type
        treeBounds = SpatialOps.boundsOf(childTree);
    }
    Node treeNode = Node.create(childName, treeId, metadataId, TYPE.TREE, treeBounds);
    parentBuilder.put(treeNode);
    RevTree parent = parentBuilder.build();
    return writeBack(ancestor, ancestorPath, parent, parentPath, targetDatabase, parentMetadataId);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) Envelope(com.vividsolutions.jts.geom.Envelope) RevTree(org.locationtech.geogig.api.RevTree)

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