[postgis-devel] [PostGIS] #1353: [raster] ST_SetRotation incorrect

Bryce L Nordgren bnordgren at gmail.com
Sat Feb 11 11:04:37 PST 2012


On Wed, Feb 8, 2012 at 10:29 PM, David Zwarg <dzwarg+postgis at azavea.com>wrote:

> Hello Bryce,
>
> I dug through your git repository and nabbed out the st_geotransform
> methods, put them in core and rt_pg. I replaced the rt_rotation test and
> expected output with the values that you provided. I'm not sure if this
> also resolves the preservation of the angle between the basis vectors --
> does that feature rely on something else, or is it all included in the
> geotransform code that you had in your repo?
>

Sorry for the delay. All is included. The "magic" is in
RASTER_setrotation() here:

    /* preserve all defining characteristics of the grid except for
rotation */
    rt_raster_get_phys_params(raster, &imag, &jmag, &theta_i, &theta_ij);
    rt_raster_set_phys_params(raster, imag, jmag, rotation, theta_ij);

"theta_ij" is the angle between the basis vectors, as described on the wiki
page. Also, you may want to note in the documentation that "rotation" is an
absolute value specifying the angle between the "i" vector and the
"x/easting" axis in whatever SRID you're using. It's not an additional
rotation over and above whatever the "current" rotation is. If you do want
"setrotation" to essentially perform a "rotate 'rotation' degrees relative
to however the raster is currently rotated", change the above to:

    /* preserve all defining characteristics of the grid except for
rotation */
    rt_raster_get_phys_params(raster, &imag, &jmag, &theta_i, &theta_ij);
    rt_raster_set_phys_params(raster, imag, jmag, rotation+theta_i,
theta_ij);

Both are fine with me, as it seems like a kind of arbirary choice as long
as the docs make it clear what the function is trying to do.

As a bonus for all your hard work, it appears that  #1331 can be closed out
as a duplicate of #1556.

Good work!

Bryce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20120211/86b7bfce/attachment.html>


More information about the postgis-devel mailing list