PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_WrapX()

Datum ST_WrapX ( PG_FUNCTION_ARGS  )

Definition at line 1062 of file lwgeom_functions_basic.c.

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

Referenced by LWGEOM_longitude_shift().

1063 {
1064  Datum gdatum;
1065  GSERIALIZED *geom_in;
1066  LWGEOM *lwgeom_in, *lwgeom_out;
1067  GSERIALIZED *geom_out;
1068  double cutx;
1069  double amount;
1070 
1071  POSTGIS_DEBUG(2, "ST_WrapX called.");
1072 
1073  gdatum = PG_GETARG_DATUM(0);
1074  cutx = PG_GETARG_FLOAT8(1);
1075  amount = PG_GETARG_FLOAT8(2);
1076 
1077  //if ( ! amount ) PG_RETURN_DATUM(gdatum);
1078 
1079  geom_in = ((GSERIALIZED *)PG_DETOAST_DATUM(gdatum));
1080  lwgeom_in = lwgeom_from_gserialized(geom_in);
1081 
1082  lwgeom_out = lwgeom_wrapx(lwgeom_in, cutx, amount);
1083  geom_out = geometry_serialize(lwgeom_out);
1084 
1085  lwgeom_free(lwgeom_in);
1086  lwgeom_free(lwgeom_out);
1087  PG_FREE_IF_COPY(geom_in, 0);
1088 
1089  PG_RETURN_POINTER(geom_out);
1090 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:167
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function:
Here is the caller graph for this function: