2956{
2958 GSERIALIZED *geom_scale = PG_GETARG_GSERIALIZED_P(1);
2960 LWGEOM *lwg, *lwg_scale, *lwg_origin;
2961 LWPOINT *lwpt_scale, *lwpt_origin;
2964 bool translate = false;
2967
2968
2971 if (!lwpt_scale)
2972 {
2974 PG_FREE_IF_COPY(geom_scale, 1);
2975 lwpgerror("Scale factor geometry parameter must be a point");
2976 PG_RETURN_NULL();
2977 }
2978
2979
2980 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
2982
2983
2985 {
2988 PG_FREE_IF_COPY(geom_scale, 1);
2989 PG_RETURN_POINTER(geom);
2990 }
2991
2992
2993
3000
3001
3002 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3003 {
3004 geom_origin = PG_GETARG_GSERIALIZED_P(2);
3007 if (lwpt_origin)
3008 {
3010 translate = true;
3011 }
3012
3014 PG_FREE_IF_COPY(geom_origin, 2);
3015 }
3016
3017
3018 if (translate)
3019 {
3020
3021 memset(&aff, 0,
sizeof(
AFFINE));
3022
3024
3025 aff.
xoff = -1 * origin.
x;
3026 aff.
yoff = -1 * origin.
y;
3027 aff.
zoff = -1 * origin.
z;
3029 }
3030
3032
3033
3034 if (translate)
3035 {
3040 }
3041
3042
3045 PG_FREE_IF_COPY(geom, 0);
3046 PG_FREE_IF_COPY(geom_scale, 1);
3047 PG_RETURN_POINTER(ret);
3048}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
void lwgeom_free(LWGEOM *geom)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)