[ WHEN_SIMPLE (use input bbox if present) ]
noop(geometry) *LWG*
ExteriorRing(geometry) *LWG*
- SetSRID(geometry,int4) **SRL**
- force_2d(geometry) **SRL**
+ SetSRID(geometry,int4) *SRL*
+
+ # doesn't change bbox cache status if input is already 2d
+ force_2d(geometry) *SRL*
+
force_3dz(geometry) **SRL**
force_3d(geometry) **SRL**
force_3dm(geometry) **SRL**
Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
{
PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ char *srl;
PG_LWGEOM *result;
size_t size = 0;
if ( lwgeom_ndims(geom->type) == 2 ) PG_RETURN_POINTER(geom);
// allocate a larger for safety and simplicity
- result = (PG_LWGEOM *) lwalloc(geom->size);
+ srl = (char *) lwalloc(geom->size);
lwgeom_force2d_recursive(SERIALIZED_FORM(geom),
- SERIALIZED_FORM(result), &size);
+ srl, &size);
- // we can safely avoid this... memory will be freed at
- // end of query processing anyway.
- //result = lwrealloc(result, size+4);
-
- result->size = size+4;
+ result = PG_LWGEOM_construct(srl, pglwgeom_getSRID(geom),
+ lwgeom_hasBBOX(geom->type));
PG_RETURN_POINTER(result);
}
PG_FUNCTION_INFO_V1(LWGEOM_setSRID);
Datum LWGEOM_setSRID(PG_FUNCTION_ARGS)
{
- PG_LWGEOM *lwgeom = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
int newSRID = PG_GETARG_INT32(1);
PG_LWGEOM *result;
- result = pglwgeom_setSRID(lwgeom, newSRID);
+ result = PG_LWGEOM_construct(SERIALIZED_FORM(geom), newSRID,
+ lwgeom_hasBBOX(geom->type));
PG_RETURN_POINTER(result);
}