Computes the effective area of each vertex in a geometry using the Visvalingam-Whyatt algorithm and stores the result as the M value of each vertex. Optionally filters vertices by a minimum area threshold for server-side simplification.
Syntax
geometry ST_SetEffectiveArea(geometry geomA, float threshold, integer setArea);Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
geomA | geometry | — | The input geometry object. |
threshold | float | 0 | Minimum effective area for vertex inclusion. When specified, only vertices with an effective area greater than or equal to this value are returned, enabling server-side simplification. When omitted (or set to 0), all vertices are returned with their computed effective areas. |
setArea | integer | 1 | Default value: 1. |
Return value
Returns a geometry object.
Usage notes
Supported types for simplification: Simplification operations apply to MultiLine, MultiPolygon, and MultiPoint objects. The function accepts any geometry type as input.
GeometryCollection support: The function processes each geometry in a collection independently, so it works with GeometryCollection objects.
M value: The effective area of each vertex is stored as its M value. The returned geometry object may lose its previous information stored in the M value.
3D support: The function supports 3D geometries. The Z dimension of the input affects the output geometry.
Output validity: The returned geometry may lose topological validity or simplicity. Validate the output if topology preservation is required.
Example
The following example calls ST_SetEffectiveArea with default parameters. The effective area of each vertex is stored in the M coordinate of the output.
SELECT ST_AsText(ST_SetEffectiveArea('LINESTRING(0 0,1 1,2 2 )'::geometry));Output:
st_astext
------------------------------------------------------
LINESTRING M (0 0 3.40282e+38,1 1 0,2 2 3.40282e+38)
(1 row)The endpoints have an effective area of 3.40282e+38 (the maximum float value, indicating they are always retained). The middle vertex has an effective area of 0, making it a candidate for removal when a threshold is applied.