PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_force_2d()

Datum LWGEOM_force_2d ( PG_FUNCTION_ARGS  )

Definition at line 367 of file lwgeom_functions_basic.c.

368{
369 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
370 GSERIALIZED *pg_geom_out;
371 LWGEOM *lwg_in, *lwg_out;
372
373 /* already 2d */
374 if (gserialized_ndims(pg_geom_in) == 2)
375 PG_RETURN_POINTER(pg_geom_in);
376
377 lwg_in = lwgeom_from_gserialized(pg_geom_in);
378 lwg_out = lwgeom_force_2d(lwg_in);
379 pg_geom_out = geometry_serialize(lwg_out);
380 lwgeom_free(lwg_out);
381 lwgeom_free(lwg_in);
382
383 PG_FREE_IF_COPY(pg_geom_in, 0);
384 PG_RETURN_POINTER(pg_geom_out);
385}
int gserialized_ndims(const GSERIALIZED *g)
Return the number of dimensions (2, 3, 4) in a geometry.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition lwgeom.c:821

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

Here is the call graph for this function: