All Products
Search
Document Center

PolarDB:ST_SwapOrdinates

Last Updated:Mar 28, 2026

Swaps two coordinate ordinates of a meshgeom or sfmesh object.

Syntax

meshgeom  ST_SwapOrdinates(meshgeom  geom , cstring  ords);
sfmesh    ST_SwapOrdinates(sfmesh  sfmeshObject, cstring  ords);

Parameters

ParameterDescription
geomThe meshgeom object.
sfmeshObjectThe sfmesh object.
ordsThe two ordinates to swap. Specify a two-character string using any two of the following letters: x, y, z, and m.

Usage notes

  • Supports 3D objects. Z ordinates are preserved, not deleted.

  • Supports M ordinates.

Examples

Swap the X and Z ordinates of a meshgeom object:

SELECT ST_AsText(ST_SwapOrdinates(ST_MeshFromText('{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 2,0 10 3,10 10 1,10 0 1),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}'), 'xz'));

Output:

{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(2 0 0,3 10 0,1 10 10,1 0 10),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}