[postgis-devel] [gdal-dev] Bogus <gml:Face> interpretation

strk strk at keybit.net
Sun Jan 30 04:51:08 PST 2011


On Sun, Jan 30, 2011 at 01:24:08PM +0100, Even Rouault wrote:
> Le dimanche 30 janvier 2011 12:09:12, strk a écrit :
> >
> >  n1
> >   +-----e1-->-----.
> >   |      F1       |
> >   |           n3  |
> >   |   ,-e2->-+    |
> >   |   |  F2  |    |
> >   |   +-<-e7-'    |
> >   | n4            |
> >   `---<-e2--------+
> >                    n2
> 
> There's probably an error with the name of the edges in your first schema : 
> there are 2 e2 and one e7. I guess the edges of the interior ring should be 
> named e3 and e4, right ?

Yes, sorry, the inner one re e3 and e4 (rather than e2 and e7)

> > It occurs to me that face F1 above is bounded by all edges,
> > not just the exterior ones, so I'd put _all_ edges inside
> > one gml:Face tag:
> > 
> >  <Face id="F1">
> >   <directedEdge orientation="-" id="e1" />
> >   <directedEdge orientation="-" id="e2" />
> >   <directedEdge id="e3" />
> >   <directedEdge id="e4" />
> >  </Face>
> > 
> > This is expressed clearly in the OGC 03-105r1 document (GML-3.1.1, 2004)
> > and 07-036 (GML-3.2.1, 2007)
> > 
> > <<
> > The non-dangling edges in the boundary of a face comprise one or more
> > topological rings. Each such ring consists of directedEdges connected
> > in a cycle, and is oriented with the face on its left.
> > 
> > 
> > Now, when encountering such a GML snippet, ogr2ogr (GML driver)
> > insists in considering all edges as being part of the same ring
> > thus producing an invalid polygon as a result.
> 
> If I understand well, the face should be interpreted as a polygon with 
> exterior ring being e1,e2 and interior ring being e3, e4 ?

Yes. To my understanding.
And it would match ISO topology too (from SQL-MM).

> I've reviewed a bit the code and my understanding is that we concatenate all 
> the linestring geometries found in the directedEdge of a Face into a single 
> ring as you noticed. So we should implement detection of cycles to emit as 
> many rings as necessary.

Yes.  This for each face.

> > Another example of such invalid intepretation follows:
> > 
> >   +------+------+
> >   | F1   |  F2  |
> >   +------+------+
> > 
> > A surface/polygon formed by the two faces above (F1,F2) should be
> > represented as:
> > 
> >  <TopoSurface id="P1">
> >    <directedFace> <Face id="F1"/> </directedFace>
> >    <directedFace> <Face id="F2"/> </directedFace>
> >  </TopoSurface>
> > 
> > Whereas the resulting feature geometry should be a single-ring polygon:
> > the topological _union_ of the two faces (I haven't tested this but
> > I belive GDAL would get this wrong as well).
> 
> Yes we should likely use GEOSUnion instead of putting all the rings into a 
> single polygon as we do currently.

Correct. The GEOSUnion of all composing faces.

> I think you shouldn't try too hard to be OGR compatible in Postgis if you 
> believe that we are currently not interpreting GML correctly. The GML3 
> topology interpretation in OGR is completely new, so I would definitely not 
> label it as a reference implementation, and it probably needs adjustements.
> 
> What could help is that you file GDAL trac tickets with examples of GML3 
> topology and what you think would be the expected WKT.

Ok. Stubbed: http://trac.osgeo.org/gdal/ticket/3937
Thanks for the feedback.

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-devel mailing list