You are nearly there. Here is your method slightly modified...
public Layer createNewLayer(SimpleFeatureCollection source,
String filterString, Style style) {
try {
Filter filter = CQL.toFilter(filterString);
ListFeatureCollection subset = new
ListFeatureCollection(source.subCollection(filter));
return new FeatureLayer(subset, style);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
Michael
On 28 July 2011 01:45, lexmc <[email protected]> wrote:
> You are right Micheal. Ok I try to explain,
> this is my code(temporary and incpmplete for this function):
>
> public CreateNewLayer(String a)
> {
> Filter filter;
> try {
> filter = CQL.toFilter(a);
> SimpleFeatureCollection myFeatureCollection = null;
> try {
> ListFeatureCollection subset = new
> ListFeatureCollection(myFeatureCollection.subCollection(filter));
> } catch (IOException e) {
> e.printStackTrace();
> }
> } catch (CQLException e) {
> e.printStackTrace();
> }
>
> }
>
> I don't know hot to put my filter in a featuresource and in a new layer
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Create-a-new-layer-tp6617789p6626641.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