Hanane,

I also tried to parse complex features using gt-wfs-ng and was 
unsuccessful getting it to parse nested features. Here is the Jira issue 
I recorded:
https://osgeo-org.atlassian.net/browse/GEOT-5246

Here is my attempt to write an example:
https://github.com/bencaradocdavies/geotools/commit/9e8d9c22d1f3ddfd0b180f7f53dae17457be9786

In particular, I had to add this line in the implementation or 
maxfeatures is ignored:
https://github.com/bencaradocdavies/geotools/commit/9e8d9c22d1f3ddfd0b180f7f53dae17457be9786#diff-06f3dfd7325273d8e9fbe0043aa98abdR117

I do not know if it is broken for all features types, or just the 
GeoSciML service I tried.

Kind regards,
Ben.

On 06/06/16 23:25, Hanane Eljabiri wrote:
> Hi Everyone,
>
> I am trying to retrieve some complex features served by a WFS service.
>
> The WFS I am trying to parse is created from a specific configuration
> with a mapping file.
>
> The link to the WFS considered is
> https://wfspoc.brgm-rec.fr/geoserver/ows?service=wfs&version=2.0.0&request=GetFeature&typename=ef:EnvironmentalMonitoringFacility&COUNT=1
>
> To respond to my use case, I have tried to use the example of complex
> features request in the following
> linkhttp://old.geotools.org/ComplexFeature-Parsing-and-Building-Support_229736622.html
>
> Unfortunately, I have got the following issues:
>
> 1)    I obtain a null value for the DataStore when I set the proprety
> WFSDataStoreFactory:GML_COMPLIANCE_LEVELto 2. It seems that there is a
> test which compares the value of GMLCompliance Level to a static
> maximum value defined in
> the source of Geotools. The Maximum value has been set to 0 !
>
> I end up by setting the value of GML-Compliance-Level to 0 in my connection
> parameters.
>
> Here is the code I use to establish a connection and to get an
> instance of data store:
>
> // 1. Configure:
>
>
>    String getCapabilitiesURL =
> "https://wfspoc.brgm-rec.fr/geoserver/ows?service=wfs&version=2.0.0&request=GetCapabilities";;
>
>
>    Map<String, Serializable> connectionParameters = *new* HashMap<String,
> Serializable>();
>
>
>    connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
> getCapabilitiesURL);
>
>
>
>
>
>    connectionParameters.put("WFSDataStoreFactory:TIMEOUT", 1000);
>
>
>    connectionParameters.put("WFSDataStoreFactory:PROTOCOL", *false*);
>
>
>    /** #A: Require a Factory with this
> level of compliance. **/
>
>
>    connectionParameters.put("WFSDataStoreFactory:GML_COMPLIANCE_LEVEL", 0);
>
>
>    connectionParameters.put("WFSDataStoreFactory:MAXFEATURES", 2);
>
>
>    /** #B: Specify the location of the
> folder to be used by *app*-schema-resolver. **/
>
>
>    connectionParameters.put("WFSDataStoreFactory:SCHEMA_CACHE_LOCATION",
> "C:/schema_cache");
>
>
>
>
>    // 2. Find suitable DataAccess:
>
>
>    /** #C: Notice that these classes
> are the non-Simple forms. **/
>
>        DataAccess<FeatureType, Feature> dataAccess =
> DataAccessFinder.*getDataStore*(connectionParameters);
>
>
>
> Once I set the gml compliance to 0, I get the next following issue:
>
> 2)    The Geotools parser raises an
> exception when parsing my WFS response when it encounters an empty date value
> for the element : <gml:beginPosition/>
>
> Here is the code I am  using :
>
> // 3. Declare the type you're
> interested in (this could be done by iterating through the typeNames in
> dataStore.getTypeNames()).
>
>
>    Name nameToRetrieve = *new*
> NameImpl("http://inspire.ec.europa.eu/schemas/ef/4.0";, ":",
> "ef_EnvironmentalMonitoringFacility");
>
>
>
>
>    // 4. Get the FeatureSource
> (WFSContentComplexFeatureSource):
>
>
>    FeatureSource<FeatureType,
> Feature> featureSource = dataAccess.getFeatureSource(nameToRetrieve);
>
>
>
>
>
>    // 5. Get the FeatureType (AKA
> schema):
>
>
>    FeatureType schema = dataAccess.getSchema(nameToRetrieve);
>
>
>
>
>    // 6. Create Query using the schema.
>
>
>    Query query = *new* Query("ef_EnvironmentalMonitoringFacility");
>
>
>    query.setMaxFeatures(1);
>
>
>        
> query.setCoordinateSystem(schema.getGeometryDescriptor().getCoordinateReferenceSystem());
>
>
>
>
>    // 7. Get the features and their
> corresponding types:
>
>
>    FeatureCollection<FeatureType,
> Feature> features = featureSource.getFeatures(query);
>
>
>
>
>    // 8. Iterate over the features and
> display them:
>
>
>    FeatureIterator<Feature> iterator = features.features();
>
>
>
>
>    *try* {
>
>
>        *while* (iterator.hasNext()) {
>
>
>            Feature feature = iterator.next();
>
>
>            *for* (Property property : feature.getProperties()) {
>
>
>                System.*out*.println(property);
>
>
>            }
>
>
>        }
>
>
>    } *finally* {
>
>
>        iterator.close();
>
>        }
>
> I get the following error although my WFS response seems to be correct! (I 
> have
> tried to validate the GML using an external xml validator which uses
> xsd mentioned
> in the beginning of the GML response and the result was positive) :
>
>
>
> java.lang.IllegalArgumentException: Failed to
> parse date at:
>
>      at
> org.geotools.xml.impl.DatatypeConverterImpl.parseDate(DatatypeConverterImpl.java:197)
>
>      at
> org.geotools.xs.bindings.XSDateBinding.parse(XSDateBinding.java:105)
>
>      at
> org.geotools.gml3.bindings.TimePositionUnionBinding.parse(TimePositionUnionBinding.java:102)
>
>      at
> org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:154)
>
>      at
> org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:227)
>
>      at
> org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:186)
>
>      at
> org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:236)
>
>      at
> org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:744)
>
>      at
> org.geotools.xml.PullParser.parse(PullParser.java:107)
>
>      at
> org.geotools.data.wfs.internal.parsers.PullParserFeatureReader.parse(PullParserFeatureReader.java:80)
>
>      at
> org.geotools.data.wfs.WFSFeatureReader.<init>(WFSFeatureReader.java:43)
>
>      at
> org.geotools.data.wfs.WFSFeatureSource.getReaderInternal(WFSFeatureSource.java:262)
>
>      at
> org.geotools.data.wfs.WFSFeatureStore.getReaderInternal(WFSFeatureStore.java:154)
>
>      at
> org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:634)
>
>      at
> org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:173)
>
>      at
> org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:58)
>
>      at
> org.datalift.parsingTools.GMLParsing.ComplexFeatureRequest(GMLParsing.java:124)
>
>      at
> org.datalift.parsingTools.GMLParsing.main(GMLParsing.java:79)
>
>
>
> I am using Geotools 14.3 and jdk
> 1.7.0_79
>
> I would appreciate any help to deal with those issues or even if you
> could suggest me another way to parse complex features
> in my WFS response.
>
> Thank you
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
>
>
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

-- 
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <http://transient.nz/>
New Zealand

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to