After some fiddling about I can get features if I remove the wfs: prefix
from the typename
String name = types[i].substring(types[i].indexOf(':')+1);
and add a coordinate system to the query object (not sure if this is
essential or not)
query.setCoordinateSystem(DefaultGeographicCRS.WGS84);
Ian
On 30 August 2016 at 17:38, Hanane Eljabiri <[email protected]>
wrote:
> Hi everyone,
>
> I am using the wfs-ng plugin to ceate a wfs client. Until now, the library
> works pretty fine when it comes to establish a connection with a Geoserver
> WFS. When it comes to a Mapserver WFS, my program fails to get features. In
> fact, the feature collection I get from the source seems to be empty.
>
> I provide below the code I am using with an example of a WFS URL.
>
> String getCapabilities = "http://ws.carmencarto.fr/WFS/
> 119/fxx_grille?service=wfs&REQUEST=GetCapabilities&version=1.1.0";
>
>
>
> *Map* connectionParameters = *new* *HashMap*();
>
> *connectionParameters**.put(*
> *"WFSDataStoreFactory:GET_CAPABILITIES_URL"**, **getCapabilities** )*;
>
> *connectionParameters**.put(*
> *"WFSDataStoreFactory:WFS_STRATEGY"**, **"mapserver"**)*;
>
> *connectionParameters**.put(*
> *"WFSDataStoreFactory:WFSDataStoreFactory:TIMEOUT"**,10000000)*;
>
>
>
> // Step 2 - connection
>
> DataStore data = DataStoreFinder.*getDataStore*(
> connectionParameters );
>
>
>
> // Step 3 - *discouvery*
>
> String typeNames[] = data.getTypeNames();
>
> String typeName = typeNames[0];
>
> // Step 4 - target
>
> FeatureSource<SimpleFeatureType, SimpleFeature> source =
> data.getFeatureSource(
> typeName );
>
>
>
>
>
> Query query = *new* *DefaultQuery**( **typeName** )*;
>
> FeatureCollection<SimpleFeatureType, SimpleFeature> features
> = source.getFeatures( query );
>
> FeatureIterator<SimpleFeature> fi=features.features();
>
>
>
> *try* {
>
> *while*( fi.hasNext() )
>
> { //the following code is never executed because the
> iterator is has
>
> // no next element !
>
> Feature feature = (Feature) fi.next();
>
> //do some stuff using the featureā¦
>
> }
>
> }*catch* (Exception e)
>
> {
>
> e.printStackTrace();
>
> }
>
> Did I miss something in the configuration?
>
> I would be thankful if someone could help me to understand why I could not
> get features from this WFS.
>
> Best regards
>
> --
>
> Hanane
>
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
Ian Turton
------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users