Hi,

Justin Deoliveira <[EMAIL PROTECTED]> writes:

> In geotools 2.4 there are two parsers / encoders for gml. Sadly the
> first ( which has been around for a while ), is not that well
> maintained. And these bugs are scheduled against it.
> 
> I have been working on second generation of the parser. Documentation here:
> 
> http://docs.codehaus.org/display/GEOTDOC/05+XML+Parsing+and+Encoding
> http://docs.codehaus.org/display/GEOTDOC/XML+Developers+Guide

OK. I will study that but, frankly, a "simple" lightweight SAX parser for
parsing geometries (and geometries only) would have been sufficient to me.

Well, I think I can do something with this code snippet :

InputStream xml = ...

org.geotools.xml.StreamingParser parser = 
new org.geotools.xml.StreamingParser( configuration, xml, xpath );

Feature f = null;
while( ( f = (Feature) parser.parse() ) != null ) {
  Point point = (Point)f.getDefaultGeometry();
  String name = (String) f.getAttribute( "name" );
}

I guess I will "just" have to play with f.getDefaultGeometry(), no ?

> I tried both of these files with the "new" parser and is doesn't throw 
> exceptions. However I notice that the first file (Test.xml) is not valid 
> gml.

I wasn't claiming so ;-)

> Two issues i found were:
> 
> 1. the bounds on the feature collection uses gml:Null, where as it 
> should be just "null" according to the gml2 schema

> 2. the "location" elements are of type point property, which can only 
> contain "gml:Point" elements.

Good. That's roughly just what I want : a nice Java Exception with an as
explicit message as the one you've just written. Catching NPEs is really a 
dirty workaround, especially if there is no message to get an idea of what the
problem is.

Also, I get this one on System.err with the Ordnance Survey's file mentionned in
the update issue report :

26 avr. 2007 09:06:45 org.geotools.gml.SubHandlerPolygon create
ATTENTION: Topology Error building polygon

>From the code, it appears that this one also forwards a NPE rather than
dedicated exception (what about TopologyException ?).

Anyway, thanks for the response. I'll try to consider the new parser ASAP.

Cheers,

p.b.











-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to