PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_force_3dm()

Datum LWGEOM_force_3dm ( PG_FUNCTION_ARGS  )

Definition at line 406 of file lwgeom_functions_basic.c.

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

Referenced by LWGEOM_force_3dz().

407 {
408  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
409  GSERIALIZED *pg_geom_out;
410  LWGEOM *lwg_in, *lwg_out;
411 
412  /* already 3d */
413  if ( gserialized_ndims(pg_geom_in) == 3 && gserialized_has_m(pg_geom_in) )
414  PG_RETURN_POINTER(pg_geom_in);
415 
416  lwg_in = lwgeom_from_gserialized(pg_geom_in);
417  lwg_out = lwgeom_force_3dm(lwg_in);
418  pg_geom_out = geometry_serialize(lwg_out);
419  lwgeom_free(lwg_out);
420  lwgeom_free(lwg_in);
421 
422  PG_FREE_IF_COPY(pg_geom_in, 0);
423  PG_RETURN_POINTER(pg_geom_out);
424 }
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:50
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:60
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
Definition: lwgeom.c:751
Here is the call graph for this function:
Here is the caller graph for this function: