laoxie_1983
路人甲
路人甲
  • 注册日期2006-04-20
  • 发帖数11
  • QQ
  • 铜币151枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1457回复:1

[求助]请朋友们帮我看看问题出在那

楼主#
更多 发布于:2008-08-08 20:37
<P> 大家可以帮我解决个问题吗?<BR>我是才开始学ARCGIS的。我在执行下面的语句的时候当执行到” Set pFeatureTarget.shape = ppolygon“是总是提示no support for this geometry type<BR>不知道是什么原因<BR>Private Sub OpenShapeFile(ByVal sFilePath As String, ByVal sFileName As String)<BR>    Dim pWorkspaceFactory       As IWorkspaceFactory<BR>    Dim pFeatureWorkspace       As IFeatureWorkspace<BR>    Dim pFeatureLayer           As IFeatureLayer<BR>    Dim pMxDocument             As IMxDocument<BR>    Dim pMap                    As IMap<BR>    Dim sDir                    As String<BR>    <BR>On Error GoTo ErrorHandler:<BR>    sDir = Dir(sFilePath ; "\" ; sFileName ; ".shp")<BR>    If (sDir = "") Then<BR>        sDir = Dir(sFilePath ; "\" ; sFileName)<BR>        If (sDir = "") Then<BR>            MsgBox ("文件不存在")<BR>            Exit Sub<BR>        End If<BR>End If<BR>  '  Set pFeatClass = pFeatureWorkspace.CreateFeatureClass _<BR>        (sFileName, pFields, Nothing, Nothing, _<BR>        esriFTSimple, sShapeFieldName, "")<BR>    'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR>    Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR>Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0)</P>
<P>    'Create a new FeatureLayer and assign a shapefile to it<BR>    Set pFeatureLayer = New FeatureLayer<BR>    Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(sFileName)<BR>pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName<BR>    'Add the FeatureLayer to the focus map<BR>    Set pMxDocument = Application.Document<BR>    Set pMap = pMxDocument.FocusMap<BR>    pMap.AddLayer pFeatureLayer '打开图层<BR>    Dim pFeatureClassTarget As IFeatureClass<BR>    Dim pFeatureTarget  As IFeature<BR>    Set pFeatureClassTarget = pFeatureLayer.FeatureClass<BR>    'Set pFeatureTarget.Value(FieldIndex) = "hh"<BR>    'Set pFeatureTarget.Value(2) = "hh"<BR>    Dim polygon As IPolygon<BR>    Dim pPointCollection As IPointCollection<BR>    Dim pPoint As IPoint<BR>    Dim pWorkspaceEdit  As IWorkspaceEdit<BR>    Set pWorkspaceEdit = pFeatureWorkspace<BR>   Dim ppolygon As polygon<BR>    'set pPolygon= new Polygon() as IPolygon<BR>    Set ppolygon = New polygon<BR>   ' set pPointCollection = pPolygon as  IPointCollecti<BR>   Set pPointCollection = ppolygon<BR>    'set pPoint = new Point()<BR>      Set pPoint = New Point<BR>     pPoint.PutCoords 100, 100<BR>   ' pPoint.set(x,y)'// 设置点坐标x,y<BR>    pPointCollection.AddPoint pPoint<BR>    <BR>   ' //第2个点<BR>    'set pPoint = new Point()<BR>   ' pPoint.set(x,y); // 设置点坐标x,y<BR>    pPoint.PutCoords 10, 10<BR>    pPointCollection.AddPoint pPoint<BR>    <BR>   ' //第3个点<BR>   ' set pPoint = new Point();<BR>   ' pPoint.set(x,y); // 设置点坐标x,y<BR>    pPoint.PutCoords 20, 20<BR>    pPointCollection.AddPoint pPoint<BR>    'Set polygon.Close = ture<BR>    <BR>   ' polygon.Close<BR>    <BR>     '//写入图形<BR>    <BR>         Set pFeatureLayer = pMap.Layer(0)<BR>   ' Set pFeatureClass = pFeatureLayer.FeatureClass<BR>    Set pFeatureTarget = pFeatureClassTarget.CreateFeature<BR>   'Set pFeatureTarget.Shape = pPolygon<BR>   ' pFeatureTarget.Geometry = polygon as IGeometry<BR>    'Set pFeatureTarget.Geometry = polygon<BR>   ' pFeatureTarget.Geometry = polygon<BR>   Set pFeatureTarget.shape = ppolygon<BR>     'pFeatureTarget.Geometry = ppolygon<BR>     'Set pFeatureTarget.shp = pPolygon<BR>   ' //保存要素<BR>    'pFeatureTarget.store()<BR>    'pFeatureTarget.Store = True<BR>    pFeatureTarget.Store<BR>    <BR>    <BR>    '//结束编辑<BR>     pWorkspaceEdit.StopEditOperation<BR>    pWorkspaceEdit.StopEditing True</P>
<P>   ' pWorkspaceEdit.StartEditOperation<BR>    'pWorkspaceEdit.opEditing (True)<BR>    'polygon.close()<BR>    <BR>    Exit Sub<BR>ErrorHandler:<BR>    MsgBox Err.Description<BR>End Sub</P>
<P><BR>Private Sub UIButtonControl1_Click()<BR>    Dim pVBProject              As VBProject<BR>On Error GoTo ErrorHandler:<BR>    Set pVBProject = ThisDocument.VBProject<BR>    OpenShapeFile "d:\dbf", "pl"<BR>    'Dim pWorkspaceEdit  As IWorkspaceEdit<BR>   ' pWorkspaceEdit.StartEditing (True)<BR>    'pWorkspaceEdit.StartEditOperation<BR>    <BR>    Exit Sub<BR>ErrorHandler:<BR>    MsgBox Err.Description<BR>End Sub</P>
喜欢0 评分0
laoxie_1983
路人甲
路人甲
  • 注册日期2006-04-20
  • 发帖数11
  • QQ
  • 铜币151枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2008-08-09 16:23
朋友们:帮我看看到底那出问题了啥
举报 回复(0) 喜欢(0)     评分
游客

返回顶部