sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2036回复:9

怎样编辑图形元素的数据库字段\命名等

楼主#
更多 发布于:2004-07-11 00:42
我想通过VB+MO对当前的图层的数据库进行属性编辑,不知道代码怎样下手,怎样写代码,请斑竹老大赐教!!
喜欢0 评分0
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2004-07-11 00:43
比如,田加字段,删除字段,修改字段名以及类型,长度等
举报 回复(0) 喜欢(0)     评分
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-07-11 00:45
<P>我现在很急,要完成一个作业,不知道怎样下手.</P><P>请高手帮忙指点.</P><P>还有图形数据库与属性数据库的连接问题怎样解决?</P>
举报 回复(0) 喜欢(0)     评分
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2004-07-11 00:46
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
举报 回复(0) 喜欢(0)     评分
gisboy
卧底
卧底
  • 注册日期2003-07-26
  • 发帖数162
  • QQ
  • 铜币900枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2004-07-11 13:32
<P>addnew方法,具体mo有帮助。</P><P>This example uses the AddGeoDataset method and the TableDesc properties to create a new shapefile that represents a GeoDataset with polygon features in a DataConnection. In addition, the code associates the GeoDataset with a MapLayer, adding it to the Map. The TableDesc properties define three additional fields in the Recordset. For each feature added, the code invokes the AddNew and Update methods to populate the fields of the Recordset. To try this example, paste the code into the Declarations section of a form containing a CommonDialog control named CommonDialog1, a CommandButton named Command1 and Map named Map1 that contains a MapLayer or an ImageLayer. This layer will serve as a background layer, providing the coordinates and map units of the new MapLayer. Click F5, and track polygons by clicking on the map, a double-click signals the end of a polygon. When you've added the polygons you want, click the Save button to specify the name of the shapefile. </P><P>Option Explicit
Dim moSymbol As New MapObjects2.Symbol
Dim moPolygons As New Collection</P><P>Private Sub Command1_Click()</P><P>  Dim gds As MapObjects2.GeoDataset
  Dim sName As String
  Dim desc As New TableDesc
  Dim dc As New DataConnection
  Dim lyr As New MapObjects2.MapLayer
  Dim lPoly As Long</P><P>  With CommonDialog1
    .Filter = "ESRI Shapefiles (*.shp)|*.shp"
    .DefaultExt = ".shp"
    .ShowSave</P><P>    If Len(.FileName) = 0 Then Exit Sub  ' cancel
    dc.Database = CurDir</P><P>    
    If Not dc.Connect Then Exit Sub   ' bad dataConnection
    ' remove the extension
    sName = Left(.FileTitle, Len(.FileTitle) - 4)
  End With</P><P>  With desc
    ' define three additional fields
    .FieldCount = 3</P><P>    'set the field names
    .FieldName(0) = "Name"
    .FieldName(1) = "Area"
    .FieldName(2) = "Perimeter"</P><P>    ' set the type of field
    .FieldType(0) = moString
    .FieldType(1) = moDouble
    .FieldType(2) = moDouble</P><P>    ' set the length of a character field</P><P>    .FieldLength(0) = 16</P><P>    ' set the number of digits used in the field
    .FieldPrecision(1) = 15
    .FieldPrecision(2) = 15</P><P>    ' set the number of digits to the right of the decimal point
    .FieldScale(1) = 3
    .FieldScale(2) = 3
  End With</P><P>  Set gds = dc.AddGeoDataset(sName, moPolygon, desc)
  If gds Is Nothing Then Exit Sub   ' invalid file</P><P>  Set lyr.GeoDataset = gds
  Map1.Layers.Add lyr
  Map1.Refresh</P><P>  For lPoly = 1 To moPolygons.Count</P><P>    With lyr.Records
      .AddNew
      .Fields("Shape").Value = moPolygons(lPoly)
      .Fields("Name").Value = "Name " ; lPoly
      .Fields("Area").Value = moPolygons(lPoly).Area
      .Fields("Perimeter").Value = moPolygons(lPoly).Perimeter
      .Update
    End With
  Next
  lyr.Records.StopEditing
End Sub</P><P>Private Sub Form_Load()
  With moSymbol
    .SymbolType = moFillSymbol
    .Style = moSolidFill
    .Color = moPaleYellow
  End With
  Command1.Caption = "Save"</P><P>End Sub</P><P>Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Stdole.OLE_HANDLE)
  Dim oPoly As MapObjects2.Polygon
  
  If moPolygons.Count <> 0 Then
    For Each oPoly In moPolygons
      Map1.DrawShape oPoly, moSymbol
    Next
  End If</P><P>End Sub</P><P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  
  Dim oRect As MapObjects2.Rectangle
  Dim oPoly As New MapObjects2.Polygon
  
  If Button = 1 Then
    Set oPoly = Map1.TrackPolygon</P><P>    moPolygons.Add oPoly
    Map1.TrackingLayer.Refresh True
  Else
    Set oRect = Map1.Extent
    oRect.ScaleRectangle 0.5
    Map1.Extent = oRect
  End If
  
End Sub</P>
Our doing are not really as important as we think. Our successes and failures didn't matter after all.
举报 回复(0) 喜欢(0)     评分
ypyan
路人甲
路人甲
  • 注册日期2004-06-28
  • 发帖数7
  • QQ
  • 铜币132枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2004-07-13 08:26
<P>老大。这程序是生成shapefile的初始表结构定义。问你怎么添加、删除、修改表结构。</P><P>另外我也有问题。</P><P>我用mo+vb编程,msflexgrid显示属性表,发现在arcview中给shapefile加的字段显示在最前面几列,往后依次是featureID,id,shape等老字段。 我程序如下。  
i = 1
For Each aField In recs.Fields
      strtemp = aField.Name
      MSFlexGrid1.Row = 0
      MSFlexGrid1.Col = i
      MSFlexGrid1.Text = strtemp
      i = i + 1
Next</P><P>i = 1
While Not recs.EOF
  j = 0
  For Each aField In recs.Fields
    MSFlexGrid1.Row = i
    MSFlexGrid1.Col = j
    MSFlexGrid1.Text = aField.ValueAsString
    j = j + 1
  Next
  i = i + 1
  recs.MoveNext
Wend
另外如何给属性表添加新字段。
to各位为什么mo编程中显示的属性表把新编辑的字段放在第一个</P>
举报 回复(0) 喜欢(0)     评分
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2004-07-14 01:24
谢谢 <TABLE cellPadding=4 cellSpacing=0 width="100%"><TR><TD glow(color=#9898BA,strength=2)" vAlign=center width=*><P>  <FONT color=#990000><B>gisboy</B></FONT> 。我也有<FONT color=#000066><B>ypyan的</B></FONT> 同感,希望高手指点!!!</P></TD></TR></TABLE><img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em05.gif" />
举报 回复(0) 喜欢(0)     评分
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2004-07-14 01:26
<P>我的信箱:<a href="mailtlizheng_read@hotmail.com" target="_blank" >lizheng_read@hotmail.com</A></P><P>我是新手,请多多指教,</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
8楼#
发布于:2004-07-14 09:24
<P>看看这个有用吗 </P><P><a href="http://www.gisempire.com/bbs/dispbbs.asp?BoardID=39;ID=5306" target="_blank" >http://www.gisempire.com/bbs/dispbbs.asp?BoardID=39;ID=5306</A></P>
举报 回复(0) 喜欢(0)     评分
sirc_lizheng
伴读书童
伴读书童
  • 注册日期2004-07-09
  • 发帖数148
  • QQ
  • 铜币495枚
  • 威望0点
  • 贡献值0点
  • 银元0个
9楼#
发布于:2004-07-14 19:15
谢谢!!
举报 回复(0) 喜欢(0)     评分
游客

返回顶部