Opened 15 years ago
Closed 2 years ago
#381 closed enhancement (duplicate)
Add an optional parameter to ST_Scale to specify the anchor point
Reported by: | kneufeld | Owned by: | kneufeld |
---|---|---|---|
Priority: | low | Milestone: | PostGIS Fund Me |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
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
'NE' | 'TR' - north east (top right) corner
…
'MP' | 'C' - midpoint (centre) of the geometry
All the complicated xmin/ymin translation stuff could then be automatically computed and placed in xoffset/yoffset parameters of ST_Affine.
Change History (6)
comment:1 by , 15 years ago
Owner: | changed from | to
---|
comment:2 by , 13 years ago
Milestone: | PostGIS 2.0.0 → PostGIS 2.1.0 |
---|
comment:3 by , 13 years ago
For CAD systems, you need to specify a point of origin, not just midpoint or corner. A similar enhancement for ST_Rotate (#1251) could also be adapted for ST_Scale to provide:
ST_Scale (geometry geomA, float XFactor, float YFactor, [float ZFactor,] geometry pointOrigin);
then a user could do, for example:
-- Scale down feet to metres from the top left corner SELECT ST_Scale(geom, 0.3048, 0.3048, ST_MakePoint(ST_XMin(geom), ST_YMax(geom))); -- Scale up by 2x from centre SELECT ST_Scale(geom, 2.0, 2.0, ST_Centroid(geom));
comment:4 by , 12 years ago
Milestone: | PostGIS 2.1.0 → PostGIS Future |
---|
comment:6 by , 2 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This was already done in - PostGIS 2.5.0
enhancements pushed to 2.1