单值主题图不能应用于直接打开的本地TAB文件

注:此问题出现在MapXtreme 2004 6.2 中,经测试发现MapXtreme 2008 已修正此问题

 

下面的代码执行后并不能实现对“评价井”样式的修改:

 

// 打开 TAB 文件

Table t = MapInfo.Engine.Session.Current.Catalog.OpenTable(Application.StartupPath + @"/井.TAB");
FeatureLayer fl = new FeatureLayer(t);
mapControl1.Map.Layers.Add(fl);

 

// 创建单值主题

IndividualValueTheme ivt = new IndividualValueTheme(fl, "WELLTYPE", null); 
      
for(int i = 0; i < ivt.Bins.Count; i ++)
{
   if(ivt.Bins[i].Value.ToString() == "评价井")
   {

      // 对评价井进行修改样式
      MapInfo.Styles.Font f = new MapInfo.Styles.Font("MapInfo Oil&Gas", 12);
      short jingCode = 37;
      FontPointStyle fps = new FontPointStyle(jingCode, f, 0, Color.Red, 12);
      ivt.Bins[i].Style = new CompositeStyle(fps);
   }
}

 

fl.Modifiers.Clear();
fl.Modifiers.Insert(0, ivt);

 

但这段代码在 MapXtreme 2008 下却可以正确的完成修改样式的功能。若想不升级 MapXtreme 而达到预期的效果,我们需要创建中间表,如下所示:

 

MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchAll();
si.QueryDefinition.Columns = null;
IResultSetFeatureCollection rsfc = MapInfo.Engine.Session.Current.Catalog.Search("NOD10001", si);   

 

// 创建一个“井.TAB” 的复本
TableInfo ti = TableInfoFactory.CreateFromFeatureCollection("tempNod10001", TableType.MemTable, rsfc);
Table tempTable = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);      
tempTable.InsertFeatures(rsfc);


tempLayer = new FeatureLayer(tempTable);
mapControl1.Map.Layers.Add(tempLayer);

 

// 对临时的复本图层应用主题

IndividualValueTheme ivt = new IndividualValueTheme(fl, "WELLTYPE", null); 
      
for(int i = 0; i < ivt.Bins.Count; i ++)
{
   if(ivt.Bins[i].Value.ToString() == "评价井")
   {

      // 对评价井进行修改样式
      MapInfo.Styles.Font f = new MapInfo.Styles.Font("MapInfo Oil&Gas", 12);
      short jingCode = 37;
      FontPointStyle fps = new FontPointStyle(jingCode, f, 0, Color.Red, 12);
      ivt.Bins[i].Style = new CompositeStyle(fps);
   }
}

 

tempLayer.Modifiers.Clear();
tempLayer.Modifiers.Insert(0, ivt);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值