問(wèn)題
書(shū)接上文點(diǎn)抽稀,在加載低層級(jí)瓦片時(shí),發(fā)現(xiàn)瓦片體積增大,渲染壓力也比較大。
思路
在上文點(diǎn)抽稀的基礎(chǔ)上稍作改造,提取多邊形中心點(diǎn)如法炮制,抽稀的結(jié)果再和原多邊形匹配,返回抽稀后的多邊形即可
SQL
select
b.geom,
a.count,
b.name
from
(
select
--用于分組
width_bucket(
st_x(c.geom),
st_xmin(
ST_TileEnvelope(Z, X, Y)
),
st_xmax(
ST_TileEnvelope(Z, X, Y)
),
50
) as grid_x,
width_bucket(
st_y(c.geom),
st_ymin(
ST_TileEnvelope(Z, X, Y)
),
st_ymax(
ST_TileEnvelope(Z, X, Y)
),
50
) as grid_y,
--集合&選點(diǎn)&統(tǒng)計(jì)
ST_GeometryN(
st_collect(c.geom),
1
) as geom,
count(c.geom)
from
(
select
st_centroid(geom) as geom
from
buildings
) as c --中心點(diǎn)拿出來(lái)抽稀
where
st_intersects(
c.geom,
ST_TileEnvelope(Z, X, Y)
)
group by
grid_x,
grid_y
) a,
buildings b
where
a.geom && st_centroid(b.geom); --重新匹配原有幾何
效果

bucket_width=500

bucket_width=100

bucket_width=50

bucket_width=20
后續(xù)
頁(yè)面加載效果待續(xù)