ST_SwapOrdinates

更新时间:
复制 MD 格式

Swaps two coordinate ordinates in a geometry object.

Syntax

geometry ST_SwapOrdinates(geometry geom, cstring ords);

Parameters

ParameterDescription
geomThe geometry object whose coordinates to swap.
ordsThe two ordinates to swap. A 2-character string composed of any two of the following characters: x, y, z, m.

Usage notes

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

  • Preserves z coordinates in 3D objects — no ordinate is dropped.

  • Supports m coordinates.

Examples

Swap the x and y ordinates of a point:

SELECT ST_AsText(ST_SwapOrdinates('POINT(1 0)'::geometry, 'xy'));

Output:

 st_astext
------------
 POINT(0 1)
(1 row)