IT人
相关图书

关于调用IFeatureClass进行Insert失败问题

所属分类:企业开发 地理信息系统
-----------------------------------------


程序简要代码如下:

esriGeoDatabase::IFeatureWorkspacePtr spFeaWs = spWorkspace;
esriGeoDatabase::IWorkspaceEditPtr spWsEdit = spFeaWs;


spWsEdit->StartEditing(VARIANT_TRUE);
spWsEdit->StartEditOperation();

esriGeoDatabase::IFeatureClassPtr spFeatureClass;
spFeaWs->raw_OpenFeatureClass(sDestTbName.AllocSysString(),&spFeatureClass);

esriGeoDatabase::IFeatureBufferPtr spFeatureBuf;
esriGeoDatabase::IFeatureCursorPtr spFeacureCursor;

spFeacureCursor = spFeatureClass->Insert(VARIANT_TRUE);
if (spFeacureCursor == NULL) 
{
return FALSE;
}

执行insert时,总是出现错误 “无效的参数量”

请高手给予回答啊,急啊

----------------------------------------------------------------------

帮助中有这么一个例子,你可以看一下

[C#] 
    public void IFeatureClass__Insert(IFeatureClass featureClass)
    {
        //get the Workspace from the IDataset interface on the feature class
        IDataset dataset = (IDataset)featureClass;
        IWorkspace workspace = dataset.Workspace;
        
        //Cast for an IWorkspaceEdit
        IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

        //Start an edit session and operation
        workspaceEdit.StartEditing(true);
        workspaceEdit.StartEditOperation();

        //Create the Feature Buffer
        IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
        //Create insert Feature Cursor using buffering = true.
        IFeatureCursor featureCursor = featureClass.Insert(true);

        object featureOID;

        //With a feature buffer you have the ability to set the attribute for a specific field to be
        //the same for all features added to the buffer.
        featureBuffer.set_Value(featureBuffer.Fields.FindField("InstalledBy"), "K Johnston");
        
        //Here you can set the featurebuffers's shape by setting the featureBuffer.Shape 
        //to a geomerty that matched the featureclasses.

        //Insert the feature into the feature cursor
        featureOID = featureCursor.InsertFeature(featureBuffer);

        //Calling flush allows you to handle any errors at a known time rather then on the cursor destruction.
        featureCursor.Flush();

        //Stop editing
        workspaceEdit.StopEditOperation();
        workspaceEdit.StopEditing(true);

        //Release the Cursor
        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
    }



--------------------------------------------------------

该问题已经解决
相关问题
    Copyright ◎ 1998 - 2007 编程资料网 All Rights Reserved