全部產品
Search
文件中心

ApsaraDB RDS:ST_AsMVTGeom

更新時間:Jun 08, 2024

將一個地理網格對象轉換為瓦片座標系的幾何對象。

文法

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