use of org.locationtech.geogig.api.RevFeatureTypeImpl in project GeoGig by boundlessgeo.
the class FormatCommonV2 method readFeatureType.
public static RevFeatureType readFeatureType(ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException {
Name name = readName(in);
int propertyCount = readUnsignedVarInt(in);
List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>();
for (int i = 0; i < propertyCount; i++) {
attributes.add(readAttributeDescriptor(in, typeFactory));
}
SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter>emptyList(), BasicFeatureTypes.FEATURE, null);
return new RevFeatureTypeImpl(id, ftype);
}
use of org.locationtech.geogig.api.RevFeatureTypeImpl in project GeoGig by boundlessgeo.
the class WriteTree2Test method tree.
/**
* Creates a tree reference for testing, forcing the specified id and metadata id, and with the
* specified number of features (zero or more).
* <p>
* Note the tree is saved to the specified database only if its a leaf tree (more than zero
* features), in order for the {@link #createFromRefs} method to be able of saving the parent
*/
private NodeRef tree(ObjectDatabase db, String path, String id, String mdId, int numFeatures) {
Preconditions.checkArgument(numFeatures != 0 || EMPTY_ID.equals(id), "for zero features trees use RevTree.EMPTY_TREE_ID");
final ObjectId treeId = id(id);
final ObjectId metadataId = id(mdId);
final String feturePrefix = NodeRef.nodeFromPath(path);
RevTreeBuilder b = new RevTreeBuilder(db);
if (numFeatures > 0) {
for (int i = 0; i < numFeatures; i++) {
Node fn = feature(db, feturePrefix, i);
b.put(fn);
}
}
RevTree fakenId = forceTreeId(b, treeId);
if (!db.exists(fakenId.getId())) {
db.put(fakenId);
}
if (!metadataId.isNull()) {
RevFeatureType fakeType = new RevFeatureTypeImpl(metadataId, pointsType);
if (!db.exists(fakeType.getId())) {
db.put(fakeType);
}
}
String name = NodeRef.nodeFromPath(path);
String parent = NodeRef.parentPath(path);
Envelope bounds = SpatialOps.boundsOf(fakenId);
Node node = Node.create(name, treeId, metadataId, TYPE.TREE, bounds);
return new NodeRef(node, parent, ObjectId.NULL);
}
use of org.locationtech.geogig.api.RevFeatureTypeImpl in project GeoGig by boundlessgeo.
the class FormatCommonV1 method readFeatureType.
public static RevFeatureType readFeatureType(ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException {
Name name = readName(in);
int propertyCount = in.readInt();
List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>();
for (int i = 0; i < propertyCount; i++) {
attributes.add(readAttributeDescriptor(in, typeFactory));
}
SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter>emptyList(), BasicFeatureTypes.FEATURE, null);
return new RevFeatureTypeImpl(id, ftype);
}
Aggregations