bilaldursun1 / nettopologysuite

Automatically exported from code.google.com/p/nettopologysuite
0 stars 0 forks source link

Can't read GML files having elements <gml:exterior>, <gml:posList>, <gml:pos> #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm using NTS 1.11 to extract coordinates data from some GML files. Basically I 
can use NetTopologySuite.IO.GML2.GMLReader class to read coordinates data from 
some of GML files. For others, it raises exception ShouldNeverReadHere or 
return empty result. My GML files come from clients or it's created by Quantum 
GIS application. 

I attached GML files that the api can't read value. Below is my sample code

=== BEGIN CODE ====
var xmlReader = new XmlTextReader(new StringReader(gmlXmlContent));
var gmlReader = new GMLReader();
do
   {
      if (IsStartElement(xmlReader, "Point"))
                {
                    var data = (IPoint)gmlReader.Read(xmlReader);
                }
                else if (IsStartElement(xmlReader, "LineString"))
                {
                    var data = gmlReader.Read(xmlReader);
                }
                else if (IsStartElement(xmlReader, "Polygon"))
                {
var data = (IPolygon)gmlReader.Read(xmlReader);
                }
            } while (xmlReader.Read());

/////////////////
private bool IsStartElement(XmlReader reader, string name)
{
   return reader.IsStartElement(GML_PREFIX + ":" + name);
}

=== / END ====

With the above code, I can extract data some GML files, and some other I can't. 
I tried to look at the source code and realized that the reader doesn't 
recognize some kind of xml element in my GML file although they are created 
totally in normal way. These elements are: <gml:exterior>, <gml:posList>, 
<gml:pos>

I run the code on .NET 4, Windows 7 OS

Can somebody help me figure out the behind reason why NTS can't read some of 
GML files ?

Thanks,
Duy

Original issue reported on code.google.com by duylamph...@gmail.com on 1 Jan 2012 at 9:14

Attachments:

GoogleCodeExporter commented 9 years ago
Maybe those keywords are GML 3+?

I've fixed the gml reader in r796 to handle the keywords, except for file 4 
since I don't know how to handle that yet. Surface is not a class in NTS.

Original comment by felix.ob...@netcologne.de on 2 Jan 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Many thank felix :)

Actually I haven't worked much on GML format and have no idea about the meaning 
of  <gml:exterior>, <gml:posList> and <gml:pos>. Regarding the file 4 issue, 
maybe the Surface element in that GML file isn't in GML standard or maybe it 
have been added to GML later on. I'm not sure which case is right

Original comment by duylamph...@gmail.com on 2 Jan 2012 at 10:57

GoogleCodeExporter commented 9 years ago
AFAIK in 'Simple Features Specification for SQL' a surface is an abstract 
class, and the only concrete implementation is the Polygon class, so I think 
that can be correct to try to manage a surface as a polygon and let the code 
fail if some error happens

Original comment by diegogu...@gmail.com on 2 Jan 2012 at 11:06

GoogleCodeExporter commented 9 years ago
From looking at the sample file I assume it would be more like a multipolygon, 
but may contain patches made of nonlinear components, like e.g. oracle sdo can 
handle. I don't think we should bother as long jts does not.

Original comment by felix.ob...@netcologne.de on 2 Jan 2012 at 1:46

GoogleCodeExporter commented 9 years ago
>I don't think we should bother as long jts does not
I completely agree. 

Original comment by diegogu...@gmail.com on 2 Jan 2012 at 1:48

GoogleCodeExporter commented 9 years ago
Thank you

Original comment by duylamph...@gmail.com on 3 Jan 2012 at 3:06