計(jì)算幾何對(duì)象相交的所有網(wǎng)格對(duì)象。
語法
geomgrid[] ST_AsGrid(geometry geom, integer precision);
參數(shù)
參數(shù)名稱 | 描述 |
---|---|
geom | 需要計(jì)算的幾何對(duì)象。 |
precision | 精度級(jí)別,取值:0~31。 |
描述
幾何對(duì)象的空間參考必須是CGC2000(SRID=4490),如果不是則會(huì)調(diào)用空間投影變換函數(shù)(ST_Transform)對(duì)幾何對(duì)象的坐標(biāo)進(jìn)行轉(zhuǎn)換,請(qǐng)確保能正確轉(zhuǎn)換到CGC2000坐標(biāo)系統(tǒng)。
本函數(shù)將返回幾何對(duì)象相交的網(wǎng)格對(duì)象數(shù)組,對(duì)于點(diǎn)、線或面數(shù)據(jù)分別返回對(duì)應(yīng)的網(wǎng)格編碼,如下圖所示:
示例
select st_astext(st_asgrid(
ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490), 15))
st_astext
--------------------
{G001310322230230}
select st_astext(st_asgrid(
ST_geomfromtext('LINESTRING(122.48077 51.72814,122.47416 51.73714)',4490), 18))
st_astext
--------------------------------------------------------------------------------
{G001331032213300011,G001331032213300013,G001331032213122320,G00133103221312232
2,G001331032213300100,G001331032213122303,G001331032213122321,G00133103221312231
2}