3S基础知识:MapX应用教程—在MapX下紧缩表

  在MapX下紧缩表

  在Professional里面,紧缩表用 Pack Table 语句完成。而在MapX中则需要使用临时图层,并用复制技术来完成。

示例: ‘紧缩当前Map对象中的所有图层

  Dim LayerInfo As New MapXLib.LayerInfo

  Dim Lyr As MapXLib.Layer

  Dim LyrTemp As MapXLib.Layer

  Dim Flds As MapXLib.Fields

  Dim Ds As MapXLib.Dataset


  Dim I As Integer

  Dim LayerName, FilePath As String


  On Error Resume Next


  For I = MainMap.Layers.Count To 1 Step -1

  ´复制源表数据到临时表

  Set Lyr = MainMap.Layers.Item(I)

  Set Ds = Lyr.Datasets.Item(1)

  Set Flds = Ds.Fields


  LayerName = Lyr.Name

  LayerInfo.Type = miLayerInfoTypeTemp

  LayerInfo.AddParameter "FileSpec", LayerName

  LayerInfo.AddParameter "NAME", LayerName

  LayerInfo.AddParameter "Features", Lyr.AllFeatures‘复制所有有效图元

  LayerInfo.AddParameter "Fields", Flds ’复制字段列表


  LayerInfo.AddParameter "AutoCreateDataset", 1

  LayerInfo.AddParameter "datasetname", LayerName

  Set LyrTemp = MapTemp.Layers.Add(LayerInfo, 1) ‘复制到另外Map对象


  ´删除源表

  Set Lyr = Nothing

  FilePath = MainMap.Layers.Item(I).Filespec

  LayerName = Mid(FilePath, InStr(1, FilePath, "Maps") + 6, Len(FilePath)

  - InStr(1, FilePath, "Maps"))

  FilePath = Mid(FilePath, 1, InStr(1, FilePath, "Maps") + 5)

  LayerName = Mid(LayerName, 1, Len(LayerName) - 4)


  MainMap.Layers.Remove (I)

  MainMap.Refresh


  Kill FilePath + LayerName + ".TAB"


  ´复制临时表数据到源表

  Set LyrTemp = MapTemp.Layers.Item(LayerName)


  LayerInfo.Type = miLayerInfoTypeNewTable

  LayerInfo.AddParameter "FileSpec", FilePath + LayerName + ".TAB"

  LayerInfo.AddParameter "NAME", LayerName

  LayerInfo.AddParameter "Features", LyrTemp.AllFeatures

  LayerInfo.AddParameter "Fields", Flds


  LayerInfo.AddParameter "AutoCreateDataset", 1

  LayerInfo.AddParameter "datasetname", LayerName

  Set Lyr = MainMap.Layers.Add(LayerInfo, 1)


  ´删除临时表

  MapTemp.Layers.Remove (MapTemp.Layers.Count)

  MapTemp.Refresh

  Next


  Set Lyr = Nothing

  Set Ds = Nothing

  Set Flds = Nothing

  Set LayerInfo = Nothing

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值