Hi Jody,
(using version 2.6)
Yes, you're right, the same works like this :
filter = CQL.toFilter("status LIKE 'ON'");
map.addLayer(featureSource, null);
Query myQuery = new DefaultQuery(myLayerFT,filter);
map.getLayer(myLayer).setQuery(myQuery);
And, as you said, this is probably a better way.....
Thanks !
Fred.
On Mon, Jul 12, 2010 at 7:32 AM, Jody Garnett <[email protected]>wrote:
> Can I ask you to try things in a slightly different way ....
>
> 1. Create your map layer using the FeatureSource
> 2. Set the filter on the map layer
>
> This way the renderer can make an efficient query by combining your filter
> with any filters provided by the style; and it won't end up using
> ContentFeatureCollection at all.
>
> Jody
>
> On 11/07/2010, at 9:12 PM, Fred Lehodey wrote:
>
> > Dears,
> >
> > Using gt 2.6 with Postgis tables:
> >
> > filter = CQL.toFilter("status LIKE 'ON'");
> > FeatureCollection<SimpleFeatureType, SimpleFeature> collection =
> featureSource.getFeatures( filter );
> > //System.out.println(collection.size()); // ok, returns good result...
> >
> > But:
> > map.addLayer(collection, null);
> >
> > Give:
> > Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException:
> Must call hasNext before calling next
> > at
> org.geotools.jdbc.JDBCFeatureReader.ensureNext(JDBCFeatureReader.java:238)
> > at
> org.geotools.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:252)
> > at
> org.geotools.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:82)
> > at
> org.geotools.data.store.ContentFeatureCollection$WrappingIterator.next(ContentFeatureCollection.java:248)
> > at
> org.geotools.data.collection.CollectionDataStore.<init>(CollectionDataStore.java:78)
> > at org.geotools.data.DataUtilities.source(DataUtilities.java:930)
> > at
> org.geotools.map.DefaultMapLayer.<init>(DefaultMapLayer.java:157)
> > at
> org.geotools.map.DefaultMapContext.addLayer(DefaultMapContext.java:394)
> > at FataMap.mapita.ReturnMapContext(mapita.java:480)
> > ......
> >
> > Thanks for any hints..
> >
> > Fred.
> >
> >
> >
> ------------------------------------------------------------------------------
> > This SF.net email is sponsored by Sprint
> > What will you do first with EVO, the first 4G phone?
> > Visit sprint.com/first --
> http://p.sf.net/sfu/sprint-com-first_______________________________________________
> > Geotools-gt2-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users