[postgis-users] Empty GeometryCollection and AsSVG

Olivier Courtin pnine at free.fr
Wed Oct 27 04:40:22 PDT 2004


Hi,

Still playing with AsSVG function, and i met a little problem, with
query like :

SELECT AsSVG(simplify(the_geom, 1000), 1, 0) FROM my_table;

With some data and with a quite high simplify tolerance parameter, the
simplify output could be empty. And become a GeometryCollection type...
And this even if the original type was a Polygon or anything else...

And as AsSVG not handle rightly GeometryCollection type, output
could be like that :

Row 1) M 572119 -1720173 l 1162 4085 -4360 -567 3198 -3518 
Row 2) GEOMETRYCOLLECTION not yet supported
Row 3) M 572119 -1720173 l -3198 3518 4360 567 -1162 -4085
...


I provide below a partial patch for AsSvg who return an empty string if
GeometryCollection is Empty.

So result will be :

Row 1) M 572119 -1720173 l 1162 4085 -4360 -567 3198 -3518 
Row 2) 
Row 3) M 572119 -1720173 l -3198 3518 4360 567 -1162 -4085
...


Any better idea ?



diff -u against current cvs head :

--- lwgeom_svg.c        2004-10-27 13:13:12.000000000 +0200
+++ patched_lwgeom_svg.c        2004-10-27 13:27:13.000000000 +0200
@@ -92,8 +92,17 @@
 
        if (lwgeom_getType(geometry->type) == COLLECTIONTYPE)
        {
-               result = (char *)palloc(64); 
-               sprintf(result, "GEOMETRYCOLLECTION not yet supported");
+               inspected = lwgeom_inspect(SERIALIZED_FORM(geometry));
+
+               result = (char *)palloc(64);
+
+               if(inspected->ngeometries == 0){
+                       sprintf(result, "%s", "");
+               } else {
+                       sprintf(result,
+                               "GEOMETRYCOLLECTION not yet supported");
+               }
+
                return result;
        }
 


HTH :)

--
Ol



More information about the postgis-users mailing list