Object result = resultMap.get(BufferFactory.RESULT.key);
Geometry bufferedGeom = geom1.buffer(buffer);
}
public static void example3() {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
tb.setName("featureType");
tb.add("geometry", Point.class);
tb.add("integer", Integer.class);
GeometryFactory gf = new GeometryFactory();
SimpleFeatureBuilder b = new SimpleFeatureBuilder(tb.buildFeatureType());
DefaultFeatureCollection features = new DefaultFeatureCollection(null, b.getFeatureType());
for (int i = 0; i < 2; i++) {
b.add(gf.createPoint(new Coordinate(i, i)));
b.add(i);
features.add(b.buildFeature(i + ""));
}
Map<String, Object> input = new HashMap();
input.put(BufferFeatureCollectionFactory.FEATURES.key, features);
input.put(BufferFeatureCollectionFactory.BUFFER.key, 10d);
BufferFeatureCollectionFactory factory = new BufferFeatureCollectionFactory();
BufferFeatureCollectionProcess process = factory.create();
Map<String, Object> output = process.execute(input, null);
FeatureCollection buffered = (FeatureCollection) output
.get(BufferFeatureCollectionFactory.RESULT.key);
assertEquals(2, buffered.size());
for (int i = 0; i < 2; i++) {
Geometry expected = gf.createPoint(new Coordinate(i, i)).buffer(10d);
FeatureCollection sub = buffered.subCollection(ff.equals(ff.property("integer"),
ff.literal(i)));
assertEquals(1, sub.size());
FeatureIterator iterator = sub.features();
SimpleFeature sf = (SimpleFeature) iterator.next();
assertTrue(expected.equals((Geometry) sf.getDefaultGeometry()));
iterator.close();