Search in sources :

Example 11 with GeometryDescriptor

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;
        }
    };
}
Also used : GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor) ForwardingFeatureCollection(org.locationtech.geogig.api.data.ForwardingFeatureCollection) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 12 with GeometryDescriptor

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);
}
Also used : GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor) WKTReader2(org.geotools.geometry.jts.WKTReader2) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 13 with GeometryDescriptor

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";
    }
}
Also used : GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor)

Aggregations

GeometryDescriptor (org.opengis.feature.type.GeometryDescriptor)13 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)6 WKTReader2 (org.geotools.geometry.jts.WKTReader2)5 Optional (com.google.common.base.Optional)1 Point (com.vividsolutions.jts.geom.Point)1 DataStore (org.geotools.data.DataStore)1 GeometryAttributeImpl (org.geotools.feature.GeometryAttributeImpl)1 ProgressListener (org.locationtech.geogig.api.ProgressListener)1 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)1 ForwardingFeatureCollection (org.locationtech.geogig.api.data.ForwardingFeatureCollection)1 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)1 InvalidParameterException (org.locationtech.geogig.cli.InvalidParameterException)1 GeoToolsOpException (org.locationtech.geogig.geotools.plumbing.GeoToolsOpException)1 ImportOp (org.locationtech.geogig.geotools.plumbing.ImportOp)1 GeometryAttribute (org.opengis.feature.GeometryAttribute)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1