PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_force_4d()

Datum LWGEOM_force_4d ( PG_FUNCTION_ARGS  )

Definition at line 435 of file lwgeom_functions_basic.c.

436{
437 GSERIALIZED *pg_geom_in = PG_GETARG_GSERIALIZED_P(0);
438 GSERIALIZED *pg_geom_out;
439 LWGEOM *lwg_in, *lwg_out;
440 double z = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(1);
441 double m = PG_NARGS() < 3 ? 0 : PG_GETARG_FLOAT8(2);
442
443 /* already 4d */
444 if (gserialized_ndims(pg_geom_in) == 4)
445 PG_RETURN_POINTER(pg_geom_in);
446
447 lwg_in = lwgeom_from_gserialized(pg_geom_in);
448 lwg_out = lwgeom_force_4d(lwg_in, z, m);
449 pg_geom_out = geometry_serialize(lwg_out);
450 lwgeom_free(lwg_out);
451 lwgeom_free(lwg_in);
452
453 PG_FREE_IF_COPY(pg_geom_in, 0);
454 PG_RETURN_POINTER(pg_geom_out);
455}
int gserialized_ndims(const GSERIALIZED *g)
Return the number of dimensions (2, 3, 4) in a geometry.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
LWGEOM * lwgeom_force_4d(const LWGEOM *geom, double zval, double mval)
Definition lwgeom.c:839

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

Here is the call graph for this function: