PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ST_WrapX()

Datum ST_WrapX ( PG_FUNCTION_ARGS  )

Definition at line 1074 of file lwgeom_functions_basic.c.

1075 {
1076  Datum gdatum;
1077  GSERIALIZED *geom_in;
1078  LWGEOM *lwgeom_in, *lwgeom_out;
1079  GSERIALIZED *geom_out;
1080  double cutx;
1081  double amount;
1082 
1083  POSTGIS_DEBUG(2, "ST_WrapX called.");
1084 
1085  gdatum = PG_GETARG_DATUM(0);
1086  cutx = PG_GETARG_FLOAT8(1);
1087  amount = PG_GETARG_FLOAT8(2);
1088 
1089  // if ( ! amount ) PG_RETURN_DATUM(gdatum);
1090 
1091  geom_in = ((GSERIALIZED *)PG_DETOAST_DATUM(gdatum));
1092  lwgeom_in = lwgeom_from_gserialized(geom_in);
1093 
1094  lwgeom_out = lwgeom_wrapx(lwgeom_in, cutx, amount);
1095  geom_out = geometry_serialize(lwgeom_out);
1096 
1097  lwgeom_free(lwgeom_in);
1098  lwgeom_free(lwgeom_out);
1099  PG_FREE_IF_COPY(geom_in, 0);
1100 
1101  PG_RETURN_POINTER(geom_out);
1102 }
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_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:169
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

References geometry_serialize(), lwgeom_free(), lwgeom_from_gserialized(), and lwgeom_wrapx().

Here is the call graph for this function: