Lesson 13 of the Ministry of Armed Forces 3D Electronic Sandbox Virtual Digital Sandbox Development Tutorial

Lesson 13 of the Ministry of Armed Forces 3D simulation electronic sandbox virtual digital sandbox development tutorial

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

 In order to facilitate the access of third-party data, a user layer interface is introduced in the SDK. It mainly completes the access of third-party data, including dynamic data (such as GPS). Users can control the UI and the interaction of the UI by themselves, which can realize vehicle control such as Didi Taxi. The UI in the public security application is displayed according to attribute control, and the user The display of the layer is directly called by the core part, and the interface below is called when the data needs to be displayed. This can prevent users from accessing from the outside. And lagging affects the user experience. The recycling of UI is the responsibility of the core and does not require user intervention. During secondary development, users only need to care about the UI they want to present and the interaction of the UI:

     public interface UserGisData : INotifyPropertyChanged
    {         NewGisBiao.Base.JunBiao.CenteType BiaoCenterType         {             use using use with using using        . / >                                                                                                                                                                          overall label                                                                                                    .         ; a>        int minzoom < /span>             /span>         void OnUserBiaoClick(DrawPointData va); //UI click events are now invalid, and the UI can respond to all interactive events on its own         List<DrawPointData> DrawData(double centerx, double centery) ;         /// <returns></returns>         /// <param name="centery" ;></param>         /// <param name="centerx"></param>         /// /// </ summary>         /// Draw user objects         /// <summary>         Dictionary<SechData, Point> SechForRect(List<Point> Line, string info,double length);         Dictionary<SechData, Point> SechForLine(List<Point> Line, string info, double length);         Dictionary<SechData, Point> SechPro(double centerx, double centery, string info, double length);         /// <returns></returns>         param name="length">Range (null will be passed in if not)</param>         /// <param name="info">Query information (if all will be passed in*)</param>         /// <param name="centery">Query the latitude of the center point (if not, null will be passed in)</param>         /// & lt; Param name = & quot; centerx & quot; & gt; ) </param>         /// & lt;/Summary & gt;         {         to  =48> System.Windows.Media.Imaging.BitmapImage MICon            /// <summary>        {                    Minimum display layer of this user layer /// <summary>        {         /// & lt;/summary & gt;         /// minimum display layer         / // & lt; summary & gt;        }            set;            get; //Hide and show the user layer        {         / // <summary>        }            set;            get; //Access the currently existing UI object        {
 
 




 


         

 
     
 
 







 
 





 








 








 








 
 
 
 
















 


 







 
 

 
 
 
    }

List<DrawPointData> DrawData(double centerx, double centery); is the core part of this interface. The incoming parameter is the longitude and latitude of the center point of the current map. According to this longitude and latitude, secondary development users need to draw data from data (such as mysql or other third-party data). ) Query the data that currently needs to be displayed and return it together with the UI: Examples are as follows:

 List<DrawPointData> UserGisData.DrawData(double centerx, double centery)
        {
 
            if (Con == null)
            {
                Con = new MySql.Data.MySqlClient.MySqlConnection(IniRead.IniReadWrite.GetMySqlDataConnstring());
                Con.Open();
            }
 
            int mmzoom = IniRead.IniReadWrite.MPareant.Zoom;
            int drawfanwei = 5;
            double bx, by, ex, ey;
            Int64 cx, cy;
            NewGisBiao.Help.MathHelp.MyConver(centerx, centery, out cx, out cy, (int)mmzoom - 1);
            NewGisBiao.Help.MathHelp.MyConver2(cx - drawfanwei, cy - drawfanwei, (int)mmzoom - 1, out bx, out by);
            NewGisBiao.Help.MathHelp.MyConver2(cx + drawfanwei, cy + drawfanwei, (int)mmzoom - 1, out ex, out ey);
            string t6 = " where (jingdu > " + bx.ToString() + " and jingdu<"
                               + ex.ToString() + " and weidu > "
                               + ey.ToString() + " and weidu < "
                               + by + ")";
            MySqlCommand cmd = Con.CreateCommand();
            cmd.CommandText = "select * from gw_shigu" + t6;
            MySqlDataReader read = cmd.ExecuteReader();
 
            try
            {
 
 
                if (read.HasRows)
                {
                    List<DrawPointData> y1 = new List<DrawPointData>();
                    while (read.Read())
                    {
                        if (MData.ContainsKey(read["number"].ToString() + "A") == false)
                        {
 
                            DrawPointData u1 = new DrawPointData();
 
                            u1.ISAutoAngle = true;
                            u1.ISAutoScal = true;
                            u1.MaxZoomScal = 15;
 
 
                            u1.ID = read["number"].ToString() + "A";
                            u1.MPoint = new Point(Convert.ToDouble(read["jingdu"].ToString()), Convert.ToDouble(read["weidu"].ToString()));
                            Image h1 = new Image();
                            u1.Hi = 0.05;
                            h1.Width = 45;
                            h1.Height = 70;
                            if (read["sgtype"].ToString().Trim() == "重伤")
                                h1.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\res\\重伤.png"));
                            if (read["sgtype"].ToString().Trim() == "轻伤")
                                h1.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\res\\轻伤.png"));
                            if (read["sgtype"].ToString().Trim() == "无伤")
                            {
                                BitmapImage u11 = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\res\\无伤.png"));
                                h1.Source = u11;
                                h1.Width = u11.Width;
                                h1.Height = u11.Height;
                            }
                            h1.Stretch = Stretch.Fill;
 
 
                            h1.Tag = read["number"].ToString() + ";" + u1.MPoint.X.ToString() + ";" + u1.MPoint.Y.ToString();
                            u1.UIObject = h1;
                            y1.Add(u1);
                        }
                    }
                    read.Close();
                  
                    return y1;
                }
                read.Close();
                return null;
            }
            catch
            {
                read.Close();
                return null;
            }
 
 
 
 
        }

The above method mainly obtains user data within a range from the center point returned by the interface, and creates different UIs based on the user's attributes.

This is a different vehicle icon displayed according to the vehicle type. It can also display some statistical data like the following:

You can give full play to the advantages of WPF in UI and make beautiful labels

When the UI display is completed, you can also call:

 /// <summary>
        /// Update the UI object in the user layer
        a>         public bool UpdateUserObject(string Layes, string ID, Point NewPoint, double Angle, FrameworkElement NewUI, bool Ami = true)         returns>         /// <param name="Ami">Whether it is animated</param>         /// <param name="NewUI">New UI</param> ;         / // <param name="Angle">New Angle</param>         /// <param name="NewPoint">New latitude and longitude</param>         /// <param name="ID" >User level ID</param>
        /// <param name="Layes">User layer name</param>






The interface updates the existing UI to achieve dynamic vehicle effects like Didi Taxi. This interface is only useful for existing UIs.
————————————————

Guess you like

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