ST_GeometryN 使用一個集合和一個整數指標, 然後將第 n 個幾何物件傳回該集合。
語法
db2gse.ST GeometryN(g db2gse.ST_GeomCollection, n Integer)
回覆類型
db2gse.ST_Geometry
範例
都市工程師必須知道建築物覆蓋區是否在用地的多重多邊形的第一個多邊形內。
BUILDING_ID 直欄唯一識別 BUILDINGFOOTPRINTS 表格的每一列。LOT_ID 直欄識別建築物用地。 FOOTPRINT 直欄儲存建築物的幾何。
CREATE TABLE BUILDINGFOOTPRINTS ( building_id integer, lot_id integer, footprint db2gse.ST_MultiPolygon); CREATE TABLE LOTS ( lot_id integer, lot db2gse.ST_MultiPolygon);
查詢列示在第一塊用地多邊形內的全部建築物覆蓋區的 BUILDINGFOOTPRINTS building_id 和 lot_id。 ST_GeometryN 函數傳回多重多邊形陣列中的第一塊用地多邊形。
SELECT bf.building_id,bf.lot_id FROM BUILDINGFOOTPRINTS bf,LOTS WHERE db2gse.ST_Within(footprint, db2gse.ST_GeometryN (lot,1)) = 1 AND bf.lot_id = LOTS.lot_id;