Dear all,

I started using Geotools & I have some issue in using the *CachingFeatureSource* (presented here: http://geotoolsnews.blogspot.com/2010_04_01_archive.html) When I don't use the CachingFeatureSource, I can get all the features I want. If I use the cache, I don't get all features.
Do you have any idea about how to solve this? You will find the code below.

Thanks a lot  in advance for your answers,

Regards,
Emmanuel

Code:

/URL url = new URL( Constants.localGeoserverWFS );
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put(WFSDataStoreFactory.URL.key, url);
params.put(WFSDataStoreFactory.TIMEOUT.key, new Integer(60000));
params.put(WFSDataStoreFactory.MAXFEATURES.key, new Integer(200000));
params.put(WFSDataStoreFactory.WFS_STRATEGY.key, "geoserver");

DataStore store = DataStoreFinder.getDataStore(params);

String typeName = "fao:t_statarea_csquare05_hseez_wgs84";
SimpleFeatureSource featureSource = store.getFeatureSource(typeName);

//Filter
String textFilterEEZ ="geocode_1 IN('21','31') AND geocode_3 ='163'";
Filter filterEEZ = ECQL.toFilter(textFilterEEZ);
Query query = new Query( typeName, filterEEZ);

//Cache
CachingFeatureSource cacheFeatureSource = new CachingFeatureSource(featureSource);
SimpleFeatureCollection features = cacheFeatureSource.getFeatures(query);

//Default style
StyleBuilder sb1 = new StyleBuilder();
PolygonSymbolizer ps1 = sb1.createPolygonSymbolizer(new Color(185, 211, 238), new Color(58, 95, 205), 1);
Style style = sb1.createStyle(ps1);

//MapContext
MapContext map = new DefaultMapContext();
map.setTitle("Using cached features");
map.addLayer(features, style);
JMapFrame.showMap(map);/
--
*Emmanuel Blondel*
GIS Consultant

Geographic Information Systems
in Agronomy - Environment -Fisheries
Email: [email protected] - [email protected]
Phone: +33 (0) 6 45 97 87 52
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to