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

Definition at line 382 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_has_m(), gserialized_ndims(), lwgeom_force_3dm(), lwgeom_free(), and lwgeom_from_gserialized().

383 {
384  GSERIALIZED *pg_geom_in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
385  GSERIALIZED *pg_geom_out;
386  LWGEOM *lwg_in, *lwg_out;
387 
388  /* already 3d */
389  if ( gserialized_ndims(pg_geom_in) == 3 && gserialized_has_m(pg_geom_in) )
390  PG_RETURN_POINTER(pg_geom_in);
391 
392  lwg_in = lwgeom_from_gserialized(pg_geom_in);
393  lwg_out = lwgeom_force_3dm(lwg_in);
394  pg_geom_out = geometry_serialize(lwg_out);
395  lwgeom_free(lwg_out);
396  lwgeom_free(lwg_in);
397 
398  PG_FREE_IF_COPY(pg_geom_in, 0);
399  PG_RETURN_POINTER(pg_geom_out);
400 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:30
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)
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
Definition: lwgeom.c:658

Here is the call graph for this function: