Пример #1
0
        private void initData()
        {
            for (int i = 0; i < OgicPnts.Count; i++)
            {
                TrackPntInfo tPntInfo = new TrackPntInfo();
                if (i <= 60)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 0, i);
                }
                else if (i <= 120 && i > 60)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 1, i - 60);
                }
                else if (i <= 180 && i > 120)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 2, i - 120);
                }
                else if (i <= 240 && i > 180)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 3, i - 180);
                }
                else if (i <= 300 && i > 240)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 3, i - 240);
                }
                else if (i <= 300 && i > 360)
                {
                    tPntInfo.GetPntTime = new DateTime(2011, 4, 1, 0, 3, i - 300);
                }
                Point pnt = new Point();
                pnt.X             = OgicPnts[i].X;
                pnt.Y             = OgicPnts[i].Y;
                tPntInfo.LocalPnt = pnt;
                trackTimePnts.Add(tPntInfo);
            }
            // 对trackPnt按时间进行排序,时间早的点排在前
            trackTimePnts.Sort();

            GetAllPntsOnLine(trackTimePnts);
        }
Пример #2
0
        /// <summary>
        /// 为了在调用SORT时,按时间的先后顺序排序
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            int res = 0;

            try
            {
                TrackPntInfo sObj = (TrackPntInfo)obj;
                if (this.getPntTime.CompareTo(sObj.getPntTime) > 0)
                {
                    res = 1;
                }
                else if (this.getPntTime.CompareTo(sObj.getPntTime) < 0)
                {
                    res = -1;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("排序异常", ex.InnerException);
            }
            return(res);
        }