use of org.opengis.feature.AttributeType in project geotoolkit by Geomatys.
the class SpatialJoinProcess method copyAttributes.
/**
* This function copy attributes from source to target Feature except geometry descriptor.
* The copied attributes name will be "attributeName_sourceFeatureTypeName".
* @param target targetFeature
* @param source source Feature
* @param concatType concatenated FeatureType
* @return the resulting Feature
*/
static Feature copyAttributes(final Feature target, final Feature source, final FeatureType concatType) {
final Feature resultFeature = concatType.newInstance();
resultFeature.setPropertyValue(AttributeConvention.IDENTIFIER, FeatureExt.getId(target).getIdentifier() + "_" + FeatureExt.getId(source).getIdentifier());
// copy target Feature
for (final PropertyType targetProperty : target.getType().getProperties(true)) {
if (targetProperty instanceof AttributeType && !AttributeConvention.contains(targetProperty.getName())) {
final String name = targetProperty.getName().toString();
resultFeature.setPropertyValue(name, target.getPropertyValue(name));
}
}
// copy source Feature except geometry descriptor
for (final PropertyType sourceProperty : source.getType().getProperties(true)) {
if (sourceProperty instanceof AttributeType && !AttributeConvention.contains(sourceProperty.getName())) {
if (!AttributeConvention.isGeometryAttribute(sourceProperty)) {
final String name = sourceProperty.getName().tip().toString();
final String rename = name + "_" + source.getType().getName().tip().toString();
try {
resultFeature.setPropertyValue(rename, source.getPropertyValue(name));
} catch (IllegalArgumentException ex) {
resultFeature.setPropertyValue(name, source.getPropertyValue(name));
}
}
}
}
return resultFeature;
}
Aggregations