#1591 closed defect (invalid)
ST_GeomFromGML crushes for Triangle (Triangulard Surface/TIN)
Reported by: | itboyet | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | postgis | Version: | 2.0.x |
Keywords: | Cc: |
Description
I am trying to use the ST_GeomFromGML to insert some TIN/Triangular Object into Postgres database; however, PostGIS/PostgreSQL exits after I executed the following query:
SELECT ST_AsEWKT(ST_GeomFromGML(' <gml:TriangulatedSurface>
<gml:TrianglePatches>
<gml:Triangle>
<gml:exterior>
<gml:LinearRing gml:id="1">
<gml:posList srsDimension="3">
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Triangle> <gml:Triangle>
<gml:exterior>
<gml:LinearRing gml:id="2">
<gml:posList srsDimension="3">
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Triangle> <gml:Triangle>
<gml:exterior>
<gml:LinearRing gml:id="3">
<gml:posList srsDimension="3">
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Triangle> <gml:Triangle>
<gml:exterior>
<gml:LinearRing gml:id="4">
<gml:posList srsDimension="3">
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Triangle>
</gml:TrianglePatches>
</gml:TriangulatedSurface>'));
However, it would give me an actual error if I change the tag "TriangulatedSurface" to "TriangularSurface", which should not be the correct gml tag.
Change History (20)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
select postgis_full_version(); postgis_full_version ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- POSTGIS="2.0.0alpha6SVN" GEOS="3.4.0dev-CAPI-1.8.0" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" SVN_REVISION=9229 USE_STATS
comment:3 by , 13 years ago
With TriangulatedSurface i got:
TIN EMPTY
And with TriangularSurface
ERROR: invalid GML representation
PostGIS trunk r9241
comment:4 by , 13 years ago
I get the same. Pasteable version of the query:
SELECT ST_AsEWKT(ST_GeomFromGML(' <gml:TriangulatedSurface> <gml:TrianglePatches> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="1"> <gml:posList srsDimension="3"> 0 0 1000000 0 10 1000000 10 10 1000000 0 0 1000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="2"> <gml:posList srsDimension="3"> 0 0 8000000 10 10 1000000 0 0 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="3"> <gml:posList srsDimension="3"> 0 0 8000000 0 10 1000000 10 10 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="4"> <gml:posList srsDimension="3"> 0 0 8000000 0 0 1000000 0 10 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> </gml:TrianglePatches> </gml:TriangulatedSurface>'));
comment:5 by , 13 years ago
I see we have no cunit test for GML input, would be worth adding one (we could at least get a valgrind opinion on the matter)
comment:6 by , 13 years ago
Comment here also suggests there are memory errors: source:trunk/postgis/lwgeom_in_gml.c#L654 Time to move GML parser into liblwgeom ?
comment:8 by , 13 years ago
Oops, the gml parser includes reprojection which uses the PROJ cache, which in turn is only at the pgsql level…
comment:9 by , 13 years ago
@strk : there was previous reflexion related to moving it to liblwgeon here #444
I think there's 2 options right now:
- Check quickly that request posted by itboyet is valgrind clean
(so no need to play with proj4)
- tackle #444 for 2.0 rather than 2.1
I can spend some time on it, but i didn't plan (at all) to migrate the ~1000 units tests related to GeomFrom*ML to cunit syntax/logic.
comment:10 by , 13 years ago
I've commented on #444, if you can spend some time checking itboyet case with valgrind that would be enough for me.
comment:11 by , 13 years ago
I've noticed another thing: the library prints errors on stderr, like these:
namespace error : Namespace prefix gml on TriangulatedSurface is not defined <gml:TriangulatedSurface> <gml:TrianglePatches> <gml:Triangle> <gml:exterior> < ^
it probably shouldn't.
Anyway the query runs valgrind-clean on a cassert-enabled postgresql 9.1
comment:12 by , 13 years ago
I've dropped the POINTARRAY clone in r9279, still no memory errors I can see either on pgsql 9.1 or 8.4.
comment:13 by , 13 years ago
I had version alpha5 when I had this error. I got "TIN EMPTY" after upgrading to alpha6. However, the GML has the correct format for insertion. Is it a bug since it returns "TIN EMPTY"?
comment:14 by , 13 years ago
Well, it's a legal TIN (at least, the WKT version goes in fine) so the GML function should be looked at…
TIN( ((0 0 1000000,0 10 1000000,10 10 1000000,0 0 1000000)), ((0 0 8000000,10 10 1000000,0 0 1000000,0 0 8000000)), ((0 0 8000000,0 10 1000000,10 10 1000000,0 0 8000000)), ((0 0 8000000,0 0 1000000,0 10 1000000,0 0 8000000)) )
comment:15 by , 13 years ago
Meanwhile, as a remark I also want to point out that ST_AsGML does not support TIN and/or Triangle Geometry. Perhaps it would be great to have both INPUT function (ST_GeomFromGML) and OUTPUT function (ST_AsGML) working in sync.
comment:17 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
So, turns out GML is case sensitive… this works
SELECT ST_AsEWKT(ST_GeomFromGML(' <gml:TriangulatedSurface> <gml:trianglePatches> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="1"> <gml:posList srsDimension="3"> 0 0 1000000 0 10 1000000 10 10 1000000 0 0 1000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="2"> <gml:posList srsDimension="3"> 0 0 8000000 10 10 1000000 0 0 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="3"> <gml:posList srsDimension="3"> 0 0 8000000 0 10 1000000 10 10 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> <gml:Triangle> <gml:exterior> <gml:LinearRing gml:id="4"> <gml:posList srsDimension="3"> 0 0 8000000 0 0 1000000 0 10 1000000 0 0 8000000 </gml:posList> </gml:LinearRing> </gml:exterior> </gml:Triangle> </gml:trianglePatches> </gml:TriangulatedSurface>'));
comment:18 by , 13 years ago
And, incidentally, As_GML does support TIN, just for GML3 only:
select st_asgml(3,'TIN(((0 0 1000000,0 10 1000000,10 10 1000000,0 0 1000000)),((0 0 8000000,10 10 1000000,0 0 1000000,0 0 8000000)),((0 0 8000000,0 10 1000000,10 10 1000000,0 0 8000000)),((0 0 8000000,0 0 1000000,0 10 1000000,0 0 8000000)))'::geometry);
and the full wrap-around
select st_astext(st_geomfromGML(st_asgml(3,'TIN(((0 0 1000000,0 10 1000000,10 10 1000000,0 0 1000000)),((0 0 8000000,10 10 1000000,0 0 1000000,0 0 8000000)),((0 0 8000000,0 10 1000000,10 10 1000000,0 0 8000000)),((0 0 8000000,0 0 1000000,0 10 1000000,0 0 8000000)))'::geometry)));
comment:19 by , 13 years ago
There, final answer, the error message from TIN→GML2 is now more useful at r9331.
Can you update your PostGIS to the latest revision? I am not seeing a crash here…