Nome

ST_Rotate — Rotates a geometry about an origin point.

Sinossi

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);

Descrizione

Rotates geometry rotRadians counter-clockwise about the origin point. The rotation origin can be specified either as a POINT geometry, or as x and y coordinates. If the origin is not specified, the geometry is rotated about POINT(0 0).

Migliorato: Nella 2.0.0 è stato introdotto il supporto per le superfici poliedriche, i triangoli e i TIN.

Enhanced: 2.0.0 additional parameters for specifying the origin of rotation were added.

Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2

Questa funzione supporta il 3d e non distrugge gli z-index.

Questo metodo supporta le Curve e le Circular String.

Questa funzione supporta le Polyhedral Surface.

Questa funzione supporta i Triangoli e le Triangulated Irregular Network Surfaces (TIN).

Esempi

This example rotates a geometry by 180 degrees.

Code
SELECT ST_Rotate('LINESTRING (50 160,50 50,100 50)'::geometry, pi());
Output
LINESTRING(-50 -160,-50 -50,-100 -50)
Figure
Geometry figure for visual-st-rotate-01

This example rotates a geometry 30 degrees counter-clockwise around x=50, y=160.

Code
SELECT ST_Rotate('LINESTRING (50 160,50 50,100 50)'::geometry, pi()/6, 50, 160);
Output
LINESTRING(50 160,105 64.737206,148.30127 89.737206)
Figure
Geometry figure for visual-st-rotate-02

This example rotates a geometry 60 degrees clockwise around its centroid.

Code
SELECT ST_Rotate(geom, -pi()/3, ST_Centroid(geom))
FROM (SELECT 'LINESTRING (50 160,50 50,100 50)'::geometry AS geom) AS foo;
Output
LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708)
Figure
Geometry figure for visual-st-rotate-03