Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Features into FeatureCollection

Damjan Šavko wrote:
Simple question: how can I add features to a FeatureCollection?

The goal is to copy data from a dbf file to a shapefile. I take the data (do some work with them), create a Feature with a certain FeatureType and put the data into the feature. Now I need to getter my features into a FeatureCollection of some sort. I use FeatureStore.addFeatures(FeatureCollection) to save the data into a shapefile and it works fine with FeatureCollections obtained by premade shapefiles. How can I make my own FeatureCollection (all the constructors and methods to do that are protected!) and put my features in it?
Every time I need to do something that is not easy with features I have put a method in DataUtilities:
http://udig.refractions.net/docs/api-geotools/org/geotools/data/DataUtilities.html#collection(org.geotools.feature.Feature[])

Not the best but it will get you going.

Here is a more happy way:
- http://udig.refractions.net/docs/api-geotools/org/geotools/feature/DefaultFeatureCollections.html#createCollection(java.lang.String,%20org.geotools.feature.FeatureType)

Happy hacking,
Jody



Back to the top