问题
书接上文点抽稀,在加载低层级瓦片时,发现瓦片体积增大,渲染压力也比较大。
思路
在上文点抽稀的基础上稍作改造,提取多边形中心点如法炮制,抽稀的结果再和原多边形匹配,返回抽稀后的多边形即可
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,
--集合&选点&统计
ST_GeometryN(
st_collect(c.geom),
1
) as geom,
count(c.geom)
from
(
select
st_centroid(geom) as geom
from
buildings
) as c --中心点拿出来抽稀
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); --重新匹配原有几何
效果
后续
页面加载效果待续