예제 #1
0
        private void LoadDynamicObjectAndLineFromFile()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(Application.StartupPath + @"\MotionPath.xml");
            wkt = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            // 指定坐标系与xml里的相同
            dynamicObject.CrsWKT = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            point.SpatialCRS     = new CRSFactory().CreateFromWKT(dynamicObject.CrsWKT) as ISpatialCRS;
            line.SpatialCRS      = new CRSFactory().CreateFromWKT(dynamicObject.CrsWKT) as ISpatialCRS;

            XmlNodeList nodes = xmlDoc.SelectNodes("root/Waypoint");
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                double x = double.Parse(node.SelectSingleNode("X").InnerText);
                double y = double.Parse(node.SelectSingleNode("Y").InnerText);
                double z = double.Parse(node.SelectSingleNode("Z").InnerText);
                position.Set(x, y, z);
                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
                i++;
                double when = double.Parse(node.SelectSingleNode("When").InnerText);
                dynamicObject.AddWaypoint2(point, when);
                this.axRenderControl1.ObjectManager.CreateRenderPoint(point, null, rootId);
            }

            ICurveSymbol cur = new CurveSymbol();

            cur.Color = System.Drawing.Color.Red;
            cur.Width = -2;
            rline     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, cur, rootId);
        }
예제 #2
0
        /// <summary>
        /// 轨迹回放
        /// </summary>
        /// <param name="traceInfo">轨迹数据</param>
        /// <param name="speedTimes">回放倍数</param>
        /// <param name="traceChanged">轨迹是否改变</param>
        public void RenderVehicleTrajectory(IList <Trajectory> traceInfos, int speedTimes, bool traceChanged = true)
        {
            try
            {
                if (traceChanged)
                {
                    if (traceDynamicObj == null)
                    {
                        traceDynamicObj            = _axRenderControl.ObjectManager.CreateDynamicObject();
                        traceDynamicObj.AutoRepeat = false;
                        traceDynamicObj.CrsWKT     = WKT;
                        traceDynamicObj.TurnSpeed  = 300;
                        AppendGuidToStringBuilder(traceDynamicObj.Guid);

                        symbol = new SimplePointSymbolClass()
                        {
                            FillColor = 0xff0000ff,
                            Size      = 10
                        };

                        #region 创建线
                        IPoint    point = _geoFactory.CreatePoint(i3dVertexAttribute.i3dVertexAttributeZ);
                        IPolyline line  = (IPolyline)_geoFactory.CreateGeometry(i3dGeometryType.i3dGeometryPolyline, i3dVertexAttribute.i3dVertexAttributeZ);
                        line.SpatialCRS = _spatialCRS;


                        foreach (Trajectory trajectory in traceInfos)
                        {
                            IVector3 position = new Vector3();
                            position.Set(trajectory.LongitudeWgs84, trajectory.LatitudeWgs84, 1);
                            point.Position   = position;
                            point.SpatialCRS = _spatialCRS;

                            line.AppendPoint(point);
                            traceDynamicObj.AddWaypoint2(point, Convert.ToDouble(30 * speedTimes));

                            var rPoint = _axRenderControl.ObjectManager.CreateRenderPoint(point, symbol);
                            rPoint.MaxVisibleDistance = 12500;
                            rPoint.ViewingDistance    = 50;

                            AppendGuidToStringBuilder(rPoint.Guid);
                            //_axRenderControl.Camera.FlyToObject(rPoint.Guid, i3dActionCode.i3dActionFollowBehindAndAbove);
                        }
                        tracePolyline = _axRenderControl.ObjectManager.CreateRenderPolyline(line, new CurveSymbol {
                            Color = 0xFFFFFF00, Width = -2
                        });
                        tracePolyline.VisibleMask        = i3dViewportMask.i3dViewAllNormalView;
                        tracePolyline.MaxVisibleDistance = 12500;
                        tracePolyline.HeightStyle        = i3dHeightStyle.i3dHeightAbsolute;

                        AppendGuidToStringBuilder(tracePolyline.Guid);
                        #endregion
                    }
                }
                else
                {
                    if (traceDynamicObj == null)
                    {
                        return;
                    }

                    traceDynamicObj.Stop();
                    traceDynamicObj.TurnSpeed = 300 * speedTimes;
                    for (int i = 0; i < traceInfos.Count; i++)
                    {
                        traceDynamicObj.GetWaypoint2(i, out IPoint point, out double speed);
                        traceDynamicObj.ModifyWaypoint2(i, point, 30);
                    }
                }

                TraceObjectsPlay("111", traceDynamicObj, true);
            }
            catch (Exception ex)
            {
                LoggerHelper.Logger.Error(ex, $"执行RenderVehicleTrajectory错误");
                throw ex;
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: batuZ/Samples
        private void btnNavigate_Click(object sender, EventArgs e)
        {
            if (tour != null)
            {
                //是否相机跟随
                if (cbCameraFollow.Checked)
                {
                    if (renderModelPoint != null)
                    {
                        this.axRenderControl1.Camera.FlyToObject(renderModelPoint.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                    }
                    else if (skinMesh != null)
                    {
                        this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                    }
                }
                tour.Play();
                return;
            }

            tour           = this.axRenderControl1.ObjectManager.CreateDynamicObject(rootId);
            tour.CrsWKT    = dataset_Road.SpatialReference.AsWKT();
            tour.TurnSpeed = 100000;

            if (renderLine != null)
            {
                IPolyline line = renderLine.GetFdeGeometry() as IPolyline;
                for (int i = 0; i < line.PointCount; i++)
                {
                    fdepoint = line.GetPoint(i);
                    if (txtLocationNames.Text.Contains("I'm Here!"))
                    {
                        tour.AddWaypoint2(fdepoint, 30);
                    }
                    else
                    {
                        tour.AddWaypoint2(fdepoint, 100);
                    }
                }
            }
            else if (multiRenderLine != null)
            {
                IMultiPolyline mline = multiRenderLine.GetFdeGeometry() as IMultiPolyline;
                for (int i = 0; i < mline.GeometryCount; i++)
                {
                    IPolyline line = mline.GetPolyline(i);
                    for (int j = 0; j < line.PointCount; j++)
                    {
                        fdepoint = line.GetPoint(j);
                        if (txtLocationNames.Text.Contains("I'm Here!"))
                        {
                            tour.AddWaypoint2(fdepoint, 30);
                        }
                        else
                        {
                            tour.AddWaypoint2(fdepoint, 100);
                        }
                    }
                }
            }
            if (txtLocationNames.Text.Contains("I'm Here!"))
            {
                LoadPeople(tour);
            }
            else
            {
                LoadCar(tour);
            }
            //是否相机跟随
            if (cbCameraFollow.Checked)
            {
                if (renderModelPoint != null)
                {
                    this.axRenderControl1.Camera.FlyToObject(renderModelPoint.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                }
                else if (skinMesh != null)
                {
                    this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                }
            }
            tour.Play();
        }