栀竹
路人甲
路人甲
  • 注册日期2006-04-27
  • 发帖数40
  • QQ
  • 铜币334枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1668回复:3

在线等-急-创建polygon的问题

楼主#
更多 发布于:2007-01-09 10:46
<P>在engine开发中</P>
<P>创建了10 个polygon</P>
<P>FID=0的一行没有对象,FID=1到10 是我创建的对象</P>
<P>高手请教:如何使FID=0 到9是我创建的对象</P>
<P>谢谢!!!</P>
喜欢0 评分0
栀竹
路人甲
路人甲
  • 注册日期2006-04-27
  • 发帖数40
  • QQ
  • 铜币334枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-01-09 11:17
<P>    代码如下:</P>
<P>Public Function CreateEpiShpfile(ByVal outputPath As String, ByVal shapeName As String) As String<BR>        Dim s As String<BR>        s = "CreateIsoseisShpfile:OK"<BR>        Dim strPath As String<BR>        Dim strName As String<BR>        strPath = outputPath<BR>        strName = shapeName<BR>        Dim shapeFileName As String<BR>        shapeFileName = "shape"<BR>        '=========================创建shape空文件=======================<BR>        Dim pFWS As IFeatureWorkspace<BR>        Dim pWorkspaceFactory As IWorkspaceFactory<BR>        pWorkspaceFactory = New ShapefileWorkspaceFactory<BR>        pFWS = pWorkspaceFactory.OpenFromFile(strPath, 0)</P>
<P>        Dim pFields As IFields<BR>        Dim pFieldsEdit As IFieldsEdit<BR>        pFields = New Fields<BR>        pFieldsEdit = pFields</P>
<P>        Dim pfield As IField<BR>        Dim pfieldedit As IFieldEdit<BR>        pfield = New Field<BR>        pfieldedit = pfield</P>
<P>        pfieldedit.Name_2 = shapeFileName<BR>        pfieldedit.Type_2 = esriFieldType.esriFieldTypeGeometry</P>
<P>        Dim pGeomDef As IGeometryDef<BR>        Dim pGeomDefedit As IGeometryDefEdit<BR>        pGeomDef = New GeometryDef<BR>        pGeomDefedit = pGeomDef<BR>        pGeomDefedit.GeometryType_2 = esriGeometryType.esriGeometryPoint<BR>        Dim spaRefFact As ISpatialReferenceFactory2<BR>        spaRefFact = New SpatialReferenceEnvironment<BR>        Dim geoCoordSys As IGeographicCoordinateSystem<BR>        geoCoordSys = spaRefFact.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984)<BR>        Dim sRef As ISpatialReference<BR>        sRef = geoCoordSys</P>
<P>        pGeomDefedit.SpatialReference_2 = sRef</P>
<P>        pfieldedit.GeometryDef_2 = pGeomDef<BR>        pFieldsEdit.AddField(pfield)</P>
<P>        pfield = New Field<BR>        pfieldedit = pfield<BR>        pfieldedit.Name_2 = "ID"<BR>        pfieldedit.Length_2 = 16<BR>        pfieldedit.Type_2 = esriFieldType.esriFieldTypeDouble<BR>        pFieldsEdit.AddField(pfield)</P>
<P>        pfield = New Field<BR>        pfieldedit = pfield<BR>        pfieldedit.Name_2 = "Date"<BR>        pfieldedit.Length_2 = 30<BR>        pfieldedit.Type_2 = esriFieldType.esriFieldTypeDate<BR>        pFieldsEdit.AddField(pfield)</P>
<P>        Dim pFeatClass As IFeatureClass<BR>        Dim pclsid As UID<BR>        pclsid = New UID<BR>        pclsid.Value = "esriGeoDatabase.Feature"<BR>        pFeatClass = pFWS.CreateFeatureClass(strName, pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, shapeFileName, "")<BR>        '=================================end================================</P>
<P>        '===========================创建点================================<BR>        Dim point As IPoint<BR>        point = New Point</P>
<P>        point.PutCoords(x, y)<BR>        Dim ipFC As IFeatureCursor<BR>        Dim ipFB As IFeatureBuffer<BR>        Dim ipFieldsNew As IFields<BR>        Dim u As Integer<BR>        ipFC = pFeatClass.Insert(True)<BR>        ipFB = pFeatClass.CreateFeatureBuffer<BR>        ipFieldsNew = pFeatClass.Fields</P>
<P>        Dim indid As Integer<BR>        indid = ipFieldsNew.FindField("ID")<BR>        Dim indrq As Integer<BR>        indrq = ipFieldsNew.FindField("Date")<BR>        Dim indsj As Integer</P>
<P>        Dim ipFeat As IFeature<BR>        ipFeat = pFeatClass.CreateFeature<BR>        Dim inshp As Integer<BR>        inshp = ipFieldsNew.FindField("shape")</P>
<P>        Dim ipGeom As IGeometry</P>
<P>        ipGeom = point<BR>        ipFB.Value(inshp) = ipGeom<BR>        ipFB.Value(indid) = ID<BR>        ipFB.Value(indrq) = Now.Date<BR>        ipFB.Value(indsj) = Now.Hour.ToString + ":" + Now.Minute.ToString + ":" + Now.Second.ToString<BR>        Dim ret As Object<BR>        ret = ipFC.InsertFeature(ipFB)<BR>        ipFC.Flush()<BR>        '=============================end===================================<BR>        Return s<BR>    End Function</P>
举报 回复(0) 喜欢(0)     评分
栀竹
路人甲
路人甲
  • 注册日期2006-04-27
  • 发帖数40
  • QQ
  • 铜币334枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-01-09 11:57
<P>哈哈,刚刚自己探索一下,已经得到解决拉</P>
<P>这里用的是 IFeatureCursor和IFeatureBuffer</P>
<P>改成IFeature.creatfeature就可以啦<BR></P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2007-01-09 13:58
CreateFeatureBuffer可以让你创建大数据量的shapefile的速度增快很多的
举报 回复(0) 喜欢(0)     评分
游客

返回顶部