hpcc
路人甲
路人甲
  • 注册日期2006-08-01
  • 发帖数34
  • QQ
  • 铜币278枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2061回复:3

[求助]怎样对shp进行编辑??

楼主#
更多 发布于:2007-03-14 15:05
<P>我想对shp文件进行添加、删除等操作</P>
<P>在mo里我知道是一个只读的属性recordset.Updatable来控制的</P>
<P>但这个属性怎么老是false啊???急死我了</P>
<P>望各位大虾指点。。</P>
喜欢0 评分0
lhfde
路人甲
路人甲
  • 注册日期2006-05-23
  • 发帖数51
  • QQ
  • 铜币243枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-03-22 23:36
<P>      其实就和对记录进行修改一样,vb应该差不错。</P>
<P>       IMoRecordsetPtr  a_Select ;</P>
<P>        a_Select->Edit();<BR>         a_Select->Fields->Item(TVariant("Name"))->set_Value((TVariant)"1");<BR>         a_Select->_Update();<BR>         a_Select->StopEditing();</P>
举报 回复(0) 喜欢(0)     评分
huqingfengxy
路人甲
路人甲
  • 注册日期2007-01-20
  • 发帖数14
  • QQ
  • 铜币137枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-03-31 14:03
<P>添加点你可以用下面的代码:</P>
<P>Option Explicit</P>
<P>Private Sub DrawLayer()<BR>  Dim Layer As MapLayer<BR>  Dim dc As New DataConnection<BR>   <BR>  On Error GoTo Err1<BR>  dc.Database = App.Path + "\..\" + "Mexico"<BR>  Set Layer = New MapLayer<BR>  Set Layer.GeoDataset = dc.FindGeoDataset("states")<BR>  Layer.Symbol.Color = moLimeGreen<BR>  Map1.Layers.Add Layer<BR>  <BR>  Set Layer = New MapLayer<BR>  Set Layer.GeoDataset = dc.FindGeoDataset("CITIES1")<BR>  Layer.Symbol.Color = moRed<BR>  Map1.Layers.Add Layer<BR>  Exit Sub<BR>  <BR>Err1:<BR>  If dc.ConnectError = 0 Then<BR>    MsgBox "没找到图层", vbInformation, "MO示例"<BR>  Else<BR>    MsgBox ConnectErrorMsg(dc.ConnectError), vbInformation, "MO示例"<BR>  End If<BR>  End<BR>End Sub</P>
<P>Private Sub Form_Load()<BR>  DrawLayer   '加载墨西哥地图的States和Cities1图层;<BR>End Sub</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<BR>  Dim P1 As MapObjects2.Point<BR>  Dim Ans As Variant<BR>  Dim Recs As MapObjects2.Recordset<BR>  Dim Layer As MapObjects2.MapLayer<BR>  <BR>  Set Layer = Map1.Layers("CITIES1")<BR>  Set Recs = Layer.Records<BR>  Set P1 = Map1.ToMapPoint(X, Y)<BR>  <BR>  Ans = MsgBox("要添加这个特征?", vbYesNo, "MO示例")<BR>  If Ans = vbYes Then<BR>    If Recs.Updatable Then<BR>      With Layer.Records<BR>        .AddNew<BR>        .Fields("Shape").Value = P1    '添加特征;<BR>        .Fields("Name").Value = "新城市"<BR>        .Fields("CITIES_").Value = "1"<BR>        .Update<BR>        .StopEditing<BR>      End With<BR>      Map1.Refresh<BR>    Else<BR>      MsgBox "图层文件不能编辑"<BR>    End If<BR>  End If<BR>End Sub<BR></P>
举报 回复(0) 喜欢(0)     评分
huqingfengxy
路人甲
路人甲
  • 注册日期2007-01-20
  • 发帖数14
  • QQ
  • 铜币137枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-03-31 14:04
<P>其他的可以加我QQ309116862</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部