Computes the Delaunay triangulation of the vertices of a geometry object and returns the result as a geometry collection, MultiLineString, or triangulated irregular network (TIN) surface.
Syntax
geometry ST_DelaunayTriangles(geometry g1, float tolerance, int4 flags);Parameters
| Parameter | Type | Description |
|---|---|---|
g1 | geometry | The input geometry object. |
tolerance | float | The tolerance of the vertices of the input geometry object. |
flags | int4 | The bitfield that controls the output type. Default: 0. Valid values: 0 (polygon collection), 1 (MultiLineString), 2 (TIN surface). See the following table for details. |
`flags` values:
| Value | Output type |
|---|---|
0 | Collection of polygon objects (default) |
1 | MultiLineString |
2 | TIN surface |
Description
ST_DelaunayTriangles supports triangles and TIN surfaces.
Examples
Default output (polygon collection)
The following example generates 30 random points inside a unit square and computes the Delaunay triangulation, returning the result as a collection of triangle polygons (default flags = 0).
SELECT g, ST_DelaunayTriangles(g)
FROM (
SELECT ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry, 30) AS g
) AS t;
MultiLineString output (flags = 1)
Set flags = 1 to return the triangle edges as a MultiLineString instead of filled polygons.
SELECT ST_DelaunayTriangles(g, 0.0, 1)
FROM (
SELECT ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry, 30) AS g
) AS t;TIN surface output (flags = 2)
Set flags = 2 to return the result as a TIN surface.
SELECT ST_DelaunayTriangles(g, 0.0, 2)
FROM (
SELECT ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry, 30) AS g
) AS t;该文章对您有帮助吗?