public static String toString(@NonNull RevFeature f) { return String.format("%s(%s)%s", // f.getClass().getSimpleName(), // toShortString(f.getId()), // toString(((ValueArray) f))); }
public Feature build(final String id, final RevFeature revFeature, final @Nullable GeometryFactory geometryFactory) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(revFeature); final FeatureId fid = new LazyVersionedFeatureId(id, revFeature.getId()); GeogigSimpleFeature feature = new GeogigSimpleFeature(revFeature, featureType, fid, attNameToRevTypeIndex, geometryFactory); return feature; }
public Feature build(final String id, final RevFeature revFeature, final @Nullable GeometryFactory geometryFactory) { Preconditions.checkNotNull(id); Preconditions.checkNotNull(revFeature); final FeatureId fid = new LazyVersionedFeatureId(id, revFeature.getId()); GeogigSimpleFeature feature = new GeogigSimpleFeature(revFeature, featureType, fid, attNameToRevTypeIndex, geometryFactory); return feature; }
public Iterator<FeatureInfo> apply(List<NodeRef> refs) { Map<ObjectId, RevFeature> correlationIndex = new HashMap<>(refs.size()); ArrayList<ObjectId> ids = new ArrayList<>(refs.size()); refs.forEach(ref->ids.add(ref.getObjectId())); Iterator<RevFeature> all = odb.getAll(ids, NOOP_LISTENER, RevFeature.class); all.forEachRemaining(revFeature -> correlationIndex.put(revFeature.getId(),revFeature)); ArrayList<FeatureInfo> result = new ArrayList<>(refs.size()); refs.forEach( ref-> result.add(FeatureInfo.insert(correlationIndex.get(ref.getObjectId()), ref.getMetadataId(), ref.path() ))); return (result.iterator() ); } }
@Override public FeatureInfo apply(SimpleFeature f) { RevFeature feature = RevFeature.builder().build(f); String fid = f.getID(); String path = NodeRef.appendChild(treePath, fid); String version = feature.getId().toString(); if (returnFidsOnInsert) { insertedFids.add(new FeatureIdVersionedImpl(fid, version)); } return FeatureInfo.insert(feature, featureTypeId, path); }};
@Test public void testRevFeatureToString() { List<Object> values = Lists.newArrayList("StringProp1_1", new Integer(1000), "POINT(1 1)"); RevFeature feature = RevFeatureBuilder.builder().addAll(values).build(); String featureString = feature.toString(); assertEquals("Feature[" + feature.getId().toString() + "; StringProp, 1000, POINT(1 1)]", featureString); } }
private DiffEntry entry(String name, RevFeature l, RevFeature r) { //@formatter:off Node lnode = l == null? null: RevObjectFactory.defaultInstance().createNode(name, l.getId(), ObjectId.NULL, TYPE.FEATURE, SpatialOps.boundsOf(l), null); Node rnode = r == null? null: RevObjectFactory.defaultInstance().createNode(name, r.getId(), ObjectId.NULL, TYPE.FEATURE, SpatialOps.boundsOf(r), null); //@formatter:on NodeRef oldObject = lnode == null ? null : NodeRef.create(NodeRef.ROOT, lnode); NodeRef newObject = rnode == null ? null : NodeRef.create(NodeRef.ROOT, rnode); return new DiffEntry(oldObject, newObject); }
/** * 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()); FeatureInfo feature = featureInfo(f); workTree.insert(feature); ObjectId objectId = feature.getFeature().getId(); return objectId; }
/** * 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()); FeatureInfo feature = featureInfo(f); workTree.insert(feature); ObjectId objectId = feature.getFeature().getId(); return objectId; }
@Test public void testBuildEmpty() throws Exception { RevFeature emptyFeature = RevFeature.builder().build(); assertNotNull(emptyFeature); assertTrue(emptyFeature.getValues().isEmpty()); assertEquals(ObjectId.valueOf("0aaf76f425c6e0f43a36197de768e67d9e035abb"), emptyFeature.getId()); }
@Test public void testInsertSingle() throws Exception { FeatureInfo fi = featureInfo(points1); workTree.insert(fi); assertEquals(fi.getFeature().getId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId()); }
@Test public void testBuildEmpty() throws Exception { RevFeature emptyFeature = RevFeatureBuilder.builder().build(); assertNotNull(emptyFeature); assertTrue(emptyFeature.getValues().isEmpty()); assertEquals(ObjectId.valueOf("0aaf76f425c6e0f43a36197de768e67d9e035abb"), emptyFeature.getId()); }
@Test public void testInsertSingle() throws Exception { FeatureInfo fi = featureInfo(points1); workTree.insert(fi); assertEquals(fi.getFeature().getId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId()); }
private void testCreateFeature(ObjectId id, List<Object> values) { RevFeature actual = factory.createFeature(id, values); assertNotNull(actual); RevFeature expected = DEFAULT.createFeature(id, values); assertNotNull(expected); assertEquals(id, expected.getId()); RevObjectTestUtil.deepEquals(expected, actual); }
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeatureBuilder.build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds); }
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeature.builder().build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return RevObjectFactory.defaultInstance().createNode(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds, null); }
protected ObjectId insert(Repository repo, Feature f) throws Exception { final WorkingTree workTree = repo.workingTree(); Name name = f.getType().getName(); String parentPath = name.getLocalPart(); RevFeatureType type = RevFeatureTypeBuilder.build(f.getType()); repo.objectDatabase().put(type); String path = NodeRef.appendChild(parentPath, f.getIdentifier().getID()); FeatureInfo fi = FeatureInfo.insert(RevFeatureBuilder.build(f), type.getId(), path); workTree.insert(fi); return fi.getFeature().getId(); }
protected ObjectId insert(Repository repo, Feature f) throws Exception { final WorkingTree workTree = repo.workingTree(); Name name = f.getType().getName(); String parentPath = name.getLocalPart(); RevFeatureType type = RevFeatureType.builder().type(f.getType()).build(); repo.objectDatabase().put(type); String path = NodeRef.appendChild(parentPath, f.getIdentifier().getID()); FeatureInfo fi = FeatureInfo.insert(RevFeature.builder().build(f), type.getId(), path); workTree.insert(fi); return fi.getFeature().getId(); }