将一个地理网格对象转换为瓦片坐标系的几何对象。
语法
geometry ST_AsMVTGeom(geomgrid grid, geometry bounds, int4 extent, int4 buffer, boolean clip_geom);
geometry ST_AsMVTGeom(h3grid grid, geometry bounds, int4 extent, int4 buffer, boolean clip_geom);
返回值
经过坐标系转换的几何对象。
参数
参数名称 | 描述 |
grid | 需要输出到MVT的geomgrid或h3地理网格对象。 |
bounds | 瓦片的矩形边界,不包含缓冲区。 |
extent | 瓦片坐标系中的瓦片大小,默认4096。 |
buffer | 瓦片坐标系中的缓冲区大小,默认256。 |
clip_geom | grid对应的几何形状是否被瓦片边界裁剪,默认true。 |
描述
将地理网格对象对应的几何形状转换为瓦片坐标系的几何对象。
和常用的输入参数为Geometry的ST_AsMVTGeom函数不同,bounds的类型为Geometry,而非Box2D。
输出的坐标系由bounds决定,建议使用ST_TileEnvelope函数来生成bounds。
若使用ST_TileEnvelope函数以外的方法来生成bounds,需要设定SRID。
示例
select st_asmvtgeom('010200040000'::geomgrid, st_tileenvelope(0, 0, 0));
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0103000020110F000001000000050000000000000000D8A2400000000000FC99400000000000D8A240000000000000A040000000000000A040000000000000A040000000000000A0400000000000FC99400000000000D8A2400000000000FC9940
select st_asmvtgeom('010200040000'::geomgrid, st_transform(st_tileenvelope(0, 0, 0), 4326));
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0103000020E610000001000000050000000000000000D8A2400000000000F493400000000000D8A240000000000000A040000000000000A040000000000000A040000000000000A0400000000000F493400000000000D8A2400000000000F49340
select st_asmvtgeom('010200040000'::geomgrid, st_transform(st_tileenvelope(0, 0, 0), 4326), 1024, 128, false);
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0103000020E610000001000000050000000000000000D882400000000000F073400000000000D8824000000000000080400000000000008040000000000000804000000000000080400000000000F073400000000000D882400000000000F07340
select st_asmvtgeom(st_h3fromlatlng(20.5, 128.2, 5), st_tileenvelope(0, 0, 0));
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0103000020110F00000100000006000000000000000064AB400000000000449C40000000000066AB400000000000489C40000000000066AB4000000000004C9C40000000000062AB4000000000004C9C40000000000062AB400000000000489C40000000000064AB400000000000449C40
select st_asmvtgeom(st_h3fromlatlng(20.5, 128.2, 5), 'SRID=4326;POLYGON((-180 -85,-180 85, 180 85, 180 -85, -180 -85))');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0103000020E61000000100000007000000000000000064AB400000000000449840000000000066AB400000000000489840000000000066AB400000000000509840000000000064AB400000000000549840000000000062AB400000000000549840000000000062AB4000000000004C9840000000000064AB40000000000044984
文档内容是否对您有帮助?