PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ LWGEOM_force_3dz()

Datum LWGEOM_force_3dz ( PG_FUNCTION_ARGS  )

Definition at line 387 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_has_z(), gserialized_ndims(), LWGEOM_force_3dm(), lwgeom_force_3dz(), lwgeom_free(), lwgeom_from_gserialized(), and PG_FUNCTION_INFO_V1().

Referenced by LWGEOM_force_2d().

388 {
389  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
390  GSERIALIZED *pg_geom_out;
391  LWGEOM *lwg_in, *lwg_out;
392 
393  /* already 3d */
394  if ( gserialized_ndims(pg_geom_in) == 3 && gserialized_has_z(pg_geom_in) )
395  PG_RETURN_POINTER(pg_geom_in);
396 
397  lwg_in = lwgeom_from_gserialized(pg_geom_in);
398  lwg_out = lwgeom_force_3dz(lwg_in);
399  pg_geom_out = geometry_serialize(lwg_out);
400  lwgeom_free(lwg_out);
401  lwgeom_free(lwg_in);
402 
403  PG_FREE_IF_COPY(pg_geom_in, 0);
404  PG_RETURN_POINTER(pg_geom_out);
405 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
Definition: lwgeom.c:781
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1128
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:60
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function:
Here is the caller graph for this function: