use of org.opengis.feature.type.GeometryDescriptor 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;
}
};
}
use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.
the class HashObjectTest method feature.
protected Feature feature(SimpleFeatureType type, String id, Object... values) throws ParseException {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
for (int i = 0; i < values.length; i++) {
Object value = values[i];
if (type.getDescriptor(i) instanceof GeometryDescriptor) {
if (value instanceof String) {
value = new WKTReader2().read((String) value);
}
}
builder.set(i, value);
}
return builder.buildFeature(id);
}
use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.
the class OSMExportSL method getOriginTreesFromOutputFeatureType.
private String getOriginTreesFromOutputFeatureType(SimpleFeatureType featureType) {
GeometryDescriptor descriptor = featureType.getGeometryDescriptor();
Class<?> clazz = descriptor.getType().getBinding();
if (clazz.equals(Point.class)) {
return "node";
} else {
return "way";
}
}
Aggregations