ST_Normalize

更新时间:
复制 MD 格式

Returns the normalized (canonical) form of a geometry object. Normalizing two geometries before comparing them ensures that differences in vertex order, ring order, or element order do not affect the result.

Syntax

geometry ST_Normalize(geometry geom)

Parameters

ParameterDescription
geomThe geometry object to normalize.

Description

ST_Normalize reorganizes the internal structure of a geometry object. The function may reorder vertices within rings, reorder rings within a polygon, and reorder elements within a MULTI geometry — without altering the geometric shape.

Examples

Normalize a LINESTRING

ST_Normalize reorders the vertices of the input geometry:

SELECT ST_AsText(ST_Normalize(ST_GeomFromText('LINESTRING(2 1,1 1)')));

Output:

      st_astext
---------------------
 LINESTRING(1 1,2 1)
(1 row)

What's next

  • ST_Equals: Tests whether two geometries are geometrically equal. Normalize both geometries with ST_Normalize before calling ST_Equals to ensure the comparison is not affected by ordering differences.