chen22303
路人甲
路人甲
  • 注册日期2006-02-21
  • 发帖数17
  • QQ
  • 铜币156枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1835回复:2

AE帮助里的例子(创建featureClass)出错,应该怎么调试?(VB+AE)

楼主#
更多 发布于:2007-05-08 11:28
<P>老是提示自动化错误,错误图片为:</P>
<P> <IMG src="http://bbs.esrichina-bj.cn/ESRI/attachments/forumid_26/2_8ykyLkBsRTpn.jpg" border=0></P>

<P>已引用的库如下:</P>
<P> <IMG src="http://bbs.esrichina-bj.cn/ESRI/attachments/forumid_26/2_55hcgsIqcxPY.jpg" border=0></P>

<P>希望有高人出来指点一下,小弟感激不尽.谢谢</P>



<P>模块的代码</P>

<P>Public Sub CreateShapefile()</P>
<P>    Const strFolder As String = "d:\data"<BR>    Const strName As String = "MyShapeFile"    'Dont include .shp extension<BR>    Const strShapeFieldName As String = "Shape"<BR>    <BR>    ' Open the folder to contain the shapefile as a workspace<BR>    Dim pFWS As esriGeoDatabase.IFeatureWorkspace<BR>    Dim pWorkspaceFactory As esriGeoDatabase.IWorkspaceFactory<BR>    Set pWorkspaceFactory = New esriDataSourcesFile.ShapefileWorkspaceFactory<BR>    Set pFWS = pWorkspaceFactory.OpenFromFile(strFolder, 0)<BR>    <BR>    <BR>    ' Set up a simple fields collection<BR>    Dim pFields As IFields<BR>    Dim pFieldsEdit As IFieldsEdit<BR>    Set pFields = New esriGeoDatabase.Fields<BR>    Set pFieldsEdit = pFields<BR>    Dim pField As IField<BR>    Dim pFieldEdit As IFieldEdit<BR>    <BR>    <BR>    ' Make the shape field<BR>    ' it will need a geometry definition, with a spatial reference<BR>    Set pField = New esriGeoDatabase.Field<BR>    Set pFieldEdit = pField<BR>    pFieldEdit.Name = strShapeFieldName<BR>    pFieldEdit.Type = esriFieldTypeGeometry<BR>        <BR>    Dim pGeomDef As IGeometryDef<BR>    Dim pGeomDefEdit As IGeometryDefEdit<BR>    Set pGeomDef = New GeometryDef<BR>    Set pGeomDefEdit = pGeomDef<BR>    With pGeomDefEdit<BR>        .GeometryType = esriGeometryType.esriGeometryPolygon<BR>        Set .SpatialReference = New UnknownCoordinateSystem<BR>    End With<BR>    Set pFieldEdit.GeometryDef = pGeomDef<BR>    pFieldsEdit.AddField pField<BR>    <BR>     ' Add another miscellaneous text fieGld<BR>    Set pField = New esriGeoDatabase.Field<BR>    Set pFieldEdit = pField<BR>    With pFieldEdit<BR>       .Length = 30<BR>       .Name = "MiscText"<BR>       .Type = esriFieldTypeString<BR>    End With<BR>    pFieldsEdit.AddField pField</P>
<P>    ' Create the shapefile<BR>    ' (some parameters apply to geodatabase options and can be defaulted as Nothing)<BR>    Dim pFeatClass As IFeatureClass<BR>    Set pFeatClass = pFWS.CreateFeatureClass(strName, pFields, Nothing, Nothing, esriFTSimple, strShapeFieldName, "")<BR>    <BR>End Sub</P>
<P>窗体代码:</P>
<P><BR>Private Sub Command1_Click()<BR>    Call CreateShapefile<BR>End Sub</P>
喜欢0 评分0
dougui
路人甲
路人甲
  • 注册日期2006-02-11
  • 发帖数4
  • QQ
  • 铜币136枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-07-30 15:46
<P>Set pFWS = pWorkspaceFactory.OpenFromFile(strFolder, 0)<BR>估计这句话就出错了!!</P>
<P>我也碰到了同样的问题,不知道怎么解决阿!!</P>
举报 回复(0) 喜欢(0)     评分
zhonghua
路人甲
路人甲
  • 注册日期2005-04-01
  • 发帖数94
  • QQ
  • 铜币466枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-08-01 16:47
<P>问题应该在这里:With pGeomDefEdit<BR>        .GeometryType = esriGeometryType.esriGeometryPolygon<BR>        Set .SpatialReference = New UnknownCoordinateSystem</P>
<P>你这样试一下(c#):</P>
<P>ISpatialReferenceFactory2 pSRF2;<BR>            ISpatialReference pSR;<BR>            IGeographicCoordinateSystem pGCS = pSRF2.CreateGeographicCoordinateSystem(6362);//esriSRDatum_WGS1984<BR>            pSR = (ISpatialReference)pGCS;</P>
<P>IGeometryDefEdit pGeoDefEdit;<BR>            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;<BR>            pGeoDefEdit.SpatialReference_2 = pSR;</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部