Hello everyone,

we are having problems creating a SimpleFeature from a Geometry. These 
are our steps:

1. Read a number of features from a Shapefile

File file1 = new File("bla.shp");
FileDataStore store1 = FileDataStoreFinder.getDataStore(file1);
SimpleFeatureSource featureSource1 = store1.getFeatureSource();
SimpleFeatureCollection s1 = featureSource1.getFeatures();

2. Get a specific feature from the collection and buffer

SimpleFeature feature1 = ....
Geometry geom1 = (Geometry) feature1.getDefaultGeometry();
Geometry buffer = geom1.buffer( 0.1 );

3. Converting the buffer-Geometry back to a SimpleFeature for further 
processing / visualization

We tried:

feature.setDefaultGeometry(buffer); // ---> Doesn't work

We have also tried using the SimpleFeatureBuilder to create a new 
Feature, but it didn't work out:

SimpleFeatureType featureType = feature1.getType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);

builder.add( buffer );
builder.add( "theName" );

SimpleFeature x = builder.buildFeature( "fid908" );
s1.add(x); // --> returns false, so does not work

How the hell do we convert the buffer-Geometry to a Simple Feature? Can 
anyone help with simple step by step instructions or an URL?

Kind regards

Bryan Hempen

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to