使用Chaikin算法返回給定Geometry對象的平滑版本。

語法

geometry  ST_ChaikinSmoothing(geometry  geom , integer  nIterations , boolean  preserveEndPoints);

參數

參數名稱 描述
geom 目標Geometry對象。
nIterations 迭代次數。最大值為5,默認為1。
preserveEndPoints 標志位,是否保留端點,默認為false。只對多邊形有意義。

描述

  • 每次迭代頂點數將增加一倍。
    • 該函數在每個點之前和之后的線的1/4處放置新的頂點,并刪除原始點。
    • 新點將為所有包含的維度(也包括z和m)插值。
  • 返回的Geometry對象將比原始對象具有更多的點。要減少點數,請對結果使用ST_SimplifyST_SimplifyVW等簡化函數。

示例

不同迭代次數的效果對比:
select g,ST_ChaikinSmoothing(g,1),
             ST_ChaikinSmoothing(g,5)
       from (select 'LINESTRING(0 0,2 2,3 1,3.5 1.5,5 0,5.25 0.25,5.5 0)'::geometry as g) as t;
123