ST_SimplifyPreserveTopology — 使用Douglas-Peucker算法返回几何图形的简化和有效版本。
geometry ST_SimplifyPreserveTopology(
geometry geomA, float tolerance)
;
使用Douglas-Peucker算法返回给定几何体的简化版本。将避免创建无效的衍生几何图形(特别是多边形)。我实际上只对(多)线和(多)多边形做了一些事情,但你可以安全地用任何类型的几何体调用它。由于简化是在逐个对象的基础上进行的,因此您还可以将GeometryCollection提供给此函数。
由GEOS模块执行。
可用性:1.3.3
与简化相同的示例,但我们看到保留拓扑可防止过度简化。这个圆最多只能变成一个正方形。
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