

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
public interface ISpatialFilter
Provides access to members that return and modify the type of spatial relationship that the filter will use.
ISpatialFilter is a QueryFilter that includes both spatial and attribute constraints. Therefore, a SpatialFilter can be used to restrict the set of features retrieved from a feature class using both spatial and attribute restrictions. ISpatialFilter inherits from IQueryFilter so you can optionally specify a string defining a where clause, include a list of columns to be retrieved or specify the spatial reference in which to output the geometry of the resulting features. See the IQueryFilter interface for help on the inherited methods and properties.
The most common ways to perform a spatial query using a spatial filter is to create the spatial filter using this interface and use it as a parameter for IFeatureClass::Search, IFeatureClass::Select or similar methods on feature layers, selection sets, etc.
The Geometry and SpatialRel properties are required.
Geometry is the source geometry in relation to which the spatial selection will be performed. GeometryField is a string corresponding to the name of the field containing the geometries to be compared to the source geometry. Finally the spatial relationship is specified with the SpatialRel property passing it an esriSpatialRelEnum .
A SearchOrder can be specified using an esriSearchOrder. When an attribute query is specified it will specify which of the attritute or spatial part of the query is executed first. A judicious choice may significantly improve the performances. This is only available with SDE datasources.
The SpatialRelDescription can optionally be populated with a string to define spatial relationships that are not possible using the esriSpatialRelEnum values. In this case the SpatialRel parameter must be set to esriSpatialRelRelation. See the help on the SpatialRelDescription property for details on string formatting.
The esriGeometry library provides other ways to perform a spatial selection. See, for instance, the example associated with ITopologicalOperator that performs a spatial selection on polylines that share a line segment.
IQueryDef
,
com.esri.arcgis.catalogUI.IGxObjectFilter
,
IFeatureClass.getFeatures(java.lang.Object, boolean)
,
IFeatureClass.search(com.esri.arcgis.geodatabase.IQueryFilter, boolean)
,
IFeatureClass.featureCount(com.esri.arcgis.geodatabase.IQueryFilter)
,
IQueryFilter
Method Summary  

IGeometry 
getGeometry()
The query geometry used to filter results. 
String 
getGeometryField()
The name of the Geometry field to which the filter applies. 
int 
getSearchOrder()
The search order used by the filter. 
int 
getSpatialRel()
The spatial relationship checked by the filter. 
String 
getSpatialRelDescription()
The array elements which describe the spatial relation between the query geometry and the requested geometries. 
boolean 
isFilterOwnsGeometry()
Indicates whether the filter owns the query geometry. 
void 
setGeometryByRef(IGeometry geometry)
The query geometry used to filter results. 
void 
setGeometryExByRef(IGeometry geometry,
boolean rhs2)
The query geometry used to filter results. 
void 
setGeometryField(String geomField)
The name of the Geometry field to which the filter applies. 
void 
setSearchOrder(int order)
The search order used by the filter. 
void 
setSpatialRel(int spatialRel)
The spatial relationship checked by the filter. 
void 
setSpatialRelDescription(String spatialRelDescription)
The array elements which describe the spatial relation between the query geometry and the requested geometries. 
Methods inherited from interface com.esri.arcgis.geodatabase.IQueryFilter 

addField, getOutputSpatialReference, getSubFields, getWhereClause, setOutputSpatialReferenceByRef, setSubFields, setWhereClause 
Method Detail 

int getSearchOrder() throws IOException, AutomationException
SearchOrder gets the order in which spatial searches are applied by the RDBMS (ArcSDE). The spatial component of the search should generally be applied before the attribute component. The more spatially restrictive of the two should be used. In the following query, "Find all wells with particulate counts between 1000 and 1200 in within 5 miles of a school", the esriSearchOrderAttribute enumerator is more effective. If the filter geometry is the outline of the city of Modesto, California and the attribute query is "street_name = 'Main St.'" then esriSearchOrderSpatial should be used, as there are a large number of "Main St." records at a national level.
Please note that esriSearchOrderSpatial is the default option. The following esriSearchOrder enumeration values are used to set the search order:
esriSearchOrderAttribute
Sets the search order to attribute first.
esriSearchOrderSpatial
Sets the search order to spatial first.
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setSearchOrder(int order) throws IOException, AutomationException
order
 A com.esri.arcgis.geodatabase.esriSearchOrder constant (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.int getSpatialRel() throws IOException, AutomationException
Tolerances
Most spatial relationships are defined by the intersection of boundaries, interior and exterior. All shapes have an interior. Lines and polygons have a boundary. Most spatial relations use a tolerance when examining the spatial relationship between two features. In most cases this tolerance is the XY tolerance of the search feature. All geometries within the tolerance are seen as intersecting. In the overlaps case the tolerance sets the minimum overlap. Geometries that overlap less than the tolerance will not be seen as overlapping.
Relationships that use the XY tolerance:
esriSpatialRelIntersects
esriSpatialRelEnvelopeIntersects
esriSpatialRelTouches
esriSpatialRelOverlaps
esriSpatialRelCrosses
esriSpatialRelWithin
esriSpatialRelContains
The esriSpatialRelRelation uses the XY resolution. Usually ten times smaller than the XY tolerance.
esriSpatialRelIndexIntersects does not use a tolerance.
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setSpatialRel(int spatialRel) throws IOException, AutomationException
spatialRel
 A com.esri.arcgis.geodatabase.esriSpatialRelEnum constant (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.IGeometry getGeometry() throws IOException, AutomationException
Only highlevel geometries, envelopes and geometry bags can be used. Highlevel geometries are polygons, polylines, points, and multipoints. Lowlevel geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used.
If a geometry bag is being used as the filter's query geometry, a spatial index should be created for the bag prior to any evaluation using the filter. This can be done by casting the geometry bag to the ISpatialIndex interface, setting the AllowIndexing property to true, and calling the Invalidate method.
Note that at ArcGIS 9.3 and later, setting this property to null will cause an error.
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setGeometryByRef(IGeometry geometry) throws IOException, AutomationException
Only highlevel geometries, envelopes and geometry bags can be used. Highlevel geometries are polygons, polylines, points, and multipoints. Lowlevel geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used.
geometry
 A reference to a com.esri.arcgis.geometry.IGeometry (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setGeometryExByRef(IGeometry geometry, boolean rhs2) throws IOException, AutomationException
Only highlevel geometries, envelopes and geometry bags can be used. Highlevel geometries are polygons, polylines, points, and multipoints. Lowlevel geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used.
The boolean parameter represents the FilterOwnsGeometry property.
geometry
 A reference to a com.esri.arcgis.geometry.IGeometry (in)rhs2
 The rhs2 (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.boolean isFilterOwnsGeometry() throws IOException, AutomationException
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.String getGeometryField() throws IOException, AutomationException
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setGeometryField(String geomField) throws IOException, AutomationException
geomField
 The geomField (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.String getSpatialRelDescription() throws IOException, AutomationException
A nine character string containing describing the spatial relationships to be tested by the spatial filter. Required when setting the SpatialRel property to use the esriSpatialRelRelation enumerator.
The SpatialRelDescription allows the comparison of any spatial relationship between two geometries. A spatial relationship is defined by the intersections between the boundary, interior, and exterior of the query geometry and the requested geometry.
All of the spatial relationships defined by the esriSpatialRelEnum enumeration can be duplicated using this property.
Interior:
The interior of a shape is defined as the entire shape minus its boundary. All shapes have interior.
Boundary:
Linear and area shapes have boundaries, but point shapes do not. The boundary of linear shapes consists of the end points of all linear parts. The boundary of area shapes consists of the linear boundary of the polygon shell(s).
Exterior:
The area outside a shape. All shapes have an exterior.
Each element for the first shape, the query geometry, may be tested against each element of the second shape, the requested geometry, giving nine possible spatial intersections as listed in the table below:
Query Geometry  Requested Geometry  

1  interior  interior 
2  interior  boundary 
3  interior  exterior 
4  boundary  interior 
5  boundary  boundary 
6  boundary  exterior 
7  exterior  interior 
8  exterior  boundary 
9  exterior  exterior 
The ninecharacters string expected by ISpatialFilter::SpatialRelDescription, is used to specify whether the intersection of each of the elements in the array is true (T), false (F), or not tested (*).
For instance, in 'FFFTTT***', relationships 13 must be false, relationships 46 must be true, and relationships 79 are not tested.
Note that any two shapes' exteriors always intersect.
Example Strings
Shares a boundary: '****T***'
Shares a boundary and interiors intersect: 'T***T****'
Shares a boundary and interiors do not intersect: 'F***T****'
Does not touch the boundary and interiors intersect: 'T***F****'
Relation  Query Geometry  Requested Geometry  String 
Contains  Line  Line  TT*FFT*** 
Contains  Point  Line  TT*FFT*** 
Contains  Point  Point  T******** 
Contains  Line  Poly  TT*FFT*** 
Contains  Poly  Poly  TT*FFT*** 
Crosses  Line  Line  TF*FF**** 
Crosses  Poly  Line  TT**F**** 
Crosses  Line  Poly  TT**T**** 
Overlaps  Line  Line  TT*T***** 
Overlaps  Point  Point  T******** 
Overlaps  Poly  Poly  TT*T***** 
Touch  Line  Line  FF*FT**** 
Touch  Poly  Line  FF*FT**** 
Touch  Line  Poly  FF*FT**** 
Touch  Poly  Poly  FF*FT**** 
Within  Line  Line  TF**F**** 
Within  Point  Line  T******** 
Within  Point  Point  T******** 
Within  Line  Poly  TF**F**** 
Within  Poly  Poly  TF**F**** 
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.void setSpatialRelDescription(String spatialRelDescription) throws IOException, AutomationException
spatialRelDescription
 The spatialRelDescription (in)
IOException
 If there are interop problems.
AutomationException
 If the ArcObject component throws an exception.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 