Within Operator

Within is a boolean spatial operator that evaluates whether an object, such as a polygon, contains all of another geometry.

Example 1:

SELECT city FROM table WHERE obj Within <geometry>

If the data source provider supports Within, the entire query is delegated to the data source provider.

If the data source provider does not support Within, the query is converted to an EnvelopesIntersect and delegated as follows:

SELECT city, obj FROM table WHERE obj EnvelopesIntersect <geometry>

Spectrum Spatial evaluates Within using the results from the data source provider:

SELECT city FROM <results of the delegation> WHERE obj Within <geometry>

Example 2:

SELECT city FROM table WHERE <geometry> Within obj

This example is the opposite of the first example. It is the inverse of the Contains operator with the operands reversed. As written, this query does not meet the rules of the WHERE clause, where boolean operators must be in the form WHERE <column> operator <geometry>. The query is rephrased as a Contains operation and delegated according to the rules for Contains.

SELECT city FROM table WHERE obj Contains <geometry>