ST_DelaunayTriangles

更新时间:
复制 MD 格式

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

ParameterTypeDescription
g1geometryThe input geometry object.
tolerancefloatThe tolerance of the vertices of the input geometry object.
flagsint4The 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:

ValueOutput type
0Collection of polygon objects (default)
1MultiLineString
2TIN 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;
Result of ST_DelaunayTriangles with default parameters

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;