Search in sources :

Example 6 with Name

use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.

the class GeoGigDataStore method getDiffFeatureSource.

/**
     * Builds a FeatureSource (read-only) that fetches features out of the differences between two
     * root trees: a provided tree-ish as the left side of the comparison, and the datastore's
     * configured HEAD as the right side of the comparison.
     * <p>
     * E.g., to get all features of a given feature type that were removed between a given commit
     * and its parent:
     * 
     * <pre>
     * <code>
     * String commitId = ...
     * GeoGigDataStore store = new GeoGigDataStore(geogig);
     * store.setHead(commitId);
     * FeatureSource removed = store.getDiffFeatureSource("roads", commitId + "~1", ChangeType.REMOVED);
     * </code>
     * </pre>
     * 
     * @param typeName the feature type name to look up a type tree for in the datastore's current
     *        {@link #getOrFigureOutHead() HEAD}
     * @param oldRoot a tree-ish string that resolves to the ROOT tree to be used as the left side
     *        of the diff
     * @param changeType the type of change between {@code oldRoot} and
     *        {@link #getOrFigureOutHead() head} to pick as the features to return.
     * @return a feature source whose features are computed out of the diff between the feature type
     *         diffs between the given {@code oldRoot} and the datastore's
     *         {@link #getOrFigureOutHead() HEAD}.
     */
public SimpleFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot, final ChangeType changeType) throws IOException {
    Preconditions.checkNotNull(typeName, "typeName");
    Preconditions.checkNotNull(oldRoot, "oldRoot");
    Preconditions.checkNotNull(changeType, "changeType");
    final Name name = name(typeName);
    final ContentEntry entry = ensureEntry(name);
    GeogigFeatureSource featureSource = new GeogigFeatureSource(entry);
    featureSource.setTransaction(Transaction.AUTO_COMMIT);
    featureSource.setChangeType(changeType);
    if (ObjectId.NULL.toString().equals(oldRoot) || RevTree.EMPTY_TREE_ID.toString().equals(oldRoot)) {
        featureSource.setOldRoot(null);
    } else {
        featureSource.setOldRoot(oldRoot);
    }
    return featureSource;
}
Also used : ContentEntry(org.geotools.data.store.ContentEntry) Name(org.opengis.feature.type.Name)

Example 7 with Name

use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method getTypeRef.

/**
     * @return
     */
NodeRef getTypeRef() {
    GeoGigDataStore dataStore = getDataStore();
    Name name = getName();
    Transaction transaction = getTransaction();
    return dataStore.findTypeRef(name, transaction);
}
Also used : Transaction(org.geotools.data.Transaction) Name(org.opengis.feature.type.Name)

Example 8 with Name

use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method buildFeatureType.

@Override
protected SimpleFeatureType buildFeatureType() throws IOException {
    SimpleFeatureType featureType = getNativeType();
    final Name name = featureType.getName();
    final Name assignedName = getEntry().getName();
    if (assignedName.getNamespaceURI() != null && !assignedName.equals(name)) {
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.init(featureType);
        builder.setName(assignedName);
        featureType = builder.buildFeatureType();
    }
    return featureType;
}
Also used : SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Name(org.opengis.feature.type.Name)

Example 9 with Name

use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.

the class ListOp method _call.

/**
     * Executes the list operation on the provided data store.
     * 
     * @return a list of all tables, or Optional.absent() if none were found
     */
@Override
protected Optional<List<String>> _call() {
    if (dataStore == null) {
        throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED);
    }
    List<String> features = new ArrayList<String>();
    boolean foundTable = false;
    List<Name> typeNames;
    try {
        typeNames = dataStore.getNames();
    } catch (Exception e) {
        throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES);
    }
    for (Name typeName : typeNames) {
        foundTable = true;
        features.add(typeName.toString());
    }
    if (!foundTable) {
        return Optional.absent();
    }
    return Optional.of(features);
}
Also used : ArrayList(java.util.ArrayList) Name(org.opengis.feature.type.Name)

Example 10 with Name

use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.

the class RemoteRepositoryTestCase method delete.

protected boolean delete(GeoGIG geogig, Feature f) throws Exception {
    final WorkingTree workTree = geogig.getRepository().workingTree();
    Name name = f.getType().getName();
    String localPart = name.getLocalPart();
    String id = f.getIdentifier().getID();
    boolean existed = workTree.delete(localPart, id);
    return existed;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) Name(org.opengis.feature.type.Name)

Aggregations

Name (org.opengis.feature.type.Name)26 WorkingTree (org.locationtech.geogig.repository.WorkingTree)9 Test (org.junit.Test)6 Node (org.locationtech.geogig.api.Node)5 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)5 ObjectId (org.locationtech.geogig.api.ObjectId)4 Feature (org.opengis.feature.Feature)4 SimpleFeature (org.opengis.feature.simple.SimpleFeature)4 ArrayList (java.util.ArrayList)3 GeoGIG (org.locationtech.geogig.api.GeoGIG)3 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)3 Optional (com.google.common.base.Optional)2 LinkedList (java.util.LinkedList)2 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)2 RevFeatureTypeImpl (org.locationtech.geogig.api.RevFeatureTypeImpl)2 FieldType (org.locationtech.geogig.storage.FieldType)2 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)2 AttributeType (org.opengis.feature.type.AttributeType)2 GeometryType (org.opengis.feature.type.GeometryType)2 FactoryException (org.opengis.referencing.FactoryException)2