All Products
Search
Document Center

PolarDB:ST_SwapOrdinates

Last Updated:Mar 28, 2026

Swaps two specified coordinate ordinates of a meshgeom or sfmesh object and returns the modified 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 pair of coordinate ordinates to swap. Specify any two letters from x, y, z, and m as a two-character string.

Usage notes

  • Supports 3D objects. Z coordinates are preserved and not deleted.

  • Supports m coordinates.

Examples

The following example swaps the x and z coordinates of a meshgeom object. The input vertices (0 0 2, 0 10 3, 10 10 1, 10 0 1) become (2 0 0, 3 10 0, 1 10 10, 1 0 10) in the output.

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}]}