這個方法提供快速且僅限索引的交集方法,可判斷 geometry 執行個體是否與另一個 geometry 執行個體相交 (假設有提供索引)。
如果 geometry 執行個體有可能與另一個 geometry 執行個體相交,則會傳回 1。 這個方法可能會產生誤判傳回值,且確切的結果可能會依計畫而定。 如果未找到任何 geometry 執行個體相交,則傳回正確的 0 值 (真否定傳回值)。
在沒有提供索引或未使用索引的情況下,以相同的參數呼叫時,此方法所傳回的值會與 STIntersects() 相同。
適用於:SQL Server (SQL Server 2008 透過目前版本)、Windows Azure SQL 資料庫 (初始版本,透過目前版本)。 |
語法
.Filter ( other_geometry )
引數
- other_geometry
這是要與叫用 Filter() 之執行個體相比較的另一個 geometry 執行個體。
傳回類型
SQL Server 傳回類型:bit
CLR 傳回類型: SqlBoolean
備註
這個方法不具決定性或並非精確的。
範例
下列範例使用 Filter() 來判斷兩個 geometry 執行個體是否相交。
CREATE TABLE sample (id int primary key, g geometry);
GO
INSERT INTO sample VALUES
(0, geometry::Point(0, 0, 0)),
(1, geometry::Point(0, 1, 0)),
(2, geometry::Point(0, 2, 0)),
(3, geometry::Point(0, 3, 0)),
(4, geometry::Point(0, 4, 0));
CREATE SPATIAL INDEX sample_idx ON sample(g)
WITH (bounding_box = (-8000, -8000, 8000, 8000));
GO
SELECT id
FROM sample
WHERE g.Filter(geometry::Parse('POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))')) = 1;