[postgis-devel] [PostGIS] #381: Add an optional parameter to ST_Scale to specify the anchor point

PostGIS trac at osgeo.org
Mon Jan 11 13:12:42 PST 2010


#381: Add an optional parameter to ST_Scale to specify the anchor point
-------------------------+--------------------------------------------------
 Reporter:  kneufeld     |       Owner:  pramsey      
     Type:  enhancement  |      Status:  new          
 Priority:  low          |   Milestone:  PostGIS 2.0.0
Component:  postgis      |     Version:  trunk        
 Keywords:               |  
-------------------------+--------------------------------------------------
 ST_Scale is a simple wrapper around ST_Affine, but it's missing a very
 common "scale about the midpoint or lower left" option.

 IE. simply scaling about the midpoint of a geometry is currently a
 complicated two step approach:
 {{{
 SELECT
   ST_AsText(
     ST_Translate(
       ST_Scale(geom, 3, 2),
       -3 * (ST_Xmin(geom)+ST_XMax(geom))/2 +
 ((ST_Xmin(geom)+ST_XMax(geom))/2),
       -2 * (ST_Ymin(geom)+ST_YMax(geom))/2 +
 ((ST_Ymin(geom)+ST_YMax(geom))/2)
     )
   )

 FROM
   (SELECT 'POLYGON (( 2 5, 2 6, 3 6, 3 5, 2 5 ))'::geometry AS geom) a;
                 st_astext
 ------------------------------------------
  POLYGON((1 4.5,1 6.5,4 6.5,4 4.5,1 4.5))
 (1 row)
 }}}

 I recommend a new optional char(2) parameter be added to ST_Scale that
 will permit a user to scale based on various common anchor points:
  'SW' | 'BL' - south west (bottom left) corner[[BR]]
  'NE' | 'TR' - north east (top right) corner[[BR]]
  ...[[BR]]
  'MP' | 'C' - midpoint (centre) of the geometry[[BR]]

 All the complicated xmin/ymin translation stuff could then be
 automatically computed and placed in xoffset/yoffset parameters of
 ST_Affine.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/381>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list