Beispiel #1
0
        public void addDynamicLine()
        {
            string hhh = "";

            if (!File.Exists(FileName))
            {
                return;
            }
            FileStream   fs   = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            StreamReader sr   = new StreamReader(fs);
            string       info = sr.ReadToEnd();

            fs.Close();
            string[] infos = info.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            int      index = 0;

            lstPoint.Clear();

            double[] trans    = new double[2];
            string[] strPoint = new string[2];
            foreach (string point in infos)
            {
                strPoint = point.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (strPoint.Length < 3)
                {
                    continue;
                }
                if (double.TryParse(strPoint[1], out trans[0]) && double.TryParse(strPoint[2], out trans[1]))
                {
                    ClsCPoint p = new ClsCPoint();
                    p.PointID  = index;
                    trans      = cTrans.WGS84_BD09(trans[1], trans[0]);
                    p.PointLng = trans[0];
                    p.PointLat = trans[1];
                    //hhh += p.PointLng.ToString() + " " + p.PointLat.ToString() + "\r\n";
                    p.enumBadType = EnumBadType.其他;
                    lstPoint.Add(p);
                    index++;
                }
            }
            //string hhh = "";
            #region  取800个点,后期注释
            lstPoint800.Clear();
            int jump = (int)(lstPoint.Count / 800);
            for (int i = 0; i < lstPoint.Count; i += jump)
            {
                lstPoint800.Add(lstPoint[i]);
            }
            int    ranDom = 0;
            int    len    = lstPoint800.Count - 800;
            Random rDom   = new Random();
            for (int i = 0; i < len; i++)
            {
                ranDom = rDom.Next(0, lstPoint800.Count);
                lstPoint800.RemoveAt(ranDom);
            }
            for (int i = 0; i < 100 * index1; i++)
            {
                lstPoint800[i].PointID = i;
                hhh += lstPoint800[i].PointLng.ToString() + " " + lstPoint800[i].PointLat.ToString() + "\r\n";
            }
            Random rDom1 = new Random();
            for (int i = 0; i < 10; i++)
            {
                lstPoint800[rDom1.Next(200, 600)].enumBadType = EnumBadType.路面车辙;
                lstPoint800[rDom1.Next(200, 600)].enumBadType = EnumBadType.路面破损;
            }
            //hhh = "";
            #endregion
            this.webBrowser1.Document.InvokeScript("initMap");
            this.webBrowser1.Document.InvokeScript("addLine", new object[] { hhh });
        }
Beispiel #2
0
        ClsOrdinateTrans cTrans = new ClsOrdinateTrans();//坐标转换
        //public string hhh = "";
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                button13.Text     = "隐藏航迹";
                button9.Text      = "显示所有航迹";
                btn_ShowRuts.Text = "显示车辙";
                button7.Text      = "显示破损";
                string hhh = "";
                if (!File.Exists(FileName))
                {
                    return;
                }
                FileStream   fs   = new FileStream(FileName, FileMode.Open, FileAccess.Read);
                StreamReader sr   = new StreamReader(fs);
                string       info = sr.ReadToEnd();
                fs.Close();
                string[] infos = info.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int      index = 0;
                lstPoint.Clear();

                double[] trans = new double[2];
                string[] strPoint = new string[2];
                double   X = 0, Y = 0;
                foreach (string point in infos)
                {
                    strPoint = point.Split(new String[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                    if (strPoint.Length < 3)
                    {
                        continue;
                    }
                    if (X == 0)
                    {
                        X = Convert.ToDouble(strPoint[0]);
                        Y = Convert.ToDouble(strPoint[1]);
                    }
                    if (double.TryParse(strPoint[0], out trans[0]) && double.TryParse(strPoint[1], out trans[1]))
                    {
                        ClsCPoint p = new ClsCPoint();
                        p.PointID  = index;
                        trans      = cTrans.WGS84_BD09(trans[1], trans[0]);
                        p.PointLng = trans[0];
                        p.PointLat = trans[1];
                        //hhh += p.PointLng.ToString() + " " + p.PointLat.ToString() + "\r\n";
                        p.enumBadType = EnumBadType.其他;
                        lstPoint.Add(p);
                        index++;
                    }
                }
                //string hhh = "";
                #region  取800个点,后期注释
                lstPoint800.Clear();
                int jump = (int)(lstPoint.Count / 800);
                for (int i = 0; i < lstPoint.Count; i += jump)
                {
                    lstPoint800.Add(lstPoint[i]);
                }
                int    ranDom = 0;
                int    len    = lstPoint800.Count - 800;
                Random rDom   = new Random();
                for (int i = 0; i < len; i++)
                {
                    ranDom = rDom.Next(0, lstPoint800.Count);
                    lstPoint800.RemoveAt(ranDom);
                }
                for (int i = 0; i < 800; i++)
                {
                    lstPoint800[i].PointID = i;
                    hhh += lstPoint800[i].PointLng.ToString() + " " + lstPoint800[i].PointLat.ToString() + "\r\n";
                }
                Random rDom1 = new Random();
                for (int i = 0; i < 10; i++)
                {
                    lstPoint800[rDom1.Next(200, 600)].enumBadType = EnumBadType.路面车辙;
                    lstPoint800[rDom1.Next(200, 600)].enumBadType = EnumBadType.路面破损;
                }
                //hhh = "";
                #endregion
                //this.webBrowser1.Document.InvokeScript("setZoom(point)",Point);
                this.webBrowser1.Document.InvokeScript("CenterAndZoom", new object[] { X, Y });
                this.webBrowser1.Document.InvokeScript("initMap");
                this.webBrowser1.Document.InvokeScript("addLine", new object[] { hhh });
            }
            catch (Exception)
            { }
        }