Hi, I found the problem. It was the problem of WFS version. I just change it to v1.0: WFSConfiguration configuration = new org.geotools.wfs.v1_0.WFSConfiguration();
It works fine now. Thanks for your help. Regards, Bahman On Wed, Sep 14, 2011 at 11:33 AM, Bahman Javadi <[email protected]> wrote: > Hi, > > Thanks for your answer. > I think, I found the problem but not the solution; > > In the parsing phase and in this instruction: > FeatureCollectionType fc = (FeatureCollectionType) > parser.parse(in); > I got the following message: > > Sep 14, 2011 11:24:02 AM > org.geotools.feature.simple.SimpleFeatureTypeBuilder add > WARNING: Creating location with null CoordinateReferenceSystem - did > you mean to setCRS? > Sep 14, 2011 11:24:02 AM > org.geotools.feature.simple.SimpleFeatureTypeBuilder add > WARNING: Creating the_geom with null CoordinateReferenceSystem - did > you mean to setCRS? > > I think this make my geometry null, when I want to read it. > Any idea? > > Regards, > Bahman > > On Tue, Sep 13, 2011 at 5:48 PM, Jody Garnett <[email protected]> wrote: >> Hey someone from Australia :-) >> You are already using the GML parser (it is included as part of your >> WFSConfiguration. >> One thing that is a bit odd is that you are parsing out features; if all you >> want is the geometry you should be able to ask for *just* the geometry (as >> long as you know its name). >> I assume you found the documentation page here: >> - http://docs.geotools.org/latest/userguide/library/xml/geometry.html >> It has this near the end >> StreamingParser parser = new StreamingParser( configuration, xml, "//Point" >> ) >> Point p = null; >> while ( ( p = (Point) parser.parse() ) != null ) { >> ... >> } >> -- >> Jody Garnett >> >> On Monday, 12 September 2011 at 11:26 PM, Bahman Javadi wrote: >> >> 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® DevCon Americas, Oct. 18-20, San Francisco, CA >> Learn about the latest advances in developing for the >> BlackBerry® mobile platform with sessions, labs & more. >> See new tools and technologies. Register for BlackBerry® DevCon today! >> http://p.sf.net/sfu/rim-devcon-copy1 >> _______________________________________________ >> Geotools-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-devel >> >> > ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerry® mobile platform with sessions, labs & more. See new tools and technologies. Register for BlackBerry® DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
