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;
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations