Maybe some precision:

on a FeatureSource retrieved from WFS Datastore, is it possible to apply a Query to which we set a Hint? i.e. using Hint.VIRTUAL_TABLE_PARAMETER and the viewParams in a HashMap I tried to apply such query (see code velow) and get the corresponding feature collection, but does not work: I still get the default feature collection (i.e. corresponding to the default view params set in Geoserver)

Thanks in advance
Emmanuel

/// viewParams
//------------------
Map<String,String> viewParams = new HashMap<String,String>();

        viewParams.put("p1","v1");
        viewParams.put("p2","v2");
        viewParams.put("p3","v3");

// Datastore
//--------------
URL url = null;
        try {
url = new URL( "http://localhost:8080/geoserver/wfs?request=GetCapabilities&VERSION=1.0.0"; );
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

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 = null;
        try {
            store = DataStoreFinder.getDataStore(params);
        } catch (IOException e) {
            e.printStackTrace();
        }


 //Layername
//----------------
 String typeName = "mylayer";

 //WFS Layer
FeatureSource<? extends FeatureType, ? extends Feature> featureSource = null;
        try {
            featureSource = store.getFeatureSource(typeName);
            System.out.println(typeName);
        } catch (IOException e) {
            e.printStackTrace();
        }


//Query
----------
Hints hints = new Hints();
hints.put(Hints.VIRTUAL_TABLE_PARAMETERS, viewParams);
Query query = new Query(Query.ALL);
query.setHints(hints);


//Size of Feature Collection

        try {
            System.out.println(featureSource.getFeatures(query).size());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }/

Le 27/02/2012 17:06, Emmanuel Blondel a écrit :
Dear all,

I am currently using WFSDatastore in Geotools to get the features from a Geoserver. I need to get the features from layers built on a SQL view, i.e. that allows view parameters ("viewparams") in WMS and WFS requests

I created parameters using WFSDataStoreFactory and then created a datastore with DataStoreFinder. I want to get the FeatureSource but only for specific view parameter values. Is it possible to specify values for the view parameters with the WFS geotools plugin? in order to get only the features corresponding to these view parameters.

Thanks in advance for your help,

Emmanuel

--
*Emmanuel Blondel*
GIS Consultant

Geographic Information Systems
in Agronomy - Environment -Fisheries
Email: [email protected] - [email protected]



--
*Emmanuel Blondel*
GIS Consultant

Geographic Information Systems
in Agronomy - Environment -Fisheries
Email: [email protected] - [email protected]
Phone: +33 (0) 6 45 97 87 52
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to