ST_Scale

更新时间:
复制 MD 格式

Scales a geometry object to a new size by multiplying its coordinate values by the corresponding factors.

Syntax

geometry ST_Scale(geometry geomA, float xFactor, float yFactor, float zFactor);
geometry ST_Scale(geometry geomA, float xFactor, float yFactor);
geometry ST_Scale(geometry geom, geometry factor);
geometry ST_Scale(geometry geom, geometry factor, geometry origin);

Parameters

ParameterDescription
geomA/geomThe geometry object to scale.
xFactorThe scaling factor for x coordinate values.
yFactorThe scaling factor for y coordinate values.
zFactorThe scaling factor for z coordinate values.
factorThe scaling factor as a geometry point. Accepts 2D, 3DM, 3DZ, or 4D point objects, which sets the scaling factor for all supported dimensions.
originThe origin point of the scaling operation.

Description

  • If xFactor, yFactor, or zFactor is not specified, scaling is not applied to the corresponding dimension.

  • Supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.

  • Supports geometry objects that contain m coordinates.

  • If origin is specified, the function scales the geometry object in place relative to that origin — for example, using the centroid of the geometry object. If origin is not specified, the function scales the geometry object relative to the actual origin by multiplying each coordinate value by its corresponding factor.

Examples

Scale a geometry object using scalar x and y factors.

SELECT ST_AsText(ST_Scale('LINESTRING(2 1,1 1)'::geometry,2,2));
      st_astext
---------------------
 LINESTRING(4 2,2 2)
(1 row)

Scale a geometry object using the factor geometry parameter.

SELECT ST_AsText(ST_Scale('LINESTRING(2 1,1 1)'::geometry,'POINT(2 2)'::geometry));
      st_astext
---------------------
 LINESTRING(4 2,2 2)
(1 row)

Scale a geometry object with and without an origin parameter, and compare the results.

SELECT
    ST_Scale(g,factor),
  ST_Scale(g,factor,'POINT(2 1)'::geometry),g
  from (select 'LINESTRING(2 1,1 1,1 2)'::geometry as g,'POINT(3 3)'::geometry as factor) as t;
1