http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> MapInfo >> 正文

MapX应用教程(7)—在MapX下紧缩表

作者:未知    文章来源:网络    点击数:    更新时间:2006-12-25
摘要:
七、在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 

Tags:MapX应用教程  
责任编辑:gissky
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图