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
| Parameter | Description |
|---|---|
geom | The 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_Normalizebefore callingST_Equalsto ensure the comparison is not affected by ordering differences.
该文章对您有帮助吗?