GEOSGeometry* mline_out=0;
GEOSGeometry* mpoint_out=0;
GEOSGeometry* gout;
- uint32 nlines;
+ uint32 nlines, nlines_alloc;
uint32 npoints=0;
- uint32 ngeoms=0;
- uint32 i;
+ uint32 ngeoms=0, nsubgeoms;
+ uint32 i, j;
ngeoms = GEOSGetNumGeometries(gin);
- lines = lwalloc(sizeof(GEOSGeometry*)*ngeoms);
+ nlines_alloc = ngeoms;
+ lines = lwalloc(sizeof(GEOSGeometry*)*nlines_alloc);
points = lwalloc(sizeof(GEOSGeometry*)*ngeoms);
for (i=0; i<ngeoms; ++i)
{
lines[nlines++] = vg;
}
+ else if ( GEOSGeomTypeId(vg) == GEOS_MULTILINESTRING )
+ {
+ nsubgeoms=GEOSGetNumGeometries(vg);
+ nlines_alloc += nsubgeoms;
+ lines = lwrealloc(lines, sizeof(GEOSGeometry*)*nlines_alloc);
+ for (j=0; j<nsubgeoms; ++j)
+ {
+ const GEOSGeometry* gc = GEOSGetGeometryN(vg, j);
+ /* NOTE: ownership of the cloned geoms will be
+ * taken by final collection */
+ lines[nlines++] = GEOSGeom_clone(gc);
+ }
+ }
else
{
/* NOTE: return from GEOSGeomType will leak
PG 2 SRID=3;LINESTRING(0 0, 0 0) SRID=3;POINT(0 0)
PG 3 SRID=43;MULTILINESTRING((0 0, 10 0),(20 20, 20 20)) SRID=43;GEOMETRYCOLLECTION(LINESTRING(0 0, 10 0),POINT(20 20))
PG 4 SRID=2;MULTIPOLYGON(((5 3, 7 4, 9 5, 11 6, 13 7, 5 3)),((14 14, 14 14, 14 14, 14 14))) SRID=2;GEOMETRYCOLLECTION(MULTILINESTRING((5 3,7 4),(7 4,9 5),(9 5,11 6),(11 6,13 7)),POINT(14 14))
+PG 5 SRID=4;MULTILINESTRING((5 3 0, 7 4 5, 9 5 3, 11 6 4, 13 7 9, 5 3 0),(14 14 2, 14 14 3, 14 14 4, 14 14 5)) SRID=4;GEOMETRYCOLLECTION(MULTILINESTRING((5 3 0,7 4 3.625),(7 4 3.625,9 5 3.75),(9 5 3.75,11 6 5.375),(11 6 5.375,13 7 9)),POINT(14 14 2))
\.
-- PG.1 : polygon with single ring with single point in it