Search in sources :

Example 61 with Node

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

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

the class RepositoryTestCase method insert.

/**
     * Inserts the feature to the index but does not stages it to be committed
     */
public ObjectId insert(GeogigTransaction transaction, Feature f) throws Exception {
    final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo.workingTree());
    Name name = f.getType().getName();
    String parentPath = name.getLocalPart();
    Node ref = workTree.insert(parentPath, f);
    ObjectId objectId = ref.getObjectId();
    return objectId;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name)

Example 63 with Node

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

the class RevTreeBuilderTest method addNode.

private void addNode(RevTreeBuilder tree, int i) {
    String key = "Feature." + i;
    // ObjectId oid = ObjectId.forString(key);
    // ObjectId metadataId = ObjectId.forString("FeatureType");
    // Node ref = new Node(key, oid, metadataId, TYPE.FEATURE);
    Node ref = Node.create(key, FAKE_ID, FAKE_ID, TYPE.FEATURE, boundsOf(points1));
    tree.put(ref);
}
Also used : Node(org.locationtech.geogig.api.Node)

Example 64 with Node

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

the class GlobalState method insert.

public static List<ObjectId> insert(Feature... features) throws Exception {
    geogigCLI.close();
    GeoGIG geogig = geogigCLI.newGeoGIG(Hints.readWrite());
    Preconditions.checkNotNull(geogig);
    List<ObjectId> ids = Lists.newArrayListWithCapacity(features.length);
    try {
        Repository repository = geogig.getRepository();
        final WorkingTree workTree = repository.workingTree();
        for (Feature f : features) {
            Name name = f.getType().getName();
            String parentPath = name.getLocalPart();
            Node ref = workTree.insert(parentPath, f);
            ObjectId objectId = ref.getObjectId();
            ids.add(objectId);
        }
    } finally {
        geogig.close();
    }
    return ids;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) Repository(org.locationtech.geogig.repository.Repository) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Feature(org.opengis.feature.Feature) GeoGIG(org.locationtech.geogig.api.GeoGIG) Name(org.opengis.feature.type.Name)

Example 65 with Node

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

the class PostOrderDiffWalkTest method testLeafLeafWithSubStrees.

@Test
public void testLeafLeafWithSubStrees() {
    // two leaf trees
    ObjectId metadataId = ObjectId.forString("fake");
    RevTree left = createTreesTree(leftSource, 2, 2, metadataId).build();
    RevTree right = createTreesTree(rightSource, 3, 2, metadataId).build();
    PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
    visitor.walk(testConsumer);
    List<Bounded> leftCalls = testConsumer.orderedLeft;
    List<Bounded> rightCalls = testConsumer.orderedRight;
    System.err.println(leftCalls);
    System.err.println(rightCalls);
    Node lroot = nodeFor(left);
    Node rroot = nodeFor(right);
    assertEquals(4, leftCalls.size());
    assertEquals(4, rightCalls.size());
    assertNull(leftCalls.get(0));
    assertNull(leftCalls.get(1));
    assertNull(leftCalls.get(2));
    assertEquals(lroot, leftCalls.get(3));
    assertEquals(rroot, rightCalls.get(3));
    assertNotNull(rightCalls.get(2));
    assertEquals(RevObject.TYPE.TREE, ((Node) rightCalls.get(2)).getType());
    assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(1)).getType());
    assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(0)).getType());
}
Also used : Bounded(org.locationtech.geogig.api.Bounded) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

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