How to combine the features in the DefaultSelection
来源:互联网 发布:怎么操作淘宝千人千面 编辑:程序博客网 时间:2024/05/16 15:26
C# Code:
//This is the table with the features that will be combined
MapInfo.Mapping.FeatureLayer fl = this.MapControl1.Map.Layers["USA"] as MapInfo.Mapping.FeatureLayer;
//This created a temp table that has the same table structure as the table above
//This is where the new big combined feature will be stored
MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable("Combined_Features");
foreach(MapInfo.Data.Column col in fl.Table.TableInfo.Columns)
{
ti.Columns.Add(col.Clone());
}
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
MapInfo.FeatureProcessing.FeatureProcessor featureProcessor = new MapInfo.FeatureProcessing.FeatureProcessor();
MapInfo.Data.Feature f = null;
foreach(MapInfo.Data.IResultSetFeatureCollection irfc in MapInfo.Engine.Session.Current.Selections.DefaultSelection)
{
//Only want to combine features in the USA layer
if(irfc.BaseTable.Alias == fl.Table.Alias)
{
f = featureProcessor.Combine(irfc);
}
}
//Adds the feature to the temp table
table.InsertFeature(f);
//Creates a new featurelayer for the table and adds it to the map
MapInfo.Mapping.FeatureLayer fl2 = new MapInfo.Mapping.FeatureLayer(table);
this.MapControl1.Map.Layers.Add(fl2);
Dim fl As MapInfo.Mapping.FeatureLayer = Me.MapControl1.Map.Layers("USA")
'This created a temp table that has the same table structure as the table above
'This is where the new big combined feature will be stored
Dim ti As MapInfo.Data.TableInfoMemTable = New MapInfo.Data.TableInfoMemTable("Combined_Features")
For Each col As MapInfo.Data.Column In fl.Table.TableInfo.Columns
ti.Columns.Add(col.Clone())
Next
Dim table As MapInfo.Data.Table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti)
Dim featureProcessor As MapInfo.FeatureProcessing.FeatureProcessor = New MapInfo.FeatureProcessing.FeatureProcessor
Dim f As MapInfo.Data.Feature = Nothing
Dim irfc As MapInfo.Data.IResultSetFeatureCollection
For Each irfc In MapInfo.Engine.Session.Current.Selections.DefaultSelection
'Only want to combine features in the USA layer
If irfc.BaseTable.Alias = fl.Table.Alias Then
f = featureProcessor.Combine(irfc)
End If
Next
'Adds the feature to the temp table
table.InsertFeature(f)
'Creates a new featurelayer for the table and adds it to the map
Dim fl2 As MapInfo.Mapping.FeatureLayer = New MapInfo.Mapping.FeatureLayer(table)
Me.MapControl1.Map.Layers.Add(fl2)
//This is the table with the features that will be combined
MapInfo.Mapping.FeatureLayer fl = this.MapControl1.Map.Layers["USA"] as MapInfo.Mapping.FeatureLayer;
//This created a temp table that has the same table structure as the table above
//This is where the new big combined feature will be stored
MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable("Combined_Features");
foreach(MapInfo.Data.Column col in fl.Table.TableInfo.Columns)
{
ti.Columns.Add(col.Clone());
}
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
MapInfo.FeatureProcessing.FeatureProcessor featureProcessor = new MapInfo.FeatureProcessing.FeatureProcessor();
MapInfo.Data.Feature f = null;
foreach(MapInfo.Data.IResultSetFeatureCollection irfc in MapInfo.Engine.Session.Current.Selections.DefaultSelection)
{
//Only want to combine features in the USA layer
if(irfc.BaseTable.Alias == fl.Table.Alias)
{
f = featureProcessor.Combine(irfc);
}
}
//Adds the feature to the temp table
table.InsertFeature(f);
//Creates a new featurelayer for the table and adds it to the map
MapInfo.Mapping.FeatureLayer fl2 = new MapInfo.Mapping.FeatureLayer(table);
this.MapControl1.Map.Layers.Add(fl2);
VB.Net Code:
VB.Net Code:
Dim fl As MapInfo.Mapping.FeatureLayer = Me.MapControl1.Map.Layers("USA")
'This created a temp table that has the same table structure as the table above
'This is where the new big combined feature will be stored
Dim ti As MapInfo.Data.TableInfoMemTable = New MapInfo.Data.TableInfoMemTable("Combined_Features")
For Each col As MapInfo.Data.Column In fl.Table.TableInfo.Columns
ti.Columns.Add(col.Clone())
Next
Dim table As MapInfo.Data.Table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti)
Dim featureProcessor As MapInfo.FeatureProcessing.FeatureProcessor = New MapInfo.FeatureProcessing.FeatureProcessor
Dim f As MapInfo.Data.Feature = Nothing
Dim irfc As MapInfo.Data.IResultSetFeatureCollection
For Each irfc In MapInfo.Engine.Session.Current.Selections.DefaultSelection
'Only want to combine features in the USA layer
If irfc.BaseTable.Alias = fl.Table.Alias Then
f = featureProcessor.Combine(irfc)
End If
Next
'Adds the feature to the temp table
table.InsertFeature(f)
'Creates a new featurelayer for the table and adds it to the map
Dim fl2 As MapInfo.Mapping.FeatureLayer = New MapInfo.Mapping.FeatureLayer(table)
Me.MapControl1.Map.Layers.Add(fl2)
- How to combine the features in the DefaultSelection
- How to combine the value of multiple hashes within an array by the same key
- How to remove ^M in the file
- How to change the timeout in FXCop
- How to set the style in valuelist
- How to detect the explorer in js
- How to install VIM in the MSYS?
- How to build libDTS in the MSYS?
- How to build libA52 in the MSY?
- How to build giflib in the MSYS?
- How to build libpng in the MSYS?
- How to install live555 in the MSYS?
- How to Run Hadoop in the Cloud
- how to implement the WaitForMultipleObjects in linux
- How to pause the game in Uniy3D
- How to sleep in the Linux kernel?
- How to build the environment of MSYS in the windows?
- Changing the Favicon in PeopleSoft – The “How to”
- 三级关联互动下拉列表
- 模拟退火
- SQL Server 不存在或访问被拒绝
- 收集的一些重庆的程序员工作 2007年 2月份信息
- 微软Windows Vista Logo认证与兼容性测试支持计划火热进行中
- How to combine the features in the DefaultSelection
- 实现动网cookies全网通用,登陆、退出也是全网通用,登录合并
- 10 things you should know about every Linux installation
- Java读取PDF,Doc的方法
- 统计学简史
- 解决半截字的办法
- 字符串匹配函数IndexOf
- ASP逐条读取ACCESS数据库里面的数据
- 如何取得上一次的URL?