Exemplo n.º 1
0
 /// <summary>
 /// 向地图中添加栅格数据集
 /// </summary>
 /// <param name="isWithStyle">是否自定义风格</param>
 public void AddGrid(Boolean isWithStyle)
 {
     try
     {
         DatasetGrid dataset = m_datasource.Datasets[m_datasetGrid] as DatasetGrid;
         //设置风格并添加数据集
         Layer layer = null;
         if (isWithStyle)
         {
             LayerSettingGrid setting = new LayerSettingGrid();
             setting.ColorTable   = Colors.MakeGradient(20, ColorGradientType.BlueWhite, false);
             setting.SpecialValue = -9999;
             setting.IsSpecialValueTransparent = true;
             layer = m_mapControl.Map.Layers.Add(dataset, setting, true);
         }
         else
         {
             layer = m_mapControl.Map.Layers.Add(dataset, true);
         }
         //全幅显示添加的图层
         m_mapControl.Map.EnsureVisible(layer);
         m_mapControl.Map.Refresh();
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemplo n.º 2
0
        //将数据集添加到场景中
        private void AddToSceneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WorkspaceTreeNodeBase node = this.workspaceControl.WorkspaceTree.SelectedNode as WorkspaceTreeNodeBase;
            Dataset      dataset       = node.GetData() as Dataset;
            Layer3D      layer3D       = null;
            TerrainLayer terrainLayer  = null;
            String       layerName     = dataset.Name + "@" + dataset.Datasource.Alias;

            switch (node.NodeType)
            {
            case WorkspaceTreeNodeDataType.DatasetVector:
            {
                Random random = new Random(Guid.NewGuid().GetHashCode());

                DatasetVector        datasetVector = dataset as DatasetVector;
                Layer3DSettingVector settingVector = new Layer3DSettingVector();
                GeoStyle3D           style         = new GeoStyle3D();
                style.FillMode      = FillMode3D.LineAndFill;
                style.MarkerColor   = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));    //Color.Red;
                style.LineColor     = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));    //Color.SaddleBrown;
                style.FillForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));    //Color.SkyBlue;
                if (datasetVector.Type == DatasetType.Line3D)
                {
                    style.AltitudeMode = AltitudeMode.Absolute;
                    style.LineWidth    = 4;
                }
                settingVector.Style = style;
                layer3D             = this.m_sceneControl.Scene.Layers.Add(datasetVector, settingVector, true, layerName);
                break;
            }

            case WorkspaceTreeNodeDataType.DatasetGrid:
            {
                DatasetGrid datasetGrid = dataset as DatasetGrid;
                terrainLayer = this.m_sceneControl.Scene.TerrainLayers.Add(datasetGrid, true);
                break;
            }

            case WorkspaceTreeNodeDataType.DatasetImage:
            {
                DatasetImage        datasetImage = dataset as DatasetImage;
                Layer3DSettingImage settingImage = new Layer3DSettingImage();
                layer3D = this.m_sceneControl.Scene.Layers.Add(datasetImage, settingImage, true, layerName);
                break;
            }
            }
            //if (layer3D != null)
            //{
            //    this.m_sceneControl.Scene.EnsureVisible(layer3D.Bounds);
            //}
            //if (terrainLayer != null)
            //{
            //    this.m_sceneControl.Scene.EnsureVisible(terrainLayer.Bounds);
            //}
            this.m_sceneControl.Scene.Refresh();
        }
Exemplo n.º 3
0
        public void LoadDem(string _demFilePath)
        {
            SuperMap.Data.Conversion.DataImport m_dataImport = new SuperMap.Data.Conversion.DataImport();
            //导入dem
            m_dataImport.ImportSettings.Clear();
            ImportSettingIMG imgSetting = new ImportSettingIMG();

            imgSetting.ImportMode          = ImportMode.Overwrite;
            imgSetting.SourceFilePath      = _demFilePath;
            imgSetting.TargetDatasource    = UCEarthGlobal.m_MainSceneControl.Scene.Workspace.Datasources["Default"];
            imgSetting.MultiBandImportMode = MultiBandImportMode.SingleBand;
            imgSetting.ImportingAsGrid     = true;

            m_dataImport.ImportSettings.Add(imgSetting);
            m_dataImport.Run();
            IEnumerable <DatasetGrid> dataGridList = UCEarthGlobal.m_MainSceneControl.Scene.Workspace.Datasources["Default"].Datasets.OfType <DatasetGrid>();
            DatasetGrid importResult = dataGridList.ToList().Find(v => v.Name == System.IO.Path.GetFileNameWithoutExtension(_demFilePath)) as DatasetGrid;

            TerrainLayer terrainLayer = UCEarthGlobal.m_MainSceneControl.Scene.TerrainLayers.Add(importResult, true);

            UCEarthGlobal.m_MainSceneControl.Scene.Fly(new Camera {
                Latitude = terrainLayer.Bounds.Center.X, Longitude = terrainLayer.Bounds.Center.Y, Altitude = 10
            });
        }