PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_force_4d()

Datum LWGEOM_force_4d ( PG_FUNCTION_ARGS  )

Definition at line 413 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_ndims(), lwgeom_force_4d(), LWGEOM_force_collection(), lwgeom_free(), lwgeom_from_gserialized(), and PG_FUNCTION_INFO_V1().

Referenced by LWGEOM_force_3dm().

414 {
415  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
416  GSERIALIZED *pg_geom_out;
417  LWGEOM *lwg_in, *lwg_out;
418 
419  /* already 4d */
420  if ( gserialized_ndims(pg_geom_in) == 4 )
421  PG_RETURN_POINTER(pg_geom_in);
422 
423  lwg_in = lwgeom_from_gserialized(pg_geom_in);
424  lwg_out = lwgeom_force_4d(lwg_in);
425  pg_geom_out = geometry_serialize(lwg_out);
426  lwgeom_free(lwg_out);
427  lwgeom_free(lwg_in);
428 
429  PG_FREE_IF_COPY(pg_geom_in, 0);
430  PG_RETURN_POINTER(pg_geom_out);
431 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
Definition: lwgeom.c:708
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
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function:
Here is the caller graph for this function: