[postgis-users] Scale without translate?

Jeff Dege jdege at korterra.com
Thu May 17 14:40:45 PDT 2007


What is the cleanest way to scale a polygon without translating it?  If,
say, I wanted it doubled in every dimension, but the center to be on the
same point?

If I remember my computer graphics classes, I'd have to translate to the
origin, scale, then translate back.  Which could be done in three steps,
each of which would be a separate matrix multiplication.  Or I could
multiply the three matrices, and do it in one operation.

Reading the docs, It looks like I could do a translate(), scale(),
translate(), or if I knew the matrix I wanted, I could use affine().

Of course, I don't know the matrix I want.  I need to get it by
obtaining the center of the polygon I'm trying to scale.

So, can anyone point me to:

1: what function I use to determine the center of a polygon?

2: syntax for building a call to translate() using the function that
determines the center of a polygon?

3: syntax for building a call to affine() that does the
translate/scale/translate, using the function that determines the center
of the polygon, and the scaling factors I supply?


(As an aside, does PSQL include data types and operators for
manipulating transform matrices?)




More information about the postgis-users mailing list