名称

ST_SimplifyPreserveTopology — 使用 Douglas-Peucker 算法返回几何图形的简化有效版本。

概要

geometry ST_SimplifyPreserveTopology(geometry geomA, float tolerance);

描述

使用 Douglas-Peucker 算法返回给定几何图形的“简化”版本。将避免创建无效的派生几何图形(尤其是多边形)。实际上,它只对(多)线和(多)多边形起作用,但您可以安全地对任何类型的几何图形调用它。由于简化是在对象的基础上进行的,因此您也可以将 GeometryCollection 传递给此函数。

由 GEOS 模块执行。

可用性:1.3.3

示例

与 Simplify 相同的示例,但我们看到 Preserve Topology 阻止了过度简化。圆最多只能变成正方形。

SELECT ST_Npoints(geom) As np_before, ST_NPoints(ST_SimplifyPreserveTopology(geom,0.1)) As np01_notbadcircle, ST_NPoints(ST_SimplifyPreserveTopology(geom,0.5)) As np05_notquitecircle,
ST_NPoints(ST_SimplifyPreserveTopology(geom,1)) As np1_octagon, ST_NPoints(ST_SimplifyPreserveTopology(geom,10)) As np10_square,
ST_NPoints(ST_SimplifyPreserveTopology(geom,100)) As  np100_stillsquare
FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As geom) As foo;

--result--
 np_before | np01_notbadcircle | np05_notquitecircle | np1_octagon | np10_square | np100_stillsquare
-----------+-------------------+---------------------+-------------+---------------+-------------------
        49 |                33 |                  17 |           9 |             5 |                 5
                

另请参阅

ST_Simplify