use of org.geotools.feature.simple.SimpleFeatureTypeBuilder in project GeoGig by boundlessgeo.
the class ImportOp method forceFeatureTypeName.
private SimpleFeatureType forceFeatureTypeName(SimpleFeatureType featureType, String path) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setAttributes(featureType.getAttributeDescriptors());
builder.setName(new NameImpl(featureType.getName().getNamespaceURI(), path));
builder.setCRS(featureType.getCoordinateReferenceSystem());
featureType = builder.buildFeatureType();
return featureType;
}
use of org.geotools.feature.simple.SimpleFeatureTypeBuilder in project ddf by codice.
the class TestPubSubOgcFilter method generateSampleFeature.
private SimpleFeature generateSampleFeature() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("PubSubFeature");
// add properties
b.add("name", String.class);
b.add("classification", Integer.class);
b.add("height", Double.class);
com.vividsolutions.jts.geom.GeometryFactory geoFactory = JTSFactoryFinder.getGeometryFactory(null);
// add geo
b.setCRS(DefaultGeographicCRS.WGS84);
b.add("geo", Point.class);
final SimpleFeatureType pubSubFeature = b.buildFeatureType();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(pubSubFeature);
featureBuilder.set("name", "FirstFeature");
featureBuilder.set("classification", 10);
featureBuilder.set("height", 5.8);
com.vividsolutions.jts.geom.Point point = geoFactory.createPoint(new Coordinate(-112, 28));
featureBuilder.set("geo", point);
SimpleFeature feature = featureBuilder.buildFeature("f1");
// it looks like if I add an attribute into the feature that is of geometry type, it
// automatically
// becomes the default geo property. If no geo is specified, getDefaultGeometryProperty
// returns null
GeometryAttribute defaultGeo = feature.getDefaultGeometryProperty();
LOGGER.debug("geo name: {}", defaultGeo.getName());
LOGGER.debug("geo: {}", defaultGeo);
return feature;
}
Aggregations