首页 / 浏览问题 / 组件GIS / 问题详情
三维场景,动态添加数据源、数据集、Geometry3D
45EXP 2020年02月13日
Geometry3D geometry = e.Geometry;
                Layer3DSettingVector setting = new Layer3DSettingVector();
                setting.Style.AltitudeMode = AltitudeMode.ClampToGround;
                setting.Style.LineColor = Color.Yellow;
                setting.Style.LineWidth = 1.3;

Datasource ds = MapUtils.OpenDatasource(this.m_sceneControl.Scene.Workspace, "drawEdit");
                DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
                datasetVectorInfo.Type = DatasetType.Line3D;
                datasetVectorInfo.IsFileCache = true;
                datasetVectorInfo.Name = "line";
                DatasetVector datasetVector = ds.Datasets.Create(datasetVectorInfo);
                Recordset recordset = datasetVector.GetRecordset(true, CursorType.Dynamic);
                bool f = recordset.AddNew(geometry);
                recordset.Update();
                datasetVector.PrjCoordSys = PrjCoordSys.FromEPSG(3857);

                Layer3DDataset layerPipeLine = this.m_sceneControl.Scene.Layers.Add(datasetVector, setting, true, "pipeLine");
                layerPipeLine.IsVisible = true;
                layerPipeLine.IsEditable = true;
                layerPipeLine.IsSelectable = true;
                this.m_sceneControl.Scene.Refresh();
                this.m_sceneControl.Refresh();

请看看是哪里有问题,界面不显示线段,这段代码是放在 m_sceneControl.Tracked 事件里的,MapUtils.OpenDatasource是自定义函数,生成并打开了一个datasource

1个回答

你好,建议你先看下数据源里面有没有生成数据集,可以执行一下代码然后用idesktop打开数据源看一下,还有,数据集坐标系最好用4326的
2,432EXP 2020年02月13日

DatasetVector datasetVector = ds.Datasets.Create(datasetVectorInfo);

数据集生成后不报错,datasetVector不为空,监视此变量,发现提示

名称 类型
Message "不支持这种数据集类型" string
另外,我是创建的内存数据源

public static Datasource OpenDatasource(Workspace workspace, string datasourceName)
        {
            Datasource ds;
            if (workspace.Datasources.Contains(datasourceName))
            {
                ds = workspace.Datasources[datasourceName];
            }
            else
            {
                DatasourceConnectionInfo info = new DatasourceConnectionInfo();
                info.Server = ":memory:";
                info.EngineType = EngineType.Memory;
                info.Alias = datasourceName;

                ds = workspace.Datasources.Create(info);
            }
            return ds;
        }
主要有可能是几何对象并没有添加进去,你的geometry必须要是geoline3d才能添加进三维线数据集里面,你先创建一个三维线数据集,放在文件型数据源里面,然后再执行代码,用idesktop看或者用iobjets去查看是否添加成功在放入场景里
数据集坐标系改成4326就好了,地图用的3857,这个数据集坐标系不需要和地图匹配吗?
因为你是在场景添加的节点数据,所以坐标是经纬度的,3857对应的球面坐标系就是4326的
...