關於MapXtreme方面的幾個問題:
需求1:
用戶從客戶端圈選幾個小區,點擊相應的按鈕進行計算或其它處理,處理結束後,返回相關的框來顯示處理結果,並且把選中的小區改變成紅色。接着可以再處理其它小區,剛剛改變顏色的小區仍然顯示改變後的顏色。
(我覺得跟你們搜索網元后的顯示以及搜索頻點的顯示的效果類似)
兩個問題:
1. 選中小區後,如何獲得小區的相關信息。
我是通過獲得選擇集來從.tab文件獲得小區的主鍵(已實現),然後再通過該主鍵利用ado.net去查詢數據庫來得到。不知道方法是否與你們一致。
2. 處理結束後,把選中小區顯示成紅色,這個還沒解決好,更新失敗,可能方法還有問題。
我想按你們相關類似功能的實現方法來做。改變地圖後,如果不保存工作空間,那麼對小區顏色的改變在下一次登陸不生效,反之下一次登陸顏色改變。你們用的是臨時圖層麼?或是樣式覆蓋等其它的方法?
需求2:
新增基站。
問題:
1. 你們關於基站以及小區圖層是在服務器端定時生成的,用戶通過下載來進行更新。如果用戶需要在地圖上新增一個基站。基站及小區的畫法應該如何實現。
我覺得思路應該是:爲了保持一致,使用你們畫基站和小區時的brush,pen等,往基站和小區天線的.tab圖層里加,同時更新數據庫。所以,需要知道你們使用的畫筆畫刷的樣式以及畫扇形的方法。
不知道這個思路是否正確。
答覆:
需求1:
1、 方式是一致的,非常類似的功能應該是點擊一個小區,在屬性面板上顯示小區的屬性。
2、 類似於多個小區定位,給你代碼
public void LocateMultisCell(ArrayList cellNameList,string layerName, Map map, Color cellColor,string labelString)
{
if(cellNameList.Count == 0)
return;
MapInfo.Data.Table isTable1 = MapInfo.Engine.Session.Current.Catalog.GetTable(layerName);
if(isTable1 != null)
isTable1.Close();
string tempLayerName = "Cell_"+ layerName;
//判斷圖層是否存在
MapInfo.Data.Table isTable = MapInfo.Engine.Session.Current.Catalog.GetTable(tempLayerName);
if(isTable != null)
isTable.Close();
System.Data.DataTable table = new DataTable();
DataColumn column1 = new DataColumn();
column1.DataType = System.Type.GetType("System.Int16");
column1.ColumnName = "myId";
table.Columns.Add(column1);
DataColumn column2 = new DataColumn();
column2.DataType = System.Type.GetType("System.String");
column2.ColumnName = "name";
table.Columns.Add(column2);
DataColumn column3 = new DataColumn();
column3.DataType = System.Type.GetType("System.String");
column3.ColumnName = "bcch";
table.Columns.Add(column3);
DataColumn column4 = new DataColumn();
column4.DataType = System.Type.GetType("System.String");
column4.ColumnName = "tch";
table.Columns.Add(column4);
DataColumn column5 = new DataColumn();
column5.DataType = System.Type.GetType("System.String");
column5.ColumnName = "bsic";
table.Columns.Add(column5);
DataColumn column6 = new DataColumn();
column6.DataType = System.Type.GetType("System.String");
column6.ColumnName = "chgr";
table.Columns.Add(column6);
DataRow row;
for (int i = 0; i< cellNameList.Count; i++)
{
Wellcomm.DataService.CellFreqEntity entity = (CellFreqEntity)cellNameList[i];
row = table.NewRow();
row["myId"] = 1;
row["name"] = entity.CellName;
row["bcch"] = entity.Bcch;
row["tch"] = entity.Tch;
row["bsic"] = entity.Bsic;
row["chgr"] = entity.Chgr;
table.Rows.Add(row);
}
TableInfoAdoNet tabAdo = new TableInfoAdoNet(tempLayerName);
tabAdo.ReadOnly = false;
tabAdo.DataTable = table;
MIConnection connection=new MIConnection();
connection.Open();
Table miStateInfo = connection.Catalog.OpenTable(tabAdo);
if(miStateInfo!=null)
{
MapInfo.Data.TableInfo tableInfo = MapInfo.Data.TableInfoFactory.CreateTemp(layerName);
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("id",20));
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("name", 50));
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("bcch", 20));
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("tch", 20));
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("bsic", 20));
tableInfo.Columns.Add(ColumnFactory.CreateStringColumn("chgr", 20));
tableInfo.Columns.Add(ColumnFactory.CreateIntColumn("myId"));
tableInfo.ReadOnly=false;
Table testTable = MapInfo.Engine.Session.Current.Catalog.CreateTable(tableInfo);
Table table1800 = MapInfo.Engine.Session.Current.Catalog.GetTable("DCS1800小區天線");
Table table900 = MapInfo.Engine.Session.Current.Catalog.GetTable("GSM900小區天線");
MIConnection miConn = new MIConnection();
MICommand miCommandA = miConn.CreateCommand();
MICommand miCommandB = miConn.CreateCommand();
miCommandA.CommandText="insert into "+layerName+
" (obj,MI_Style,id,name,myId,bcch,tch,bsic,chgr) "+
" select b.obj,b.MI_Style,b.id,b.name,a.myId,a.bcch,a.tch,a.bsic,a.chgr from "+ tempLayerName +" a, "+ table1800.Alias +" b where a.name = b.name";
miCommandB.CommandText="insert into "+layerName+
" (obj,MI_Style,id,name,myId,bcch,tch,bsic,chgr) "+
" select b.obj,b.MI_Style,b.id,b.name,a.myId,a.bcch,a.tch,a.bsic,a.chgr from "+ tempLayerName +" a, "+ table900.Alias +" b where a.name = b.name";
miConn.Open();
miCommandA.ExecuteNonQuery();
miCommandB.ExecuteNonQuery();
if(Wellcomm.Easywell.Gis.Util.ViewControls.NotEmptyTable(testTable))
{
MapInfo.Mapping.FeatureLayer featureLayer = new MapInfo.Mapping.FeatureLayer(testTable);
//插入到標註的後面
map.Layers.Insert(1,featureLayer);
//小區樣式
MapInfo.Styles.SimpleInterior simpleInterior = new SimpleInterior(); //區域背景
simpleInterior.ForeColor = cellColor;
MapInfo.Styles.AreaStyle area = new MapInfo.Styles.AreaStyle();
area.Interior = simpleInterior;
SimpleLineStyle bor = new SimpleLineStyle();
area.Border = bor;
MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(area);
FeatureOverrideStyleModifier fsm = new FeatureOverrideStyleModifier("Style["+layerName+"]", compositeStyle);
featureLayer.Modifiers.Append(fsm);
//同鄰頻小區,標註顯示:BCCH(BSIC) /n [chgr1]{TCH1}[chgr2]{TCH2}...
if(labelString != null && labelString != "")
Wellcomm.Easywell.Gis.Util.CustomLabelProperties.AddMultiLabel(map,testTable,labelString,cellColor);
//控制視野
//Wellcomm.Easywell.Gis.Util.ViewControls.ViewControl(testTable,map);
Wellcomm.Easywell.Gis.Util.ViewControls.NotSelect(map,testTable);
}
//關閉操作
miStateInfo.Close();
miCommandA.Cancel();
miCommandA.Dispose();
miCommandB.Cancel();
miCommandB.Dispose();
miConn.Close();
}
}
需求2:
首先,我們這邊沒有用戶在地圖上添加網元的應用場景。用戶自己在地圖上增加一個基站,這會引起數據庫中數據的變化,如基站的覆蓋、小區的歸屬、新增基站的歸屬都會發生變化,而這些變化會引起整個圖層的變化,應該重新生成圖層。
我認爲不應該提倡這樣的做法,如果一定要實現這樣的操作,我認爲在交互上用戶發出請求後,首先更新數據庫,然後生成.TAB文件,最後下載到客戶機顯示。
另外,基站和小區不是畫上去的,是通過數據庫生成MAPINFO文件,在程序中只是打開一個MAPINFO的表以增加一個圖層。
以上只是個人意見,僅供參考。