Public Security Three-Dimensional Electronic Sandbox Digital Sandbox Situation Deduction Tutorial Lesson 12

Public Security 3D Virtual Electronic Sandbox Digital Sandbox Situation Deduction Tutorial Lesson 12

Set system.ini as follows
Server=122.112.229.220
user=GisTest
Password=chinamtouch. com

This database only provides data near Chengdu South Railway Station. Please note, 104.0648,30.61658

The SDK comes with a navigation system, which uses relatively detailed navigation data. As you know, a bug when using the Internet server has been fixed. Please be sure to download the core update at the above address when using this part of the function. Package coverage. Screenshot below:

This navigation graph is a sliced ​​navigation graph. You know the year, and the navigation system works asynchronously with threads. Because database support is required, if you are using an Internet server

The time it takes for the navigation algorithm to obtain the path will increase. It is recommended to download the database locally to see the real speed of the navigation algorithm.

  The navigation algorithm is in a separate ShortRoad.dll (can be used independently, as long as relevant data files are required.) The navigation algorithm can be fine-tuned based on the weights. Currently, there are two types: high-speed priority and shortest path.

ShortRoad.ShortPath.MyPareant = this.Dispatcher; //Because the navigation algorithm is completed by asynchronous delegation + multi-threading, an asynchronous delegation main object (static) is required.

            ​ ​ ​ ​ShortRoad.ShortPath.chuslhi(); //Initialization data (static)

          MyShort = new ShortRoad.ShortPath();

//Initialize navigation class

            MyShort.OnShortPath += new ShortRoad.ShortPath.PathOver(ShortPath_OnShortPath);

//Navigation data callback event

            MyShort.OnPro += new ShortRoad.ShortPath.ChuLiPro(ShortPath_OnPro);

//Navigation algorithm information event.

   MyShort.GetShortPath(BeginPoint.X, BeginPoint.Y, EndPoint.X, EndPoint.Y,false);

//Get the shortest path:

Parameters: starting point longitude, latitude, end point longitude, latitude, whether to enable high-speed priority.

路径回调事件:
     void ShortPath_OnShortPath(System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<System.Drawing.PointF>> value,System.Windows.Point bx,System.Windows.Point ey)

        {            double Totolength = 0;

            Pareant.PlayPath.Add(new Point3D(BeginPoint.X, BeginPoint.Y, 0));

            foreach (string key in value.Keys)

            {

                Totolength += Convert.ToDouble(key.Split('#')[1].Split(',')[12]);

                foreach (System.Drawing.PointF y1 in value[key])

                {

                    Pareant.PlayPath.Add(new Point3D(y1.X, y1.Y, 0));

                }

            }

}

事件参数1:System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<System.Drawing.PointF>>

All path data is stored. KEY is the path details and the content is as follows (Value is the latitude and longitude data):

"Qingjiang East Road #464400, 49559714, 1, 0302, 130, 3, 2, 1, , 47106369, 5880354, 3, 0.012, 1, 1, , 0, 1, 0, 510105, 510105 , 1 , , , 5 , , 4 , 3 , 11110001110000000000000000000000 , 0 , 0 , , , , 600 , , 1 , 1 , , Qingjiang East Road"

This KEY describes all the information about this road. Please refer to the table below:

In the code below, you must first reference shortroad.dll.

 ShortRoad.ShortPath.MyPareant = this.Dispatcher; //Because the navigation algorithm is completed by asynchronous delegation + multi-threading, an asynchronous delegation main object (static) is required.
            ShortRoad.ShortPath.chuslhi(); //Initialization data (static)
            >                                                                                                                                                                                                                                    . OnPro += MyShort_OnPro;             //Navigation algorithm information event.



 
 


 

  #region 导航系统
        System.Windows.Point FirstJW= new System.Windows.Point();
        System.Windows.Point secJW = new System.Windows.Point();
        private void Button_Click_15(object sender, RoutedEventArgs e)
        {
            gis3d.State = GisLib.WindowsMT.GisState.获取经纬度;
            gis3d.GetJWEvent += Gis3d_GetJWEvent2;
                
        }
 
        private void Gis3d_GetJWEvent2(System.Windows.Media.Media3D.Point3D value)
        {
            gis3d.GetJWEvent -= Gis3d_GetJWEvent2;
            FirstJW = new System.Windows.Point(value.X, value.Y);
            gis3d.State = GisLib.WindowsMT.GisState.漫游;
        }
 
        private void Button_Click_16(object sender, RoutedEventArgs e)
        {
            gis3d.State = GisLib.WindowsMT.GisState.获取经纬度;
            gis3d.GetJWEvent += Gis3d_GetJWEvent3;
        }
 
        private void Gis3d_GetJWEvent3(System.Windows.Media.Media3D.Point3D value)
        {
            gis3d.GetJWEvent -= Gis3d_GetJWEvent2;
            secJW = new System.Windows.Point(value.X, value.Y);
            MyShort.GetShortPath(FirstJW.X, FirstJW.Y, secJW.X, secJW.Y, true);
            gis3d.State = GisLib.WindowsMT.GisState.漫游;
        }
 
        private void MyShort_OnPro(string value)
        {
            FirstShort.Content = value;
        }
 
        private void MyShort_OnShortPath(Dictionary<string, List<PointF>> value, System.Windows.Point mbegin, System.Windows.Point mend)
        {
            if (value == null)
                return;
            if (value.Count == 0)
                return;
 
 
 
            List<Point3D> PlayPath = new List<Point3D>();
 
            double Totolength = 0;
 
            // Pareant.PlayPath.Add(new Point3D(BeginPoint.X, BeginPoint.Y, 0));
            foreach (string key in value.Keys)
            {
                if (key.Length > 12)
                {
                    if (key.Split('#').Length >= 2)
                        Totolength += Convert.ToDouble(key.Split('#')[1].Split(',')[12]);
                }
 
                foreach (System.Drawing.PointF y1 in value[key])
                {
                    PlayPath.Add(new Point3D(y1.X, y1.Y, 0));
                }
 
            }
            PlayPath.Add(new Point3D(secJW.X, secJW.Y, 0));
            Random t1 = new System.Random();
 
            System.Windows.Media.Color pp = new System.Windows.Media.Color();
           
                pp = Colors.Red;
 
            / /Call the road drawing method provided by the SDK to draw the road
            gis3d.RemoveShotPath("Navigation path");
            gis3d.DrawShortPath(PlayPath, " Navigation path", pp, true);
 
 
 
        }
        #endregion
 

 The effect is as follows: database cooperation is repeatedly emphasized, so when using an Internet server. It will be slower during calculation because the thread mode is used, so it does not affect the main process to do other things. The drashortpath method that comes with the SDK supports automatic thinning and can display long navigation routes.

Guess you like

Origin blog.csdn.net/qq_37897462/article/details/131962758