PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum ST_WrapX ( PG_FUNCTION_ARGS  )

Definition at line 1063 of file lwgeom_functions_basic.c.

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

1064 {
1065  Datum gdatum;
1066  GSERIALIZED *geom_in;
1067  LWGEOM *lwgeom_in, *lwgeom_out;
1068  GSERIALIZED *geom_out;
1069  double cutx;
1070  double amount;
1071 
1072  POSTGIS_DEBUG(2, "ST_WrapX called.");
1073 
1074  gdatum = PG_GETARG_DATUM(0);
1075  cutx = PG_GETARG_FLOAT8(1);
1076  amount = PG_GETARG_FLOAT8(2);
1077 
1078  //if ( ! amount ) PG_RETURN_DATUM(gdatum);
1079 
1080  geom_in = ((GSERIALIZED *)PG_DETOAST_DATUM(gdatum));
1081  lwgeom_in = lwgeom_from_gserialized(geom_in);
1082 
1083  lwgeom_out = lwgeom_wrapx(lwgeom_in, cutx, amount);
1084  geom_out = geometry_serialize(lwgeom_out);
1085 
1086  lwgeom_free(lwgeom_in);
1087  lwgeom_free(lwgeom_out);
1088  PG_FREE_IF_COPY(geom_in, 0);
1089 
1090  PG_RETURN_POINTER(geom_out);
1091 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
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)

Here is the call graph for this function: