首页 / 浏览问题 / 组件GIS / 问题详情
iobjects.net工作目录不存在的问题
20EXP 2021年03月07日

问题如图,具体代码如下,该代码是超图资源中心所下载的代码,我知道自己肯定得改改路径,可是具体在哪里改我不清楚,希望有先生可以教教我,谢谢。

设计视图如下:

代码如下:


namespace DynamicViewShedAnalysis
{
    public partial class Form1 : Form
    {
        private Workspace workspace;
        private SceneControl scenecontrol;
        private Layer3DKML layer3dkml;
        public Form1()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            Loaddata();
        }
        /// <summary>
        /// 打开工作空间和场景
        /// </summary>
        private void Loaddata()
        {
            try
            {
                scenecontrol = new SceneControl();
                scenecontrol.Dock = DockStyle.Fill;
                panel2.Controls.Add(scenecontrol);
                string filename = Application.StartupPath+ "\\test.smwu";
                WorkspaceConnectionInfo connection = new WorkspaceConnectionInfo(filename);
                workspace = new Workspace();
                bool a = workspace.Open(connection);
                scenecontrol.Scene.Workspace = workspace;
                scenecontrol.Scene.Open("DEM25@BeijingDEM");
                string path = Application.StartupPath + "\\test.kml";
                layer3dkml = scenecontrol.Scene.Layers.Add(path,Layer3DType.KML,true) as Layer3DKML;
                layer3dkml.IsEditable = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
        /// <summary>
        /// 画轨迹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawLine_Click(object sender, EventArgs e)
        {
            try
            {

                scenecontrol.Scene.TrackingLayer.Clear();
                layer3dkml.Features.Clear();
                //注册场景点击事件
                scenecontrol.MouseClick += new MouseEventHandler(scenecontrol_MouseClick);
                point3ds.Clear();
                style3d = new GeoStyle3D();//轨迹风格
                style3d.MarkerColor = Color.Green;
                style3d.MarkerSize = 10;
                style3d.LineColor = Color.Red;
                style3d.LineWidth = 5;
                style3d.AltitudeMode = AltitudeMode.Absolute;
                scenecontrol.Action = SuperMap.UI.Action3D.Null;
                scenecontrol.Scene.Refresh();
            }
            catch (Exception ex)
            {
 
            }
        }
        private GeoLine3D geoline;
        private Point3Ds point3ds=new Point3Ds();
        private Point3D point3d;
        private GeoStyle3D style3d;
        /// <summary>
        /// 场景点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void scenecontrol_MouseClick(object sender,MouseEventArgs e)
        {
            try
            {
                if (e.Button == MouseButtons.Left)
                {
                    point3d = scenecontrol.Scene.PixelToGlobe(new Point(e.X, e.Y), PixelToGlobeMode.TerrainAndModel);
                    point3ds.Add(point3d);
                    GeoPoint3D geopoint = new GeoPoint3D(point3d);
                    geopoint.Style3D = style3d;
                    scenecontrol.Scene.TrackingLayer.Add(geopoint, "Point");//轨迹经过点

                }
                else
                {
                    if (point3ds.Count < 2)
                    {
                        MessageBox.Show("至少绘制两个以上的点");
                        scenecontrol.Scene.TrackingLayer.Clear();
                        scenecontrol.Scene.Refresh();
                        return;
                    }
                    geoline = new GeoLine3D(point3ds);
                    geoline.Style3D = style3d;
                    scenecontrol.Scene.TrackingLayer.Add(geoline, "Line");//轨迹
                    scenecontrol.Scene.Refresh();
                    scenecontrol.MouseClick -= new MouseEventHandler(scenecontrol_MouseClick);
                    scenecontrol.Action = SuperMap.UI.Action3D.Pan;
                }

            }
            catch (Exception ex)
            {
 
            }
        }
        private GeoModel geoModel;
        /// <summary>
        /// 加载模型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (point3ds.Count == 0)
                {
                    MessageBox.Show("请先绘制轨迹");
                }
                geoModel = new GeoModel();
                string filename1 = Application.StartupPath + "\\plane\\plane.3ds";
                geoModel.FromFile(filename1);

                Point3D point = point3ds[0];
                geoModel.Position = point;
                GeoStyle3D geostyle = new GeoStyle3D();
                geostyle.AltitudeMode = AltitudeMode.Absolute;
                geoModel.Style3D = geostyle;
                geoModel.ScaleX = 20;
                geoModel.ScaleY = 20;
                geoModel.ScaleZ = 20;
                layer3dkml.Features.Add(geoModel);
                scenecontrol.Scene.Refresh();
            }
            catch(Exception ex)
            {
 
            }
        }
        private NodeAnimation nodeanimation;
        private Viewshed3D viewshed3D;
        /// <summary>
        /// 可视域分析,用了节点动画
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Analyst_Click(object sender, EventArgs e)
        {
            try
            {
                Feature3D feature=layer3dkml.Features[0] as Feature3D;
                GeoModel geo =feature.Geometry as GeoModel;
                nodeanimation = geo.NodeAnimation;
                nodeanimation.SetTrack(geoline);
                nodeanimation.Length = 10;
                nodeanimation.PlayMode = PlayMode.Once;
                nodeanimation.TimePostition = 0;
                nodeanimation.IsEnabled = true;
                viewshed3D = new Viewshed3D(scenecontrol.Scene);
                nodeanimation.TimePositionChanged += new TimePositionChangedEventHandler(nodeanimation_TimePositionChanged);
            }
            catch (Exception ex)
            {
 
            }
        }

其中,由于提问限制,可视域分析代码并未展示。

问题关闭原因: 问题重复了
...