Select to view content in your preferred language

The Cursor of Search method need Release?

968
5
06-20-2010 09:44 PM
szcszc
by
Emerging Contributor
If I shield the first search, the finally time is about 50ms, but if I don't shiled the first search, the finally time is more than 1000ms, the key is the variable "ipFeatureCursor", it seems that Repeatedly Search result in low Efficiency

IFeatureClassPtr ipFeatureClass;
hr = ipFeatureWorkspace->OpenFeatureClass(CComBSTR("POINT"), &ipFeatureClass);

IQueryFilterPtr ipQueryFilter(CLSID_SpatialFilter);

ISpatialFilterPtr ipSpatialFilter;
ipSpatialFilter = ipQueryFilter;

IEnvelopePtr ipEnvelope(CLSID_Envelope);
hr = ipEnvelope->PutCoords(418500,143700,418950,144000);
hr = ipSpatialFilter->putref_Geometry(IGeometryPtr(ipEnvelope));
hr = ipSpatialFilter->put_SpatialRel(esriSpatialRelEnvelopeIntersects);

BSTR strFieldName;
hr = ipFeatureClass->get_ShapeFieldName(&strFieldName);
hr = ipSpatialFilter->put_GeometryField(strFieldName);

IFeatureCursorPtr ipFeatureCursor;
hr = ipFeatureClass->Search(ipQueryFilter, VARIANT_FALSE, &ipFeatureCursor); //The firsrt Search

IEnvelopePtr ipEnvelope2(CLSID_Envelope);
hr = ipEnvelope2->PutCoords(418770,143850,418790,143890);
hr = ipSpatialFilter->putref_Geometry(IGeometryPtr(ipEnvelope2));
hr = ipSpatialFilter->put_GeometryField(strFieldName);
hr = ipSpatialFilter->put_SpatialRel(esriSpatialRelEnvelopeIntersects);

DWORD dStart = GetTickCount();
hr = ipFeatureClass->Search(ipQueryFilter, VARIANT_FALSE, &ipFeatureCursor);

IFeaturePtr ipFeature;
long lCount = 0;
hr = ipFeatureCursor->NextFeature(&ipFeature);
while (hr == S_OK)
{
hr = ipFeatureCursor->NextFeature(&ipFeature);
lCount++;
}

DWORD dEnd = GetTickCount();
DWORD dValue = dEnd - dStart;
CString str;
str.Format("%ld,Countï¼?%ld", dValue, lCount);
AfxMessageBox(str);
0 Kudos
5 Replies
szcszc
by
Emerging Contributor
If the first Search is :
hr = ipFeatureClass->Search(NULL, VARIANT_FALSE, &ipFeatureCursor);

The finally time is about 50ms, Who knows the reason?
0 Kudos
szcszc
by
Emerging Contributor
Who explain the reason,  Vangelo?
0 Kudos
VinceAngelo
Esri Esteemed Contributor
No, I have little experience with ArcObjects, so I'm not a resource in this area.
You may want to try the ArcObjects forum or just contact Tech Support directly.

If you post, be sure to specify which version (and service pack) of ArcGIS and
ArcSDE you are using.

- V
0 Kudos
szcszc
by
Emerging Contributor
No, I have little experience with ArcObjects, so I'm not a resource in this area.
You may want to try the ArcObjects forum or just contact Tech Support directly.

If you post, be sure to specify which version (and service pack) of ArcGIS and
ArcSDE you are using.

- V


Thank you very much
0 Kudos
szcszc
by
Emerging Contributor
If the data isn't versioned, there is no proplem,but if the data is versioned, the low efficiency of cursor appears.

I use spatial Filter in Searching.

Does the version function affect the efficiency of Search?

And the A table, D table of this layer has only one record, I don't edit the data much.

Server:
   Oracle: 10.2.0.4
   ArcSDE:9.3
0 Kudos