Search in sources :

Example 1 with RevFeatureTypeImpl

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);
}
Also used : RevFeatureTypeImpl(org.locationtech.geogig.api.RevFeatureTypeImpl) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ArrayList(java.util.ArrayList) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) Name(org.opengis.feature.type.Name)

Example 2 with RevFeatureTypeImpl

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);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) RevFeatureTypeImpl(org.locationtech.geogig.api.RevFeatureTypeImpl) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree)

Example 3 with RevFeatureTypeImpl

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);
}
Also used : RevFeatureTypeImpl(org.locationtech.geogig.api.RevFeatureTypeImpl) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ArrayList(java.util.ArrayList) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) Name(org.opengis.feature.type.Name)

Aggregations

RevFeatureTypeImpl (org.locationtech.geogig.api.RevFeatureTypeImpl)3 ArrayList (java.util.ArrayList)2 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)2 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)2 Name (org.opengis.feature.type.Name)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 Node (org.locationtech.geogig.api.Node)1 NodeRef (org.locationtech.geogig.api.NodeRef)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)1 RevTree (org.locationtech.geogig.api.RevTree)1 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)1