Filter (geography Data Type)

A method that offers a fast, index-only intersection method to determine if a geography instance intersects another geography instance, assuming an index is available.

Returns 1 if a geography instance potentially intersects another geography instance. This method may produce a false-positive return, and the exact result may be plan-dependent. Returns an accurate 0 value (true negative return) if there is no intersection of geography instances found.

In cases where an index is not available, or is not used, the method will return the same values as STIntersects() when called with the same parameters.

Syntax

.Filter ( other_geography )

Arguments

Term

Definition

other_geography

Is another geography instance to compare against the instance on which Filter() is invoked.

Return Types

SQL Server return type: bit

CLR return type: SqlBoolean

Remarks

This method is not deterministic and is not precise.

Examples

The following example uses Filter() to determine if two geography instances intersect each other.

Code

CREATE table sample (id int primary key, g geography);
INSERT INTO sample values
   (0, geography::Point(45, -120, 4326)),
   (1, geography::Point(45, -120.1, 4326)),
   (2, geography::Point(45, -120.2, 4326)),
   (3, geography::Point(45, -120.3, 4326)),
   (4, geography::Point(45, -120.4, 4326))

CREATE spatial index sample_idx on sample(g);
SELECT id
FROM sample 
WHERE g.Filter(geography::Parse(
   'POLYGON((-120.1 44.9, -119.9 44.9, -119.9 45.1, -120.1 45.1, -120.1 44.9))')) = 1;

See Also

Reference

STIntersects (geography Data Type)

Other Resources

Extended Methods on Geography Instances