Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lzp0070007 opened this issue Mar 26, 2020 · 3 comments
Open

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

lzp0070007 opened this issue Mar 26, 2020 · 3 comments

Comments

@lzp0070007
Copy link

请问 如果瓦片中有多个图层 如何实现???
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

@l-we
Copy link

l-we commented Mar 26, 2020

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

@lzp0070007
Copy link
Author

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

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

@haopingpang
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants