blog icon indicating copy to clipboard operation
blog copied to clipboard

请问 如果瓦片中有多个图层 如何实现???

Open lzp0070007 opened this issue 4 years ago • 3 comments

请问 如果瓦片中有多个图层 如何实现??? select st_asmvt(tile,'zbytz_mzzb_pg',4096,'geom') tile from (select w.gid,w.fldm,w.gbdm,w.mc,w.gxsj,w.lx,st_asmvtgeom(w.geom,st_makeenvelope(106.171875,26.71875,106.875,27.421875, 4326),4096, 0, true) as geom from zbytz_mzzb_pg w) as tile where tile.geom is not null

这个是一个图层 还要其他图层需要放入到一个tile

lzp0070007 avatar Mar 26 '20 03:03 lzp0070007

Tiles with multiple layers can be created by concatenating multiple calls to this function using ||. 所以直接 union all 就行。

select st_asmvt(tile,'zbytz_mzzb_pg',4096,'geom') tile from (select w.gid,w.fldm,w.gbdm,w.mc,w.gxsj,w.lx,st_asmvtgeom(w.geom,st_makeenvelope(106.171875,26.71875,106.875,27.421875, 4326),4096, 0, true) as geom from zbytz_mzzb_pg w) as tile where tile.geom is not null union all select st_asmvt(tile,'zbytz_mzzb_pg',4096,'geom') tile from (select w.gid,w.fldm,w.gbdm,w.mc,w.gxsj,w.lx,st_asmvtgeom(w.geom,st_makeenvelope(106.171875,26.71875,106.875,27.421875, 4326),4096, 0, true) as geom from zbytz_mzzb_pg w) as tile where tile.geom is not null

l-we avatar Mar 26 '20 03:03 l-we

select st_asmvt(tile,'zbytz_mzzb_pg',4096,'geom') tile from (select w.gid,w.fldm,w.gbdm,w.mc,w.gxsj,w.lx,st_asmvtgeom(w.geom,st_makeenvelope(106.171875,26.71875,106.875,27.421875, 4326),4096, 0, true) as geom from zbytz_mzzb_pg w) as tile where tile.geom is not null UNION ALL select st_asmvt(tile,'zbytz_mzzb_pg1',4096,'geom') tile from (select w.gid,w.fldm,w.gbdm,w.mc,w.gxsj,w.lx,st_asmvtgeom(w.geom,st_makeenvelope(106.171875,26.71875,106.875,27.421875, 4326),4096, 0, true) as geom from zbytz_mzzb_pg w) as tile where tile.geom is not null

image

返回的两行 还是两个瓦片 我想返回一个瓦片

lzp0070007 avatar Mar 26 '20 05:03 lzp0070007

with t1 as( SELECT ST_AsMVT(q, 'test', 4096, 'geom') as c1 FROM ( SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'), ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom ) AS q ) , t2 as( SELECT ST_AsMVT(q, 'test', 4096, 'geom') as c2 FROM ( SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'), ST_TileEnvelope(12,513,412), 4096, 0, false) AS geom ) AS q ) --使用‘||’ 将两个二进制文件合并成一个 select a.c1||b.c2 as tiles from t1 a join t2 b on 1=1

--可使用string_agg 合并试试 with t1 as( SELECT ST_AsMVT(q, 'test', 4096, 'geom') as c1 FROM ( SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'), ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom ) AS q union all SELECT ST_AsMVT(q, 'test', 4096, 'geom') as c2 FROM ( SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'), ST_TileEnvelope(12,513,412), 4096, 0, false) AS geom ) AS q ) select (string_agg(c1,'' ))::bytea as tiles from t1

haopingpang avatar Mar 29 '20 00:03 haopingpang