PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ LWGEOM_force_2d()

Datum LWGEOM_force_2d ( PG_FUNCTION_ARGS  )

Definition at line 360 of file lwgeom_functions_basic.c.

361 {
362  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
363  GSERIALIZED *pg_geom_out;
364  LWGEOM *lwg_in, *lwg_out;
365 
366  /* already 2d */
367  if (gserialized_ndims(pg_geom_in) == 2)
368  PG_RETURN_POINTER(pg_geom_in);
369 
370  lwg_in = lwgeom_from_gserialized(pg_geom_in);
371  lwg_out = lwgeom_force_2d(lwg_in);
372  pg_geom_out = geometry_serialize(lwg_out);
373  lwgeom_free(lwg_out);
374  lwgeom_free(lwg_in);
375 
376  PG_FREE_IF_COPY(pg_geom_in, 0);
377  PG_RETURN_POINTER(pg_geom_out);
378 }
int gserialized_ndims(const GSERIALIZED *g)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: gserialized.c:207
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition: lwgeom.c:776

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

Here is the call graph for this function: