Recycling-Reprinting in the IFeatureClass. Search (filter, Recycling) method in Engine

Source: Internet
Author: User
IFeatureClass is always called in ArcGIS Engine. the Search (filter, Recycling) method sets the Recycling parameter to False, but does not understand why it is set to False. I have also read the help documentation of the Engine before, but I feel more confused. I have read it myself a few days ago. With my previous experiences and experiments, I have roughly understood the differences.

When the Recycling parameter is set to True, it is considered to be a reference, and when it is set to False, it is considered to be a value. Therefore, the difference between "pass value" and "transfer address" should be noted during the application.
We know that the transfer of reference ("Address Transfer") is more efficient, so we can use
True parameter. However, add the Feature Geometry to a collection or insert it to another
When FeatureClass is used, it must be called by passing the value, that is, the parameter is False, otherwise we add the final
Geometry in a variable ). We can use the following VBA code to test the result.
Theory.
Private Sub UISearch_Click ()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pWS As IFeatureWorkspace
Dim pWSEdit As IWorkspaceEdit
Dim pDataset As IDataset

Dim pMap As IMap
Set pMap = pDoc. FocusMap
Dim pFLayer As IFeatureLayer
Set pFLayer = pMap. Layer (0)

Dim pFC As IFeatureClass
Dim pFeatureCursor As IFeatureCursor
Set pFC = pFLayer. FeatureClass


Dim pColl As Collection
Set pColl = New Collection

Set pFeatureCursor = pFC. Search (Nothing, False) ', True )'

Dim pFeat As IFeature
Set pFeat = pFeatureCursor. NextFeature
Dim I As Long
I = 0
Dim dArea As Double
Dim pPolygon As ipolympus gon
Dim pArea As IArea

DArea = 0
Set pFeat = pFeatureCursor. NextFeature
Do Until pFeat Is Nothing
I = I + 1
Set pPolygon = pFeat. Shape
Set pArea = pPolygon
'Msgbox pArea. Area
DArea = dArea + pArea. Area
Call pColl. Add (pPolygon)

Set pFeat = pFeatureCursor. NextFeature
Loop
'Msgbox I & ":" & dArea

Dim pPolygon2 As ipolympus gon
For I = 1 To pColl. Count
Set pPolygon2 = pColl. Item (I)
Set pArea = pPolygon2
'Pfc. Search (Nothing, False), each time the area information is different, because the set
Each Geometry in (pColl) is different because the parameter is set to False, which is a value-passing call.
'Pfc. Search (Nothing, True), each pop-up area information is equal because of the Set
Each Geometry in (pColl) is the same, but it is actually the last IGeometry of traversal, because the Parameter
If it is set to False, the address is called.
MsgBox pArea. Area
Next I
End Sub
You can change the second parameter of the Search Method to see that the result is different.
Add the Collection set of VB, and insert it to other FeatureClass.

Http://blog.sina.com.cn/s/blog_4ad115cb01000a4i.html Bai Xuyang ESRI China

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.