Search in sources :

Example 91 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class DifferenceGeometryProcess method clipFeature.

/**
 * Clip difference the feature with the Geometry
 *
 * @param newType the new FeatureType for the Feature
 */
public static Feature clipFeature(final Feature oldFeature, final FeatureType newType, final Geometry geometry) {
    final Feature resultFeature = newType.newInstance();
    FeatureExt.setId(resultFeature, FeatureExt.getId(oldFeature));
    for (final PropertyType property : oldFeature.getType().getProperties(true)) {
        final String name = property.getName().toString();
        final Object value = oldFeature.getPropertyValue(name);
        if (AttributeConvention.isGeometryAttribute(property)) {
            final Geometry diffGeometry = VectorProcessUtils.geometryDifference((Geometry) value, geometry);
            if (diffGeometry != null) {
                resultFeature.setPropertyValue(name, diffGeometry);
            } else {
                return null;
            }
        } else if (property instanceof AttributeType && !(AttributeConvention.contains(property.getName()))) {
            resultFeature.setPropertyValue(name, value);
        }
    }
    return resultFeature;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) AttributeType(org.opengis.feature.AttributeType) PropertyType(org.opengis.feature.PropertyType) Feature(org.opengis.feature.Feature)

Example 92 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class IntersectProcess method createFilter.

/**
 * Create an intersect filter between the intersection Geometry
 * and feature geometries
 * @return the intersect filter
 */
private Filter createFilter(FeatureType ft, final Geometry interGeom) {
    final List<Filter<Object>> filterList = new ArrayList<>();
    for (final PropertyType property : ft.getProperties(true)) {
        if (AttributeConvention.isGeometryAttribute(property)) {
            final Filter filter = FF.intersects(FF.property(property.getName()), FF.literal(interGeom));
            filterList.add(filter);
        }
    }
    return FF.or(filterList);
}
Also used : Filter(org.opengis.filter.Filter) ArrayList(java.util.ArrayList) PropertyType(org.opengis.feature.PropertyType)

Example 93 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class GMLStore method getCollectionSubType.

/**
 * Determinate if give type is a FeatureCollection type.
 * @return the children collection feature type or base feature type if type is not a collection
 */
private static FeatureType getCollectionSubType(FeatureType featureType) {
    boolean isCollectionType = false;
    // check if type is a Feature Collection, for GML up to version 3.2.1
    if (isGmlCollectionType(featureType)) {
        // TODO which property is the sub feature type ?
        return featureType;
    }
    // check if an attribute is a gml feature member, from GML version 3.0
    FeatureType subType = featureType;
    if (!isCollectionType) {
        Collection<? extends PropertyType> properties = featureType.getProperties(true);
        for (PropertyType property : properties) {
            if (property instanceof FeatureAssociationRole) {
                final FeatureAssociationRole far = (FeatureAssociationRole) property;
                final FeatureType valueType = far.getValueType();
                if (isGmlCollectionMemberType(valueType)) {
                    subType = valueType;
                }
            }
        }
    }
    // not a collection type
    return subType;
}
Also used : FeatureType(org.opengis.feature.FeatureType) PropertyType(org.opengis.feature.PropertyType) FeatureAssociationRole(org.opengis.feature.FeatureAssociationRole)

Example 94 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class ShapefileFeatureStore method getAttributes.

protected List<AttributeType> getAttributes(FeatureType type, boolean includeIdentifier) {
    final Collection<? extends PropertyType> properties = type.getProperties(true);
    final List<AttributeType> atts = new ArrayList<>();
    for (PropertyType p : properties) {
        if (!includeIdentifier && p.getName().equals(AttributeConvention.IDENTIFIER_PROPERTY))
            continue;
        if (p instanceof AttributeType) {
            atts.add((AttributeType) p);
        }
    }
    return atts;
}
Also used : AttributeType(org.opengis.feature.AttributeType) ArrayList(java.util.ArrayList) PropertyType(org.opengis.feature.PropertyType)

Example 95 with PropertyType

use of org.opengis.feature.PropertyType in project geotoolkit by Geomatys.

the class PostgresVersionControl method dropVersioning.

private void dropVersioning(final String schemaName, final FeatureType type, final Set<FeatureType> visited) throws VersioningException {
    if (visited.contains(type))
        return;
    visited.add(type);
    final String tableName = type.getName().tip().toString();
    // drop complex properties versioning
    for (PropertyType desc : type.getProperties(true)) {
        if (desc instanceof FeatureAssociationRole) {
            // complex type, drop sub table history
            FeatureAssociationRole far = (FeatureAssociationRole) desc;
            dropVersioning(schemaName, far.getValueType(), visited);
        }
    }
    final StringBuilder sb = new StringBuilder("SELECT \"HS_DropHistory\"(");
    sb.append('\'');
    if (schemaName != null && !schemaName.isEmpty()) {
        sb.append(schemaName).append('.');
    }
    sb.append(tableName);
    sb.append('\'');
    sb.append(");");
    Connection cnx = null;
    Statement stmt = null;
    try {
        cnx = featureStore.getDataSource().getConnection();
        stmt = cnx.createStatement();
        stmt.executeQuery(sb.toString());
    } catch (SQLException ex) {
        throw new VersioningException(ex.getMessage(), ex);
    } finally {
        JDBCFeatureStoreUtilities.closeSafe(featureStore.getLogger(), cnx, stmt, null);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) VersioningException(org.geotoolkit.version.VersioningException) PropertyType(org.opengis.feature.PropertyType) FeatureAssociationRole(org.opengis.feature.FeatureAssociationRole)

Aggregations

PropertyType (org.opengis.feature.PropertyType)124 AttributeType (org.opengis.feature.AttributeType)55 FeatureType (org.opengis.feature.FeatureType)48 Feature (org.opengis.feature.Feature)41 ArrayList (java.util.ArrayList)38 Geometry (org.locationtech.jts.geom.Geometry)37 FeatureAssociationRole (org.opengis.feature.FeatureAssociationRole)26 GenericName (org.opengis.util.GenericName)26 FeatureTypeBuilder (org.apache.sis.feature.builder.FeatureTypeBuilder)24 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)22 PropertyNotFoundException (org.opengis.feature.PropertyNotFoundException)20 Operation (org.opengis.feature.Operation)18 DataStoreException (org.apache.sis.storage.DataStoreException)16 Test (org.junit.Test)13 LineString (org.locationtech.jts.geom.LineString)12 HashMap (java.util.HashMap)11 Filter (org.opengis.filter.Filter)11 IOException (java.io.IOException)9 SQLException (java.sql.SQLException)9 FeatureSet (org.apache.sis.storage.FeatureSet)9