That happens when your WFS does not set up its DescribeFeatureType
correctly; you may need to configure the parser to be able to resolve to the
schema correctly? Or check the xml output and make sure to correctly
references the wfs DescribeFeatureType; and then check the results of
DescribeFeatureType to make sure it makes sense...

In the GML utility class I have some extra processing that will attempt to
fake things; but looking at the HashMaps returned and building a feature
type that matches that kind of contents; and then building features that
match that FeatureType. This is similar to the approach taken by OGR; OGR
figures out where the "geometry" is; and then goes up two levels and assumes
those things are features.

We actually use the XMLSchema; so when it is not correct we run into
trouble.

For more information; here is my attempt at updating the xml docs....
- http://docs.geotools.org/latest/userguide/library/xml/index.html

Jody

On Mon, Apr 18, 2011 at 9:20 PM, Oskari Avoin <[email protected]>wrote:

> Hi,
> We are having a slight problem when trying to read WFS 1.1 response that is
> returned in GML 3.2.1. (GeoTools 2.7-M4)
> Currently, we are reading all WFS responses using GeoTools like so:
>
>     Parser parser = new Parser(...);
>     parser.setValidating(false);
>     parser.setFailOnValidationError(false);
>     parser.setStrict(false);
>     FeatureCollection<SimpleFeatureType, SimpleFeature> features =
> (FeatureCollection<SimpleFeatureType, SimpleFeature>)
> parser.parse(response.getResponseAsInputStream());
>
> but now are getting ClassCastException "java.util.HashMap cannot be cast to
> FeatureCollection".
> XML response contains multisurface object like this:
>
>     <gml:MultiSurface gml:id="XXX.MultiSurface" srsName="EPSG:3067">
>        <gml:surfaceMember>
>             <gml:Surface gml:id="XXX.Surface" srsName="EPSG:3067">
>                 <gml:patches>
>                     <gml:PolygonPatch>
>                         <gml:exterior>
>                             <gml:LinearRing>
>                                 <gml:posList>xx yy ...</gml:posList>
>                             </gml:LinearRing>
>                         </gml:exterior>
>                         <gml:interior>
>                             <gml:LinearRing>
>                                 <gml:posList>xx yy ...</gml:posList>
>                             </gml:LinearRing>
>                         </gml:interior>
>                     </gml:PolygonPatch>
>                 </gml:patches>
>             </gml:Surface>
>         </gml:surfaceMember>
>     </gml:MultiSurface>
>
> Now, is there an easy way to convert HashMap WFS GetFeature result to a
> "Layer" that could be render into an image something like this:
>
>     String style = "...";
>     FeatureCollection<SimpleFeatureType, SimpleFeature> features = {magic
> conversion from HashMap to FeatureCollection }
>     MapContext mapContext = buildMapContext();
>     mapContext.addLayer(features, style);
>
> Cheers.
>
>
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to