Esempio n. 1
0
        /*专题图制作部分 
         * 一、SuperMap中
         *   1、将一个数据集拖拽到地图
         *   2、进来的是默认的栅格图层  然后右键制作专题图  选择栅格分段专题图
         *   3、加载专题图模板。
         *   二、代码部分
         *   1、将数据集添加进地图
         *   2、
         */
        public void refreshMod(string wksPath, string name,string password,string ref_zt)
        {
            try
            {
                SuperMap.Data.Workspace sWorkspace1 = new SuperMap.Data.Workspace();
                WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(wksPath + ".smwu");//@"G:\数据转换\测试数据\Test1\test.smwu");
                info.Password = password;
                sWorkspace1.Open(info);
                if (sWorkspace1.Datasources[name] == null)
                    return;
                Datasource ds = sWorkspace1.Datasources[name];
                int con = ds.Datasets.Count;
               
                SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(sWorkspace1);
                map.Open(name);
                
                Layers layers = map.Layers;
                
                ThemeGridRange tgr = new ThemeGridRange();
                tgr.FromXML(readXML(ref_zt));
                
                for (int i = 1; i <= con; i++)
                {
                    
                    if (map.Layers[i].Name.Substring(0, 4) == "time")
                        continue;
                    DatasetGrid dataSet = ds.Datasets["time" + i.ToString()] as DatasetGrid;
                    Layer layer =map.Layers.Insert(i, dataSet,tgr);
                    // map.Layers.Add(dataSet, tgr, true);
                    layer.IsVisible = false;
                    layer.Caption = "time" + i.ToString();
                    map.Refresh();
                    

                }
                sWorkspace1.Maps.SetMapXML(name, map.ToXML());
                //sWorkspace1.Maps.Add(name+"_x", map.ToXML());
                map.Workspace.Save();
                sWorkspace1.Dispose();
               
                //MessageBox.Show("Over");
                //  sWorkspace1.Save(); MessageBox.Show(layers.Count + "");
                 //layer.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                //layerSettingGrid.ColorTable = Colors.MakeGradient(20, ColorGradientType.BlueWhite, false);

                //layerSettingGrid.SpecialValue = -9999;
                //layerSettingGrid.IsSpecialValueTransparent = true;
                //LayerSettingVector layerSettingVector = new LayerSettingVector();
                //GeoStyle style = new GeoStyle();
                //style.FillForeColor = Color.HotPink;
                //layerSettingGrid.Style = style;
                
                
                
                //ThemeCustom tc = new ThemeCustom();
                //tc.FromXML(readXML(@"D:\移动风险监测\time53.xml"));
               
                //Theme theme=
                //string themes = theme.ToXML();
                //DevComponents.DotNetBar.Controls.RichTextBoxEx re = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
                //re.Text = themes;
                //re.SaveFile(@"D:\移动风险监测\test.txt",RichTextBoxStreamType.TextTextOleObjs);
                //theme.FromXML(readXML(@"D:\移动风险监测\time53.xml"));
               

                   

                  //  layer.Theme.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                   //layer.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                   // lyy1.Caption = ;
                    
                    //Layer lyy = layers.Add(dataSet, layerSettingGrid, true);
                    
                 
                    //MessageBox.Show(layers.Count + "");
                    //if(layers.Count==400)
                    //    j=layers.Count;
                    //layers.Add(dataSet,new LayerSettingGrid(), true);
                   //Layer ly=  layers.Insert(i, dataSet, tgr);
                   //MessageBox.Show(layers.Count + "");
                   //layers.Add(dataSet, true);
                   //MessageBox.Show(layers.Count + "");
                   //map.EnsureVisible(ly);
                 
                //sWorkspace1.Maps.Add(sWorkspace1.Maps.GetAvailableMapName(name), map.ToXML()); 
              
               
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private Theme getTheme(SuperMap.Data.Workspace wks, string mapName)
        {
            try
            {
                SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(wks);
                map.Open(mapName);
                Layers layers = map.Layers;
                Layer layer = null;
                for (Int32 i = 0; i < layers.Count; i++)
                {
                    layer = layers[i];
                    if (layer.Theme != null)
                    {
                        break;
                    }
                }
                Theme theme = layer.Theme;
                return theme;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 获得地图模板:从已有地图中
 /// </summary>
 /// <param name="wksPath">工作空间</param>
 /// <param name="index">地图索引</param>
 /// <returns>xml的字符</returns>
 public String gainXML(string wksPath, int index)
 {
     SuperMap.Data.Workspace sWorkspace = new SuperMap.Data.Workspace();
     WorkspaceConnectionInfo infomation = new WorkspaceConnectionInfo(wksPath);//@"G:\数据转换\测试数据\Test\test.smwu");
     sWorkspace.Open(infomation);
     if (sWorkspace.Maps.Count == 0)
     {
         MessageBox.Show("当前工作空间中不存在地图!");
         return "";
     }
     SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(sWorkspace);
     map.Open(sWorkspace.Maps[index]);
     String xml = map.ToXML();
     string name = map.Name;
     map.Close();
     sWorkspace.Dispose();
     return xml;
 }