Problems with Annotation Feature Class

451
2
06-03-2010 02:04 AM
by Anonymous User
Not applicable
Original User: newbyproger

Hello. I have 2 layers: one with polygons, another with text (annotation featuretype). I need to find if there is a label to each polygon. There is a part of code:

    Dim pPolygonsFCur As IFeatureCursor
    Set pPolygonsFCur = pPolygonsFeatClass.Search(Nothing, 1)
    
    Dim pPolygonFeat As IFeature
    Set pPolygonFeat = pPolygonsFCur.NextFeature
    
    Dim pTopoOperator As ITopologicalOperator
    Set pTopoOperator = New Polygon
    
    Dim pSpatialFilter As ISpatialFilter
    Set pSpatialFilter = New SpatialFilter
    pSpatialFilter.SpatialRel = esriSpatialRelIntersects

    Dim pAnnoFCur As IFeatureCursor
    Dim pAnnoFeat As IFeature
    Do Until pPolygonFeat Is Nothing
        Set pTopoOpeartor = pPolygonFeat.ShapeCopy
        Set pSpatialFilter.Geometry = pTopoOperator.Buffer(500)
        Set pAnnoFCur = pAnnoFeatClass.Search(pSpatialFilter, 1)
        Set pAnnoFeat = pAnnoFCur.NextFeature
        Do Until pAnnoFeat Is Nothing
            If (pPolygonFeat.Value(iNameIndex) = pAnnoFeat.Value(iTextFieldIndex)) Then
                'remember pPolygonFeat.OID
            End If
            Set pAnnoFeat = pAnnoFCur.NextFeature
        Loop
        Set pPolygonFeat = pPolygonsFCur.NextFeature
    Loop


1. What is wrong? pAnnoFeatClass.Search(pSpatialFilter, 1) doesnt give any result everytime
2. Is it possible not to use Decimal Degree units in buffer? map units are meters.
0 Kudos
2 Replies
AlexanderGray
Occasional Contributor III
I suggest you turn options explicit on.
this line has a spelling mistake
Set pTopoOpeartor = pPolygonFeat.ShapeCopy

Since you already instantiated pTopoOperator as a new polygon, your filter is technically ok but checking against an empty geometry.  You don't need to instantiate the polygon if you are planning to assign it a geometry from shapecopy.
0 Kudos
by Anonymous User
Not applicable
Original User: newbyproger

omg. the problem was in pTopoOpeARtor (must be pTopoOpeRAtor). Now it works. Thanks

But what about 2nd question? In every buffer sample for polygons meters are used (like buffer(500)), but in my case units are decimal degrees automatically. Map units are meters. What sould I do?
0 Kudos