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, "点")
初学者请教为什么我的点图层生成却不显示?

你只是把点读到一个点的数组里了,根本就没保存到你创建的shapefile中

在endwhile后边加一段:
for(int i =0;i<pPointCol.Count;i++)
{
pFeaClass1.CreateFeature(newFeature);
newFeature._Set_Shape(pPointCol[i]);
rowSubtypes := newFeature as IRowSubtypes;
rowSubtypes.Set_SubtypeCode(1);
rowSubtypes.InitDefaultValues;
newFeature.Store;
}
这段代码不伦不类的 你转一下追问

我现在加了下面的代码:
Dim newFeature As IFeature = pFeatureClass1.CreateFeature
newFeature.Store()
可是还是不显示,但这次属性表里有了信息?

追答

1 你的shp新建的时候没有设置SpatialReference
2 你只新建了一个空要素 要把你读取的Point赋给这个Feature

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-04-20
有一种常用的数据库。
语言可以是vc6.0、vb6.0,也可以是.net框架下的任何一种。最好熟悉ASP.NET。
数据库的话要能掌握access,还有大型的关系数据库Oracle、SQLServer。
专业软件的话,用得最多的是ESRI公司的ArcGIS,包括arcinfo、arcims、arcgisserver、arcsde等。
国产的有mapgis等!追问

这跟我这个错误有何关系?请帮我解决这个问题吧,很急的!谢谢!

第2个回答  2011-04-20
Me.Refresh()一下看看追问

不行啊!这个代码本身有什么问题没有,麻烦你帮我看看!谢谢!

相似回答