> Jody,
>
> I'm picking up the thread below, because I've bumped into some problems
> using the geotools GML library for parsing GML files, and I got no
> response from regarding this issue on the geotools mailing list. As you
> suggested to use geotools below, you might have more insight into this.
>
>
No worries; it is sometimes easier to start with running code when asking for
help. I always start with the test cases.
> I'm trying to go through the code samples privded here:
> http://docs.geotools.org/latest/userguide/library/xml/geometry.html
> in particular, the GML3 parsing code sample, and when running the code,
> I get the following warnings, during the call to
> gml.decodeFeatureCollection():
>
>
There are a couple different options on that page; setting up your
configuration by hand gives you the most control. I tried to make a GML utility
class to support the most common configuration - but I am not sure it is
working out in practice as GML schemas require so much setup.
> Nov 25, 2011 1:01:30 PM
> org.geotools.feature.simple.SimpleFeatureTypeBuilder add
> WARNING: Creating location with null CoordinateReferenceSystem - did you
> mean to setCRS?
> Nov 25, 2011 1:01:30 PM
> org.geotools.feature.simple.SimpleFeatureTypeBuilder add
> WARNING: Creating geom with null CoordinateReferenceSystem - did you
> mean to setCRS?
>
> this is despite the fact that I have called
> gml.setCoordinateReferenceSystem() earlier - see the complete code
> sample at the end of the e-mail.
>
>
I wonder if it is the GML file not having an srsName element? The problem may
be the file and not your code...
> looking at the source code of GML.decodeFeatureCollection() in the
> geotools-8.0-M3 codebase, I find that indeed, the while
> gml.setCoordinateReferenceSystem() sets the crs property in the GML
> object, the decodeFeatureCollection() call does not use the crs property.
>
>
Ah interesting; we should make a bug report (especially if you have sample
code).
> am I doing something wrong here? what would be the proper way to parse a
> GML file?
>
>
There are a couple of examples on that page; mostly I have taken them from the
JUnit tests for the different GML parsers.
I suspect you have found a bug in decodeFeatureCollection rather than doing
anything wrong.
> PS: the code I used was the following, based on the code in the
> documentation page:
>
> File file = ...
> InputStream xml = new FileInputStream(file);
> GML gml = new GML(Version.GML3);
> gml.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
> simpleFeatureCollection fc = gml.decodeFeatureCollection(xml);
>
> the test data I used is the three point test GML3 data found in the
> documentation page
>
>
You may wish to try further down that page where they set up a parser
configuration by hand. I try to do the right thing in the GML utility class you
mention; but I have not gotten a lot of feedback.
Jody
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel