3164{
3166 GSERIALIZED *geom_scale = PG_GETARG_GSERIALIZED_P(1);
3168 LWGEOM *lwg, *lwg_scale, *lwg_origin;
3169 LWPOINT *lwpt_scale, *lwpt_origin;
3172 bool translate = false;
3175
3176
3179 if (!lwpt_scale)
3180 {
3182 PG_FREE_IF_COPY(geom_scale, 1);
3183 lwpgerror("Scale factor geometry parameter must be a point");
3184 PG_RETURN_NULL();
3185 }
3186
3187
3188 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
3190
3191
3193 {
3196 PG_FREE_IF_COPY(geom_scale, 1);
3197 PG_RETURN_POINTER(geom);
3198 }
3199
3200
3201
3208
3209
3210 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
3211 {
3212 geom_origin = PG_GETARG_GSERIALIZED_P(2);
3215 if (lwpt_origin)
3216 {
3218 translate = true;
3219 }
3220
3222 PG_FREE_IF_COPY(geom_origin, 2);
3223 }
3224
3225
3226 if (translate)
3227 {
3228
3229 memset(&aff, 0,
sizeof(
AFFINE));
3230
3232
3233 aff.
xoff = -1 * origin.
x;
3234 aff.
yoff = -1 * origin.
y;
3235 aff.
zoff = -1 * origin.
z;
3237 }
3238
3240
3241
3242 if (translate)
3243 {
3248 }
3249
3250
3251 ret = geometry_serialize(lwg);
3253 PG_FREE_IF_COPY(geom, 0);
3254 PG_FREE_IF_COPY(geom_scale, 1);
3255 PG_RETURN_POINTER(ret);
3256}
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)