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);
*/
}
}
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;
}
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);
}
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;
}
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());
}
Aggregations