Search in sources :

Example 31 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class RevTreeBuilder2 method removeFeature.

/**
     * Marks the node named after {@code fid} to be deleted by adding a Node with
     * {@link ObjectId#NULL NULL} ObjectId
     */
public void removeFeature(String fid) {
    Node node = Node.create(fid, ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE, null);
    put(node);
}
Also used : Node(org.locationtech.geogig.api.Node)

Example 32 with Node

use of org.locationtech.geogig.api.Node 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 33 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class FormatCommonV1 method readNodeRef.

public static NodeRef readNodeRef(DataInput in) throws IOException {
    Node node = readNode(in);
    final byte[] metadataId = new byte[20];
    in.readFully(metadataId);
    String parentPath = in.readUTF();
    return new NodeRef(node, parentPath, ObjectId.createNoClone(metadataId));
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Node(org.locationtech.geogig.api.Node)

Example 34 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class DiffCountConsumer method tree.

@Override
public boolean tree(Node left, Node right) {
    final Node node = left == null ? right : left;
    if (NodeRef.ROOT.equals(node.getName())) {
        // ignore the call on the root tree and follow the traversal
        return true;
    }
    if (left == null || right == null) {
        addTreeFeatures(node.getObjectId(), left != null, right != null);
        if (left == null) {
            count.addedTrees(1);
        } else {
            count.removedTrees(1);
        }
        return false;
    }
    // the tree changed, or this method wouldn't have been called
    count.changedTrees(1);
    return true;
}
Also used : Node(org.locationtech.geogig.api.Node)

Example 35 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class DiffPathTracker method endTree.

/**
     * @return the resulting parent path after removing left and right from the stack, or
     *         {@code null} if left and/or right are a root tree.
     */
public String endTree(@Nullable Node left, @Nullable Node right) {
    final Node popLeft = this.leftTrees.pop();
    final Node popRight = this.rightTrees.pop();
    try {
        Preconditions.checkState(Objects.equal(popLeft, left));
        Preconditions.checkState(Objects.equal(popRight, right));
    } catch (IllegalStateException e) {
        throw e;
    }
    if (NodeRef.ROOT.equals(currentPath)) {
        currentPath = null;
    } else {
        String fullPath = currentPath;
        currentPath = NodeRef.parentPath(fullPath);
    }
    return currentPath;
}
Also used : Node(org.locationtech.geogig.api.Node)

Aggregations

Node (org.locationtech.geogig.api.Node)117 RevTree (org.locationtech.geogig.api.RevTree)56 Test (org.junit.Test)50 ObjectId (org.locationtech.geogig.api.ObjectId)44 NodeRef (org.locationtech.geogig.api.NodeRef)24 Bucket (org.locationtech.geogig.api.Bucket)20 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)18 Envelope (com.vividsolutions.jts.geom.Envelope)16 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)14 RevCommit (org.locationtech.geogig.api.RevCommit)10 Map (java.util.Map)9 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)9 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)9 File (java.io.File)7 RevFeature (org.locationtech.geogig.api.RevFeature)7 WorkingTree (org.locationtech.geogig.repository.WorkingTree)7 Feature (org.opengis.feature.Feature)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Stopwatch (com.google.common.base.Stopwatch)6 SortedMap (java.util.SortedMap)5