Пример #1
0
        private Point GenerateFirstLocation(VehcileInfo info_)
        {
            _fistFlag = true;
            Point  p      = new Point(info_.worldX - _centralPoint.x, info_.worldY - _centralPoint.y, info_.t - _startTime);
            Point  rst    = new Point();
            double offset = 10;

            if (Math.Abs(p.x) >= Math.Abs(p.y))
            {
                if (p.x > 0)
                {
                    rst.x = p.x + offset;
                }
                else
                {
                    rst.x = p.x - offset;
                }
            }
            else
            {
                if (p.y > 0)
                {
                    rst.y = p.y + offset;
                }
                else
                {
                    rst.y = p.y - offset;
                }
            }
            return(rst);
        }
Пример #2
0
        private bool IsRemain(VehcileInfo info_)
        {
            if (!_cutFlag)
            {
                return(true);
            }
            bool  rst = true;
            Point c0  = new Point();
            Point c1  = new Point();
            Point c2  = new Point();
            Point c3  = new Point();
            int   i   = 0;

            if (info_.worldX > 100)
            {
                Console.WriteLine("");
            }
            else if (info_.worldX > 50)
            {
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("");
            }
            foreach (Point p in _cutPoints)
            {
                if (i % 4 == 3)
                {
                    c3  = p;
                    rst = (rst && IsRemain(new Point(info_.worldX, info_.worldY, info_.t), c0, c1, c2, c3));
                }
                else
                {
                    switch (i % 4)
                    {
                    case 0:
                        c0 = p;
                        break;

                    case 1:
                        c1 = p;
                        break;

                    case 2:
                        c2 = p;
                        break;
                    }
                }
                i++;
            }
            return(rst);
        }
Пример #3
0
        public List <VehcileInfo> GetVehcInfo(double vehNr_)
        {
            List <VehcileInfo> lVehcInfo = new List <VehcileInfo>();



            string SQL = "select * from data530_VEH_RECORD where 1=1 ";

            SQL += GenerateQuaSQL_VEHICLE_DEC().Length != 0 ? " and " + GenerateQuaSQL_VEHICLE_DEC() + " " : " ";
            SQL += GenerateQuaSQL(1).Length != 0 ? " and " + GenerateQuaSQL(1) + " " : " ";
            SQL += GenerateQuaSQL(2).Length != 0 ? " and " + GenerateQuaSQL(2) + " " : " ";
            SQL += GenerateQuaSQL(3).Length != 0 ? " and " + GenerateQuaSQL(3) + " " : " ";

            SQL += " and t < ";
            SQL += _endTime.ToString();
            SQL += " and t >= ";
            SQL += _startTime.ToString();
            SQL += " and VehNr = ";
            SQL += vehNr_.ToString();

            OleDbDataReader dataReader = _easyAccess.ExecuteDataReader(SQL);

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    VehcileInfo info = new VehcileInfo();
                    info.vehNr       = Convert.ToDouble(dataReader.GetValue(Constant.VEH_NR).ToString());
                    info.type        = Convert.ToDouble(dataReader.GetValue(Constant.TYPE).ToString());
                    info.vehTypeName = dataReader.GetValue(Constant.VEH_TYPE_NAME).ToString();
                    info.worldX      = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_X).ToString());
                    info.worldY      = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_Y).ToString());
                    info.t           = Convert.ToDouble(dataReader.GetValue(Constant.T).ToString());
                    info.vMS         = Convert.ToDouble(dataReader.GetValue(Constant.V_MS).ToString());
                    info.link        = Convert.ToDouble(dataReader.GetValue(Constant.LINK).ToString());
                    info.lane        = Convert.ToDouble(dataReader.GetValue(Constant.LANE).ToString());
                    info.tQDelay     = Convert.ToDouble(dataReader.GetValue(Constant.TQ_DELAY).ToString());
                    info.route       = Convert.ToDouble(dataReader.GetValue(Constant.ROUTE).ToString());
                    info.routDec     = Convert.ToDouble(dataReader.GetValue(Constant.ROUTE_DEC).ToString());
                    if (IsRemain(info))
                    {
                        lVehcInfo.Add(info);
                    }
                }
            }
            return(lVehcInfo);
        }
Пример #4
0
        private Surface GetSurface(VehcileInfo info_, ref Point preLocation_)
        {
            Surface   s       = new Surface();
            double    xOffset = 0;
            double    yOffset = 0;
            VehcShape shape   = GetVehcShape(info_.type);
            Point     PL      = preLocation_;
            Point     NL      = new Point(info_.worldX - _centralPoint.x, info_.worldY - _centralPoint.y, info_.t - _startTime);

            if (PL.x != NL.x || PL.y != NL.y)
            {
                preLocation_ = NL;
            }
            else
            {
                _lastSurface.p1.z = NL.z;
                _lastSurface.p2.z = NL.z;
                _lastSurface.p3.z = NL.z;
                _lastSurface.p4.z = NL.z;

                Surface rst = new Surface();
                rst.p1.x = _lastSurface.p1.x;
                rst.p1.y = _lastSurface.p1.y;
                rst.p1.z = _lastSurface.p1.z;


                rst.p2.x = _lastSurface.p2.x;
                rst.p2.y = _lastSurface.p2.y;
                rst.p2.z = _lastSurface.p2.z;


                rst.p3.x = _lastSurface.p3.x;
                rst.p3.y = _lastSurface.p3.y;
                rst.p3.z = _lastSurface.p3.z;


                rst.p4.x = _lastSurface.p4.x;
                rst.p4.y = _lastSurface.p4.y;
                rst.p4.z = _lastSurface.p4.z;


                return(rst);
            }


            double L1 = shape.width / 2;
            double L2 = Math.Abs(Math.Sqrt((NL.x - PL.x) * (NL.x - PL.x) + (NL.y - PL.y) * (NL.y - PL.y)));
            double e  = Math.Abs(NL.x - PL.x);

            yOffset = L1 * e / L2;

            if (L1 > yOffset) //部分情况,由于数据的原因可能导致yOffset微大于L1,此时应当为0;
            {
                xOffset = Math.Abs(Math.Sqrt(L1 * L1 - yOffset * yOffset));
            }
            else
            {
                xOffset = 0;
            }

            /*
             * if(PL.x != NL.x)
             * {
             *  double slope = (NL.y - PL.y)/(NL.x - PL.x);
             *  yOffset = Math.Abs(Math.Sqrt(shape.width/(2*(1+slope*slope))));
             *  xOffset = Math.Abs(slope*yOffset);
             * }
             * else
             * {
             *  xOffset = shape.width/2;
             * }
             * */


            //计算柱体的高度
            double height = _maxheight;

            if (info_.vMS != 0)
            {
                height = (shape.length / info_.vMS);
            }

            //计算车长与两点距离比
            double coefficient = 0;
            double length      = Math.Sqrt((NL.x - PL.x) * (NL.x - PL.x) + (NL.y - PL.y) * (NL.y - PL.y));

            coefficient = shape.length / length;



            //柱体的底面到Z=0平面距离为时间t
            s.p1.x = NL.y > PL.y ? NL.x - xOffset : NL.x + xOffset;
            s.p1.y = NL.x > PL.x ? NL.y + yOffset : NL.y - yOffset;
            s.p1.z = NL.z;



            s.p2.x = NL.y > PL.y ? NL.x + xOffset : NL.x - xOffset;
            s.p2.y = NL.x > PL.x ? NL.y - yOffset : NL.y + yOffset;
            s.p2.z = NL.z;

            s.p3.x = s.p2.x - (NL.x - PL.x) * coefficient;
            s.p3.y = s.p2.y - (NL.y - PL.y) * coefficient;
            s.p3.z = NL.z;

            s.p4.x = s.p1.x - (NL.x - PL.x) * coefficient;
            s.p4.y = s.p1.y - (NL.y - PL.y) * coefficient;
            s.p4.z = NL.z;

            if (_fistFlag)
            {
                s.p3.x = s.p2.x;
                s.p3.y = s.p2.y;
                s.p3.z = s.p2.z;

                s.p4.x    = s.p1.x;
                s.p4.y    = s.p1.y;
                s.p4.z    = s.p1.z;
                _fistFlag = false;
            }

            double tmp1 = (s.p1.x - s.p2.x) * (s.p1.x - s.p2.x) + (s.p1.y - s.p2.y) * (s.p1.y - s.p2.y);
            double tmp2 = (s.p1.x - s.p4.x) * (s.p1.x - s.p4.x) + (s.p1.y - s.p4.y) * (s.p1.y - s.p4.y);

            _lastSurface.p1.x = s.p1.x;
            _lastSurface.p1.y = s.p1.y;
            _lastSurface.p1.z = s.p1.z;

            _lastSurface.p2.x = s.p2.x;
            _lastSurface.p2.y = s.p2.y;
            _lastSurface.p2.z = s.p2.z;

            _lastSurface.p3.x = s.p3.x;
            _lastSurface.p3.y = s.p3.y;
            _lastSurface.p3.z = s.p3.z;

            _lastSurface.p4.x = s.p4.x;
            _lastSurface.p4.y = s.p4.y;
            _lastSurface.p4.z = s.p4.z;


            return(s);
        }