Search in sources :

Example 11 with Name

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

the class RemoteRepositoryTestCase method insert.

/**
     * Inserts the feature to the index but does not stages it to be committed
     */
protected ObjectId insert(GeoGIG geogig, Feature f) throws Exception {
    final WorkingTree workTree = geogig.getRepository().workingTree();
    Name name = f.getType().getName();
    String parentPath = name.getLocalPart();
    Node ref = workTree.insert(parentPath, f);
    ObjectId objectId = ref.getObjectId();
    return objectId;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name)

Example 12 with Name

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

the class GeoGigDataStoreTest method testGetSchemaProvidedNamespace.

@Test
public void testGetSchemaProvidedNamespace() throws Exception {
    String namespace = "http://www.geogig.org/test";
    dataStore.setNamespaceURI(namespace);
    insertAndAdd(lines1);
    commit();
    SimpleFeatureType lines = dataStore.getSchema(RepositoryTestCase.linesTypeName);
    Name expectedName = new NameImpl(namespace, linesName);
    assertEquals(expectedName, lines.getName());
    assertEquals(super.linesType.getAttributeDescriptors(), lines.getAttributeDescriptors());
    insertAndAdd(points1);
    commit();
    SimpleFeatureType points = dataStore.getSchema(RepositoryTestCase.pointsTypeName);
    assertEquals(new NameImpl(namespace, pointsName), points.getName());
    assertEquals(super.pointsType.getAttributeDescriptors(), points.getAttributeDescriptors());
}
Also used : NameImpl(org.geotools.feature.NameImpl) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) LineString(com.vividsolutions.jts.geom.LineString) Name(org.opengis.feature.type.Name) Test(org.junit.Test)

Example 13 with Name

use of org.opengis.feature.type.Name 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;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name)

Example 14 with Name

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

the class RepositoryTestCase method delete.

public boolean delete(GeogigTransaction transaction, Feature f) throws Exception {
    final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo.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)

Example 15 with Name

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

the class DescribeOp method _call.

/**
     * Describes a table from the data store that has been assigned.
     * 
     * @return a map that contains all properties and their types from the provided table
     */
@Override
protected Optional<Map<String, String>> _call() {
    if (dataStore == null) {
        throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED);
    }
    if (table == null || table.isEmpty()) {
        throw new GeoToolsOpException(StatusCode.TABLE_NOT_DEFINED);
    }
    Map<String, String> propertyMap = new HashMap<String, 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) {
        if (!table.equals(typeName.toString()))
            continue;
        foundTable = true;
        SimpleFeatureSource featureSource;
        try {
            featureSource = dataStore.getFeatureSource(typeName);
        } catch (Exception e) {
            throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_FEATURES);
        }
        SimpleFeatureType featureType = featureSource.getSchema();
        Collection<PropertyDescriptor> descriptors = featureType.getDescriptors();
        for (PropertyDescriptor descriptor : descriptors) {
            propertyMap.put(descriptor.getName().toString(), descriptor.getType().getBinding().getSimpleName());
        }
    }
    if (!foundTable) {
        return Optional.absent();
    }
    return Optional.of(propertyMap);
}
Also used : SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) HashMap(java.util.HashMap) SimpleFeatureSource(org.geotools.data.simple.SimpleFeatureSource) 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