[gdal-dev] Issue with OGRGeometryFactory::createFromGML
Durkan, Ian
ian.durkan at progeny.net
Mon Nov 23 12:45:55 EST 2009
Greetings,
I'm trying to use OGRGeometryFactory::createFromGML and
OGRGeometry::exportToWkt (both in ogr_geometry.h) to convert GML
geometry elements into well-known text and running into a problem when
the GML geometry is provided as a collection of <pos> elements. Note
that the geometry is in GML 3.1.1 format, except the capitalization of
the outermost element names, which is irrelevant judging by the OGR
source code.
This is basically the sequence of calls I'm making, where gmlText is an
std::string & contains the input text and buffer is a char* with
sufficient space for the output:
OGRGeometry* geom =
OGRGeometryFactory::createFromGML(gmlText_noversion.c_str());
geom->exportToWkt(&buffer);
As an example of how things are going wrong, here's sample input text to
createFromGML where a collection of <pos> elements is used:
<p1:polygon xmlns:p1="http://foo" xmlns:p2="http://www.opengis.net/gml">
<p2:exterior>
<p2:LinearRing>
<p2:pos>-39 77.5</p2:pos>
<p2:pos>-38.75 77.75</p2:pos>
<p2:pos>-38.5 77.75</p2:pos>
<p2:pos>-38.25 77.5</p2:pos>
<p2:pos>-38.25 77.25</p2:pos>
<p2:pos>-38.5 77</p2:pos>
<p2:pos>-38.75 77</p2:pos>
<p2:pos>-39 77.25</p2:pos>
<p2:pos>-39 77.5</p2:pos>
</p2:LinearRing>
</p2:exterior>
<p2:interior>
<p2:LinearRing>
<p2:pos>-38.75 77.5</p2:pos>
<p2:pos>-38.5 77.5</p2:pos>
<p2:pos>-38.5 77.25</p2:pos>
<p2:pos>-38.75 77.25</p2:pos>
<p2:pos>-38.75 77.5</p2:pos>
</p2:LinearRing>
</p2:interior>
</p1:polygon>
Given the OGRGeometry created from the above text, exportToWkt gives me
the following:
POLYGON ((-39.0 77.5),(-38.75 77.5))
On the other hand, if I pass the following input to createFromGML:
<p1:polygon xmlns:p1="http://foo" xmlns:p2="http://www.opengis.net/gml">
<p2:exterior>
<p2:LinearRing>
<p2:posList>-39 77.5 -38.75 77.75 -38.5 77.75 -38.25 77.5 -38.25
77.25 -38.5 77 -38.75 77 -39 77.25 -39 77.5</p2:posList>
</p2:LinearRing>
</p2:exterior>
<p2:interior>
<p2:LinearRing>
<p2:posList>-38.75 77.5 -38.5 77.5 -38.5 77.25 -38.75 77.25 -38.75
77.5</p2:posList>
</p2:LinearRing>
</p2:interior>
</p1:polygon>
...I get the expected output from exportToWkt:
POLYGON ((-39.0 77.5,-38.75 77.75,-38.5 77.75,-38.25 77.5,-38.25
77.25,-38.5 77.0,-38.75 77.0,-39.0 77.25,-39.0 77.5),(-38.75 77.5,-38.5
77.5,-38.5 77.25,-38.75 77.25,-38.75 77.5))
This is happening for other GML geometries such as LineString as
well-the OGR functions handle <posList> input correctly, but not
collections of <pos> elements.
Can anyone offer insight as to what is going wrong in the <pos> element
collection case? My understanding is that either 4 or more <pos>
elements may be used in a LinearRing, or one <posList> containing the
list of coordinates.
Ian Durkan ( ian.durkan <at> progeny.net )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091123/c510490c/attachment.html
More information about the gdal-dev
mailing list