Hi,

I just want to create a geometry from a WFS query.
I make a WFS query and send it to WFS server, which returns me the
requested features.
I save the result in a XML file temporary. it has the geometry inside as well.

I can read all the numerical data from the file as follows:

           tmp = File.createTempFile("getFeature", "xml");
            tmp.deleteOnExit();

            Transformer tx = TransformerFactory.newInstance().newTransformer();
            tx.transform(new DOMSource(doc), new StreamResult(tmp));

            in = new FileInputStream(tmp);

WFSConfiguration configuration = new org.geotools.wfs.v1_1.WFSConfiguration();
            Parser parser = new Parser(configuration);
            FeatureCollectionType fc = (FeatureCollectionType) parser.parse(in);

            EList featureCollections = fc.getFeature();
            assert featureCollections.size() <= 1 : "feature
collection size should only be zero or one";

            SimpleFeatureCollection featureCollection =
(SimpleFeatureCollection) featureCollections
                    .get(0);
            LOGGER.debug("There are " + featureCollection.size()
                    + " featureCollection entries.");

            SimpleFeatureIterator features = featureCollection.features();

            while (features.hasNext()) {
                SimpleFeature f = features.next();

                Map<String, Object> featureMap = new HashMap<String, Object>();
                for (String attribute : attributesToReturn) {
                    Object attributeValue = f.getAttribute(attribute);
                    featureMap.put(attribute, attributeValue);
                }

                // the row (or Map in this case) will use the attribute value of
                // the table linking key as its key. we'll assume here that
                // the table linking key is always provided as one of the
                // parameters in the attributesToBeReturned field
                Object fid = f.getAttribute(params.getTableLinkingKey());

                // think of an entry in the featureMembers map being a row
                // in a table and the featureMap being the column entries
                // for each row
                featureMembers.put(fid, featureMap);

            }
}

but in this case I see the geometry field is empty.
I wonder if anyone knows how to handle the geometry.

Do I need the GML parser?

Thanks in advance,
Bahman

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to