use of org.locationtech.geogig.api.data.ForwardingFeatureCollection in project GeoGig by boundlessgeo.
the class ImportOp method getFeatureSource.
@SuppressWarnings({ "rawtypes", "unchecked" })
private FeatureSource getFeatureSource(String typeName) {
FeatureSource featureSource;
try {
featureSource = dataStore.getFeatureSource(typeName);
} catch (Exception e) {
throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_FEATURES);
}
return new ForwardingFeatureSource(featureSource) {
@Override
public FeatureCollection getFeatures(Query query) throws IOException {
final FeatureCollection features = super.getFeatures(query);
return new ForwardingFeatureCollection(features) {
@Override
public FeatureIterator features() {
final FeatureType featureType = getSchema();
final String fidPrefix = featureType.getName().getLocalPart() + ".";
FeatureIterator iterator = delegate.features();
return new FidAndFtReplacerIterator(iterator, fidAttribute, fidPrefix, (SimpleFeatureType) featureType);
}
};
}
};
}
use of org.locationtech.geogig.api.data.ForwardingFeatureCollection in project GeoGig by boundlessgeo.
the class FeatureTypeAdapterFeatureSource method getFeatures.
@Override
public FeatureCollection<T, F> getFeatures(Query query) throws IOException {
final FeatureCollection<T, F> features = super.getFeatures(query);
return new ForwardingFeatureCollection<T, F>(features) {
@Override
public FeatureIterator<F> features() {
if (delegate.getSchema().getDescriptors().size() != featureType.getDescriptors().size()) {
throw new GeoToolsOpException(GeoToolsOpException.StatusCode.INCOMPATIBLE_FEATURE_TYPE);
}
GeometryDescriptor geomDescriptorOrg = delegate.getSchema().getGeometryDescriptor();
GeometryDescriptor geomDescriptorDest = featureType.getGeometryDescriptor();
if (!geomDescriptorOrg.getType().getBinding().equals(geomDescriptorDest.getType().getBinding()) || !geomDescriptorOrg.getType().getCoordinateReferenceSystem().equals(geomDescriptorDest.getType().getCoordinateReferenceSystem())) {
throw new GeoToolsOpException(GeoToolsOpException.StatusCode.INCOMPATIBLE_FEATURE_TYPE);
}
FeatureIterator<F> iterator = delegate.features();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder((SimpleFeatureType) featureType);
return new FeatureTypeConverterIterator<F>(iterator, (SimpleFeatureBuilder) builder);
}
@Override
public T getSchema() {
return featureType;
}
};
}
Aggregations