PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum LWGEOM_force_4d ( PG_FUNCTION_ARGS  )

Definition at line 428 of file lwgeom_functions_basic.c.

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

429 {
430  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
431  GSERIALIZED *pg_geom_out;
432  LWGEOM *lwg_in, *lwg_out;
433 
434  /* already 4d */
435  if ( gserialized_ndims(pg_geom_in) == 4 )
436  PG_RETURN_POINTER(pg_geom_in);
437 
438  lwg_in = lwgeom_from_gserialized(pg_geom_in);
439  lwg_out = lwgeom_force_4d(lwg_in);
440  pg_geom_out = geometry_serialize(lwg_out);
441  lwgeom_free(lwg_out);
442  lwgeom_free(lwg_in);
443 
444  PG_FREE_IF_COPY(pg_geom_in, 0);
445  PG_RETURN_POINTER(pg_geom_out);
446 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
Definition: lwgeom.c:721
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:53
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: