所以我有一些代码可以使用空间过滤器对要素图层执行空间选择。这适用于普通要素类图层,但在 SDE 要素类上运行时会失败。我想知道是否有人可以阐明问题可能是什么?我得到的错误是 HRESULT 0x80041515,它给了我一个错误代码,我可以在任何地方找到任何信息。我的函数采用折线和图层字符串,并根据线的中心点在图层中选择一个多边形。这是代码示例:
' Creates centerpoint of line envelope
Dim pCenterPoint As IPoint = New Point
pCenterPoint.SpatialReference = pPolyline.SpatialReference
pCenterPoint.PutCoords((pPolyline.Envelope.XMin + pPolyline.Envelope.XMax) / 2, (pPolyline.Envelope.YMin + pPolyline.Envelope.YMax) / 2)
' Expands envelope
Dim eCenterEnvelope As IEnvelope
eCenterEnvelope = pCenterPoint.Envelope
eCenterEnvelope.Expand(pMxDoc.SearchTolerance, pMxDoc.SearchTolerance, False)
' Get layer of interest
Dim pLayer As IFeatureLayer = FindLayerByName(strSelect, layerType.FeatureLayer, False, False)
pLayer.Selectable = True
' Create spatial filter
Dim spatialFilter As ISpatialFilter = New SpatialFilterClass()
spatialFilter.Geometry = eCenterEnvelope
spatialFilter.GeometryField = pLayer.Name
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects
Dim queryFilter As IQueryFilter = New QueryFilterClass()
queryFilter = CType(spatialFilter, IQueryFilter)
' Select features
Dim pFeatureSelection As IFeatureSelection = pLayer
pFeatureSelection.Clear() 'clear any current selections in the layer first
pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultAdd, True)
If pFeatureSelection.SelectionSet.Count = 0 Then
Return False
Else
Return True
End If
当我调用 pFeatureSelection.SelectFeatures() 时,代码会失败,但仅当要素图层属于 SDE 要素类时。有任何想法吗?
谢谢,
卢克