SHP和CAD平面数据导入平面场景不显示

0 投票

使用产品:iobjects 10.2  操作系统:win10 x64
数据类型:文件型
问题详细描述:在三维平面场景中导入CAD和SHP数据,不显示。但在桌面端iDesktop导入正常显示。
 

                if (dataset.Type == DatasetType.Line3D)
                {
                    Layer3DSettingVector layer3DSettingVector = new Layer3DSettingVector();

                    GeoStyle3D geoStyle3D = new GeoStyle3D
                    {
                        AltitudeMode = AltitudeMode.ClampToGround,
                    };
                    layer3DSettingVector.Style = geoStyle3D;

                    // 这两行代码都不在平面场景中显示
                    //mLayersControl.Scene.Layers.Add(dataset, layer3DSettingVector, true);
                    mLayersControl.Scene.Layers.Add(dataset, layer3DSettingVector, true);
                }
                else if (dataset.Type == DatasetType.CAD)
                {
                    Layer3DSettingVector layer3DSettingVector = new Layer3DSettingVector();

                    GeoStyle3D geoStyle3D = new GeoStyle3D
                    {
                        AltitudeMode = AltitudeMode.ClampToGround,
                    };

                    layer3DSettingVector.Style = geoStyle3D;

                    // 这两行代码都不在平面场景中显示
                    mLayersControl.Scene.Layers.Add(dataset, layer3DSettingVector, true);
                    //mLayersControl.Scene.Layers.Add(dataset, (Layer3DSetting)null, true);
                }

1月 9 分类:  27次浏览 | 用户: Jing 才疏学浅 (12 分)

1个回答

0 投票

您好,组件有多种产品,为便于我们更快帮您解决问题,希望您可以准确标识您使用的产品,如iobject .net、iobject Python等。

1月 10 用户: 执笔画月 名扬四海 (2,474 分)
iobject .net
cad和shp你具体是导入成了什么数据集?
        /// <summary>
        /// 加载 CAD 影像数据
        /// </summary>
        private void AddCAD(object obj)
        {
            GetPreviousMaps();

            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "AutoCAD文件(*.dxf;*.dwg;*.dgn)|*.dxf;*.dwg;*.dgn";
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Title = "导入CAD文件";
            Workspace ws = ProjectConfig.mWorkspaceControl.WorkspaceTree.Workspace;

            if (openFileDialog.ShowDialog() == true)
            {
                string theExtension = Path.GetExtension(openFileDialog.FileName);

                dynamic importSettingCAD; // 设置动态变量,在运行时解析是何种CAD文件

                if (theExtension == ".dwg")
                {
                    importSettingCAD = new ImportSettingDWG();
                }
                else if (theExtension == ".dxf")
                {
                    importSettingCAD = new ImportSettingDXF();
                }
                else
                {
                    importSettingCAD = new ImportSettingDGN();
                }
                // 配置CAD文件导入参数
                importSettingCAD.SourceFilePath = openFileDialog.FileName;
                importSettingCAD.ImportMode = ImportMode.None; // 导入模式:无
                importSettingCAD.TargetDatasetName = 
                Path.GetFileNameWithoutExtension(openFileDialog.FileName);
                importSettingCAD.CurveSegment = 73; // 曲线拟合精度,默认73
                importSettingCAD.TargetPrjCoordSys = ws.Datasources[0].PrjCoordSys;
                importSettingCAD.ImportingAsCAD = true;
                importSettingCAD.ImportingByLayer = true;

                ImportAndConvert(importSettingCAD, ws);

                
            }
        }

        /// <summary>
        /// 加载 .Shp 数据
        /// </summary>
        private void AddShp(object obj)
        {
            GetPreviousMaps();

            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "shp文件(*.shp)|*.shp";
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Title = "导入SHP文件";
            Workspace ws = ProjectConfig.mWorkspaceControl.WorkspaceTree.Workspace;

            if (openFileDialog.ShowDialog() == true)
            {
                ImportSettingSHP importSettingShp = new ImportSettingSHP();
                importSettingShp.SourceFilePath = openFileDialog.FileName;
                importSettingShp.TargetDatasetName = 
                Path.GetFileNameWithoutExtension(openFileDialog.FileName);

                importSettingShp.TargetPrjCoordSys = ws.Datasources[0].PrjCoordSys;

                ImportAndConvert(importSettingShp, ws);

                
            }
        }



        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="importSetting"></param>
        /// <param name="ws"></param>
        /// <returns></returns>
        private Dataset ImportAndConvert(dynamic importSetting, Workspace ws)
        {

            if (DuplicateCheck(importSetting.TargetDatasetName))
            {
                MessageBoxManager.Show(MessageBoxManager.MsgBoxType.Error, 2, "重复导入底图");

                return null;
            }


            importSetting.TargetDatasource = ws.Datasources[0];

            DataImport dataImport = new DataImport();
            dataImport.ImportSettings.Clear();
            dataImport.ImportSettings.Add(importSetting);

            
            dataImport.Run();
            

            Dataset dataset = ws.Datasources[0].Datasets[importSetting.TargetDatasetName];

            return dataset;
        }

您这边具体定位目前是导入为数据集的数据集不正常,还是任意数据数据集作为图层加载在场景里后,刷新场景图层和图层里的东西不显示?
数据集正常,该数据集导入iDesktop后,场景里面正常显示。

但是作为图层加载在场景里后,刷新场景不显示,图层管理器中有该图层。然而仍然定位到该图层,场景中没有任何内容。
我建议您控制单一情况测试才能定位到具体出现问题的原因,

使用代码导入数据集,代码导入的数据集在桌面端看;(不正常则导入数据集代码有问题)

使用桌面新建的一份正常数据集集,在代码里看;(不正常则加图层代码有问题)

诸如此类,建议您先定位到具体问题在哪里。
...