GBOX *box = NULL;
int type;
- ogeoms = lwalloc(sizeof(LWGEOM*));
-
/*
** This funx is a no-op only if a bbox cache is already present
** in input.
type = lwgeom->type;
- if ( MULTITYPE[type] )
+ if ( ! MULTITYPE[type] ) return lwgeom_clone(lwgeom);
+
+ if( lwgeom_is_empty(lwgeom) )
+ {
+ ogeom = (LWGEOM *)lwcollection_construct_empty(
+ MULTITYPE[type],
+ lwgeom->srid,
+ FLAGS_GET_Z(lwgeom->flags),
+ FLAGS_GET_M(lwgeom->flags)
+ );
+ }
+ else
{
+ ogeoms = lwalloc(sizeof(LWGEOM*));
ogeoms[0] = lwgeom_clone(lwgeom);
/* Sub-geometries are not allowed to have bboxes or SRIDs, move the bbox to the collection */
ogeom = (LWGEOM *)lwcollection_construct(MULTITYPE[type], lwgeom->srid, box, 1, ogeoms);
}
- else
- {
- return lwgeom_clone(lwgeom);
- }
return ogeom;
}
st_intersects(g, 'POLYGON((0 0, 1 1, 1 0, 0 0))'::geometry) from cacheable;
DROP TABLE cacheable;
+-- #1489
+with inp AS ( SELECT
+ st_multi('POINT EMPTY'::geometry) as mp,
+ st_multi('LINESTRING EMPTY'::geometry) as ml,
+ st_multi('POLYGON EMPTY'::geometry) as ma,
+ st_multi('GEOMETRYCOLLECTION EMPTY'::geometry) as mm
+) select '#1489',
+ st_astext(mp), st_numgeometries(mp),
+ st_astext(ml), st_numgeometries(ml),
+ st_astext(ma), st_numgeometries(ma),
+ st_astext(mm), st_numgeometries(mm)
+FROM inp;
+
-- Clean up
DELETE FROM spatial_ref_sys;