24小时热门版块排行榜    

查看: 1022  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

zzahkj

木虫 (著名写手)

[求助] Vb.net+ArcEngine生成的点状图层不显示?

我刚刚接触这个,望高手给个详细解答,谢谢!我的代码如下,为什么我生成的点状图层不显示呢?
Dim pShpWksFact As IWorkspaceFactory = New ShapefileWorkspaceFactory()
            Dim pFeatWks As IFeatureWorkspace
            pFeatWks = CType(pShpWksFact.OpenFromFile(filePath, 0), IFeatureWorkspace)
            Const strShapeFieldName As String = "Shape"
            Dim pFields1 As IFields
            Dim pFieldsEdit1 As IFieldsEdit
            pFields1 = New FieldsClass()
            pFieldsEdit1 = CType(pFields1, IFieldsEdit)
            Dim pField1 As IField = New FieldClass()
            Dim pFieldEdit1 As IFieldEdit = New FieldClass()
            pFieldEdit1.Name_2 = strShapeFieldName
            pFieldEdit1.Type_2 = esriFieldType.esriFieldTypeGeometry
            pField1 = CType(pFieldEdit1, IField)
            Dim pGeomDef1 As IGeometryDef = New GeometryDefClass()
            Dim pGeomDefEdit1 As IGeometryDefEdit = New GeometryDefClass()
            pGeomDefEdit1 = CType(pGeomDef1, IGeometryDefEdit)
            pGeomDefEdit1.GeometryType_2 = esriGeometryType.esriGeometryPoint
            pGeomDefEdit1.SpatialReference_2 = Main.AxMapControl1.Map.SpatialReference
            pFieldEdit1.GeometryDef_2 = pGeomDef1
            pFieldsEdit1.AddField(pField1)
            pFields1 = CType(pFieldsEdit1, IFields)
            Dim pFeatureClass1 As IFeatureClass
            pFeatureClass1 = pFeatWks.CreateFeatureClass("点", pFields1, Nothing, Nothing, esriFeatureType.esriFTSimple, strShapeFieldName, "" )
            Dim pPointCol As IPointCollection = New MultipointClass()

            Dim sr As StreamReader = New StreamReader(My.Computer.FileSystem.CurrentDirectory & "\shu\dianceng.txt" )

            Dim str As String = sr.ReadLine()
            Dim own As Long = 0
            While str IsNot Nothing
                Dim strs() As String = Regex.Split(str, "        " )
                Dim x As Double = Convert.ToDouble(strs(0))
                Dim y As Double = Convert.ToDouble(strs(1))
                 Dim pPoint As IPoint = New PointClass()
                pPoint.X = x
                pPoint.Y = y
                Dim missing As Object = Type.Missing
                pPointCol.AddPoint(pPoint, missing, missing)
                str = sr.ReadLine()
            End While
Main.AxMapControl1.AddShapeFile(filePath, "点" )

[ Last edited by zzahkj on 2011-4-19 at 23:29 ]
回复此楼
不要迷恋哥,哥只是一个过客!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zzahkj

木虫 (著名写手)

引用回帖:
Originally posted by xiangling1 at 2011-04-21 18:59:13:
应该是后面的程序问题,你生成的点集没有添加到图层当中!
Dim pPointCol As IPointCollection = New MultipointClass()
......
pPointCol.AddPoint(pPoint, missing, missing);
后面应该加东西

我后面加了些代码,你看为什么出现未将对象引用设置到对象的实例的错误!
Dim i As Integer = 0

                If i < pPointCol.PointCount Then
                    Dim newFeature As IFeature = pFeatureClass1.CreateFeature
                    newFeature._Set_Shape.pPointCol(i)
                    Dim rowSubtypes As IRowSubtypes = newFeature
                    rowSubtypes.Set_SubtypeCode(1)
                    rowSubtypes.InitDefaultValues()
                    newFeature.Store()

                End If
                i = i + 1
            End While
这段代码是我根据一段C#代码改的,我也不知道有什么问题?
不要迷恋哥,哥只是一个过客!
7楼2011-04-22 08:58:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

zzahkj

木虫 (著名写手)

太不给力了,没人理!
不要迷恋哥,哥只是一个过客!
2楼2011-04-21 09:52:01
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiangling1

金虫 (正式写手)

【答案】应助回帖

zzahkj(金币+1): 2011-04-28 14:02:48
应该是后面的程序问题,你生成的点集没有添加到图层当中!
Dim pPointCol As IPointCollection = New MultipointClass()
......
pPointCol.AddPoint(pPoint, missing, missing);
后面应该加东西
黄沙百战穿金甲,不破楼兰终不还!
3楼2011-04-21 18:59:13
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yanggis

木虫 (著名写手)

小木虫GIS家族族长

【答案】应助回帖

如果你仅仅就这一个数据集,那就到ArcMap中直接生成显示就可以了。没必要写程序。如果有很多数据集》100个。可以自己先学一下再做。没有调试环境,没法给你说哪里错了。
4楼2011-04-21 19:49:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见