Search in sources :

Example 6 with GeometryDescriptor

use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.

the class RevFeatureSerializationTest 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 7 with GeometryDescriptor

use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.

the class OSMExportPG 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)

Example 8 with GeometryDescriptor

use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.

the class OSMExportShp 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)

Example 9 with GeometryDescriptor

use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.

the class RepositoryTestCase 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 10 with GeometryDescriptor

use of org.opengis.feature.type.GeometryDescriptor in project GeoGig by boundlessgeo.

the class TestFeatures method feature.

public static 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)

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