PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_force_4d ( PG_FUNCTION_ARGS  )

Definition at line 404 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_ndims(), lwgeom_force_4d(), lwgeom_free(), and lwgeom_from_gserialized().

405 {
406  GSERIALIZED *pg_geom_in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
407  GSERIALIZED *pg_geom_out;
408  LWGEOM *lwg_in, *lwg_out;
409 
410  /* already 4d */
411  if ( gserialized_ndims(pg_geom_in) == 4 )
412  PG_RETURN_POINTER(pg_geom_in);
413 
414  lwg_in = lwgeom_from_gserialized(pg_geom_in);
415  lwg_out = lwgeom_force_4d(lwg_in);
416  pg_geom_out = geometry_serialize(lwg_out);
417  lwgeom_free(lwg_out);
418  lwgeom_free(lwg_in);
419 
420  PG_FREE_IF_COPY(pg_geom_in, 0);
421  PG_RETURN_POINTER(pg_geom_out);
422 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
Definition: lwgeom.c:664
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:40
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: