1. ISpatialFilter接口简介
ISpatialFilter是一个包含空间和属性限制的QueryFilter,可以使用该过滤器进行要素的空间属性筛选:
使用spatial filter执行空间查询,常作为IFeatureClass::Search、IFeatureClass::Select或feature layers上相似方法的参数
需要Geometry,GeometryField和SpatialRel属性。
Geometry是源图形,根据与其的关系执行空间选择。
GeometryField是图形字段名,将其中的图形与源图形比较。
SpatialRel属性将一个esriSpatialRelEnum传入来指定空间关系。
使用esriSearchOrder指定SearchOrder。当指定属性查询后,该属性将指定先执行那一部分查询,该属性仅对SDE数据源有效。
SaptialRelDescription是个字符串,可代替SpatialRel属性定义额外的空间关系。这种情况下,SpatialRel参数必须设置成esriSpatialRelRelation。
esriGeometry提供其他方式执行空间查询。
2 属性与方法
2.1 概述表
2.2 ISpatialFilter.SpatialRelDescription
public stringSpatialRelDescription {get; set;}
用来表述查询要素和对比要素的空间关系的数组,使用9个字符进行空间关系描述,使用该参数要求SpatialRel属性取枚举值esriSpatialRelRelation.它允许比较两个几何图形之间存在的任何空间关系, 空间关系由查询几何图形的边界、内部和外部与对比图形的交点确定。A spatial relationship is defined by the intersections between the boundary, interior, and exterior of the query geometry and the requested geometry.所有被esriSpatialRelEnum定义的关系,都可以由该属性计算得到。
描述空间关系的三个基本概念:
内部:形状的内部定义为整个形状减去其边界,也即其边界内部的所有部分。[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:
说明: in 'FFFTTT***', relationships 1-3 must be false, relationships 4-6 must be true, and relationships 7-9 are not tested.
组合示例:
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****'
与esriSpatialRelEnum含义对应的字符串
[Approximate esriSpatialRelEnum SpatialRelDescription Strings ]
2.3 ISpatialFilter.SpatialRel
[C#]public esriSpatialRelEnumSpatialRel {get; set;}
说明:
大多数空间关系是由边界、内部和外部的交集定义的;
所有形状都有内部,直线和多边形有一个边界;
大多数空间关系在检查两个特征之间的空间关系时使用容差。在大多数情况下,此公差是搜索要素的XY公差。公差范围内的所有几何图形都视为相交。在重叠情况下,公差设置最小重叠。重叠小于公差的几何图形将不会被视为重叠。
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.
用到XY容差的关系:esriSpatialRelIntersects,esriSpatialRelEnvelopeIntersects,esriSpatialRelTouches, esriSpatialRelOverlaps, esriSpatialRelCrosses, esriSpatialRelWithin,esriSpatialRelContains
esriSpatialRelRelation使用XY分辨率,通常比XY的容差小十倍
esriSpatialRelIndexIntersects不使用容差