Exemple #1
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            string sp = comboBox1.SelectedItem.ToString();

            try
            {
                srcDatasource1 = SampleRun.workspace1.Datasources[0];
                sourceImg1     = srcDatasource1.Datasets[sp] as DatasetImage;
                if (sourceImg1 == null)
                {
                    MessageBox.Show(this, "图层不符条件,无法转换!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    String targetDirectory = @"..\..\SampleData\DataExchange\SitExport";
                    if (!Directory.Exists(targetDirectory))
                    {
                        Directory.CreateDirectory(targetDirectory);
                    }
                    String targetFilePath = targetDirectory + @"\SitExport.sit";
                    this.SetExportSettings(FileType.SIT, targetFilePath);
                    SampleRun.mapControl1.Map.Layers.Clear();
                    dataExport1.Run();
                    SampleRun.mapControl1.Map.Layers.Add(sourceImg1, true);
                    SampleRun.mapControl1.Map.ViewEntire();
                    SampleRun.mapControl1.Map.Refresh();
                    System.Diagnostics.Process.Start("explorer.exe", "/n,/select, " + targetFilePath);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Exemple #2
0
 public void AddImage(Boolean isWithStyle)
 {
     try
     {
         DatasetImage dataset = m_datasource.Datasets[m_datasetImage] as DatasetImage;
         //设置风格并添加数据集
         Layer layer = null;
         if (isWithStyle)
         {
             LayerSettingImage setting = new LayerSettingImage();
             setting.OpaqueRate = 50;
             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);
     }
 }
        /// <summary>
        /// 打开需要的工作空间文件及地图
        /// Open the workspace and the map
        /// </summary>
        private void Initialize()
        {
            try
            {
                // 打开工作空间及地图
                // Open the workspace and the map.
                WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"..\..\SampleData\DataExchange\DataExchange.smwu");

                m_workspace.Open(conInfo);
                m_srcDatasource = m_workspace.Datasources["SrcDatasource"];
                m_desDatasource = m_workspace.Datasources["DesDatasource"];

                m_sourceRegion = m_srcDatasource.Datasets["China400"] as DatasetVector;
                m_sourceImg    = m_srcDatasource.Datasets["Day"] as DatasetImage;

                m_dataExport = new DataExport();
                m_dataImport = new DataImport();

                this.m_mapControl.Map.Layers.Add(m_sourceRegion, true);
                this.m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// 导入为Img
        /// Import as Img
        /// </summary>
        public void ImportToImg()
        {
            try
            {
                m_dataImport.ImportSettings.Clear();

                ImportSettingIMG imgSetting = new ImportSettingIMG();
                imgSetting.ImportMode          = ImportMode.Overwrite;
                imgSetting.SourceFilePath      = @"..\..\SampleData\DataExchange\ImgImport\Multibands.img";
                imgSetting.TargetDatasource    = m_desDatasource;
                imgSetting.MultiBandImportMode = MultiBandImportMode.MultiBand;

                m_dataImport.ImportSettings.Add(imgSetting);
                m_dataImport.Run();

                DatasetImage      importResult = m_desDatasource.Datasets["Multibands"] as DatasetImage;
                LayerSettingImage layerSetting = new LayerSettingImage();
                layerSetting.DisplayBandIndexes = new Int32[] { 3, 2, 1 };
                layerSetting.DisplayColorSpace  = ColorSpaceType.RGB;

                m_mapControl.Map.Layers.Clear();
                m_mapControl.Map.Layers.Add(importResult, layerSetting, true);
                m_mapControl.Map.IsDynamicProjection = false;
                m_mapControl.Map.ViewEntire();
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Exemple #5
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();
        }
Exemple #6
0
        public void LoadDom(string _domFilePath)
        {
            SuperMap.Data.Conversion.DataImport m_dataImport = new SuperMap.Data.Conversion.DataImport();
            m_dataImport.ImportSettings.Clear();
            ImportSettingIMG imgSetting1 = new ImportSettingIMG();

            imgSetting1.ImportMode          = ImportMode.Overwrite;
            imgSetting1.SourceFilePath      = _domFilePath;
            imgSetting1.TargetDatasource    = UCEarthGlobal.m_MainSceneControl.Scene.Workspace.Datasources["Default"];
            imgSetting1.MultiBandImportMode = MultiBandImportMode.MultiBand;
            imgSetting1.ImportingAsGrid     = false;

            m_dataImport.ImportSettings.Add(imgSetting1);
            m_dataImport.Run();
            IEnumerable <DatasetImage> dataimgList = UCEarthGlobal.m_MainSceneControl.Scene.Workspace.Datasources["Default"].Datasets.OfType <DatasetImage>();
            DatasetImage importResult = dataimgList.ToList().Find(v => v.Name == System.IO.Path.GetFileNameWithoutExtension(_domFilePath)) as DatasetImage;
        }