The data source doesn't have to be a SimpleFeatureCollection - that
was the example I used because (I think) it was mentioned a few posts
ago.
If you are working with a FeatureSource you can apply your filter to
it and make your Layer with the results...
public Layer createNewLayer(SimpleFeatureSource source,
String filterString, Style style) {
try {
Filter filter = CQL.toFilter(filterString);
return new FeatureLayer(featureSource.getFeatures( filter ), style);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
Note, this example doesn't save the filter results as a new feature
collection in your code but you can do that if you want as was done in
the example in the previous post.
The Query tutorial is a good one to look at if you haven't already:
http://docs.geotools.org/latest/userguide/tutorial/filter/query.html
Michael
On 28 July 2011 20:33, lexmc <[email protected]> wrote:
> Thank you Micheal your help is so precious! I only have a doubt: how I have
> to initialize the simplefeaturecollection?
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Create-a-new-layer-tp6617789p6629359.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Got Input? Slashdot Needs You.
> Take our quick survey online. Come on, we don't ask for help often.
> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
> http://p.sf.net/sfu/slashdot-survey
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users