PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum LWGEOM_force_2d ( PG_FUNCTION_ARGS  )

Definition at line 348 of file lwgeom_functions_basic.c.

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

349 {
350  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
351  GSERIALIZED *pg_geom_out;
352  LWGEOM *lwg_in, *lwg_out;
353 
354  /* already 2d */
355  if ( gserialized_ndims(pg_geom_in) == 2 ) PG_RETURN_POINTER(pg_geom_in);
356 
357  lwg_in = lwgeom_from_gserialized(pg_geom_in);
358  lwg_out = lwgeom_force_2d(lwg_in);
359  pg_geom_out = geometry_serialize(lwg_out);
360  lwgeom_free(lwg_out);
361  lwgeom_free(lwg_in);
362 
363  PG_FREE_IF_COPY(pg_geom_in, 0);
364  PG_RETURN_POINTER(pg_geom_out);
365 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:39
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition: lwgeom.c:690
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: