[gdal-dev] Issue with OGRGeometryFactory::createFromGML
Even Rouault
even.rouault at mines-paris.org
Mon Nov 23 13:50:22 EST 2009
Ian,
this is clearly a bug in OGR that just returns after parsing the first
<pos> element. I've filed it as the following ticket :
http://trac.osgeo.org/gdal/ticket/3244
The fix should follow soon.
Best regards,
Even
Durkan, Ian a écrit :
>
> 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 )
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list