ST_Rotate — 绕原点旋转几何图形。
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
)
;
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
, float
x0
, float
y0
)
;
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
, geometry
pointOrigin
)
;
绕原点逆时针旋转几何图形弧度。旋转原点可以指定为点几何图形,也可以指定为x和y坐标。如果未指定原点,几何图形将绕点(0 0)旋转。
增强:2.0.0引入了对多面体曲面、三角形和三角网的支持。
增强:2.0.0添加了用于指定旋转原点的其他参数。
可用性:1.1.2。在1.2.2中将名称从Rotate更改为ST_Rotate
This function supports 3d and will not drop the z-index.
This method supports Circular Strings and Curves
This function supports Polyhedral surfaces.
This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).
--Rotate 180 degrees
SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()));
st_asewkt
---------------------------------------
LINESTRING(-50 -160,-50 -50,-100 -50)
(1 row)
--Rotate 30 degrees counter-clockwise at x=50, y=160
SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()/6, 50, 160));
st_asewkt
---------------------------------------------------------------------------
LINESTRING(50 160,105 64.7372055837117,148.301270189222 89.7372055837117)
(1 row)
--Rotate 60 degrees clockwise from centroid
SELECT ST_AsEWKT(ST_Rotate(geom, -pi()/3, ST_Centroid(geom)))
FROM (SELECT 'LINESTRING (50 160, 50 50, 100 50)'::geometry AS geom) AS foo;
st_asewkt
--------------------------------------------------------------
LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708)
(1 row)