PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ LWGEOM_force_4d()

Datum LWGEOM_force_4d ( PG_FUNCTION_ARGS  )

Definition at line 428 of file lwgeom_functions_basic.c.

429 {
430  GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
431  GSERIALIZED *pg_geom_out;
432  LWGEOM *lwg_in, *lwg_out;
433  double z = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(1);
434  double m = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(2);
435 
436  /* already 4d */
437  if (gserialized_ndims(pg_geom_in) == 4)
438  PG_RETURN_POINTER(pg_geom_in);
439 
440  lwg_in = lwgeom_from_gserialized(pg_geom_in);
441  lwg_out = lwgeom_force_4d(lwg_in, z, m);
442  pg_geom_out = geometry_serialize(lwg_out);
443  lwgeom_free(lwg_out);
444  lwgeom_free(lwg_in);
445 
446  PG_FREE_IF_COPY(pg_geom_in, 0);
447  PG_RETURN_POINTER(pg_geom_out);
448 }
int gserialized_ndims(const GSERIALIZED *g)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: gserialized.c:207
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
LWGEOM * lwgeom_force_4d(const LWGEOM *geom, double zval, double mval)
Definition: lwgeom.c:794

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

Here is the call graph for this function: