ST_Distance 使用兩個幾何並傳回分隔它們的最短距離。
語法
db2gse.ST_Distance(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)
回覆類型
Double
範例
都市工程師需要距任何用地線一英尺內的全部建築物的列示。
BUILDINGFOOTPRINTS 表格的 BUILDING_ID 直欄唯一識別每一棟建築物。 LOT_ID 直欄識別建築物屬於的用地。覆蓋區多重多邊形儲存每一棟建築物覆蓋區的幾何。
CREATE TABLE BUILDINGFOOTPRINTS ( building_id integer, lot_id integer, footprint db2gse.ST_MultiPolygon);
LOTS 表格儲存用地 ID,該 ID 唯一識別每一塊用地和含有用地線幾何的用地多重多邊形。
CREATE TABLE LOTS ( lot_id integer, lot db2gse.ST_MultiPolygon);
查詢傳回距用地線 1 英尺內的建築物 ID 列示。 ST_Distance 函數執行用地多重多邊形的覆蓋區與界限的空間合併。 不過 bf.lot_id 與 LOTS.lot_id 之間的等式合併,確保 ST_Distance 函數只會比較屬於相同用地的多重多邊形。
SELECT bf.building_id FROM BUILDINGFOOTPRINTS bf, LOTS WHERE bf.lot_id = LOTS.lot_id AND db2gse.ST_Distance(bf.footprint, db2gse.ST_Boundary(LOTS.lot)) <= 1.0;