Ejemplo n.º 1
0
        private VehcShape GetVehcShape(double vehrType_)
        {
            if (_vehcShape.ContainsKey(vehrType_))
            {
                return(_vehcShape[vehrType_]);
            }

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

            SQL += " and FvehicType = ";
            SQL += vehrType_.ToString();
            OleDbDataReader dataReader = _easyAccess.ExecuteDataReader(SQL);

            VehcShape shape = new VehcShape();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    shape.width     = Convert.ToDouble(dataReader.GetValue(Constant.VEH_WIDTH).ToString());
                    shape.length    = Convert.ToDouble(dataReader.GetValue(Constant.VEH_LENGTH).ToString());
                    shape.rightSide = Convert.ToDouble(dataReader.GetValue(Constant.VEH_RIGHT_SIDE).ToString());
                    shape.leftSide  = Convert.ToDouble(dataReader.GetValue(Constant.VEH_LEFT_SIDE).ToString());
                    shape.front     = Convert.ToDouble(dataReader.GetValue(Constant.VEH_FRONT).ToString());
                    _vehcShape.Add(vehrType_, shape);
                    return(shape);
                }
            }
            shape.width     = 3;
            shape.length    = 4;
            shape.rightSide = 0.5;
            shape.leftSide  = 0.5;
            shape.front     = 3;
            return(shape);
        }
Ejemplo n.º 2
0
        private double ComputeVolume(double vicNur_, double startTime_, double endTime_, double buttonX_, double topX_, double buttonY_, double topY_)
        {
            Point innerButton = new Point();
            Point innerTop    = new Point();
            Point outerButton = new Point();
            Point outerTop    = new Point();

            bool haveOuterTop    = false;
            bool haveOuterButton = false;

            double vecType = 0;

            //获得内边界点
            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 += " and t < ";
            SQL += endTime_.ToString();
            SQL += " and t >= ";
            SQL += startTime_.ToString();
            SQL += " and WorldX <= " + topX_.ToString();
            SQL += " and WorldX > " + buttonX_.ToString();
            SQL += " and WorldY <= " + topY_.ToString();
            SQL += " and WorldY > " + buttonY_.ToString();
            SQL += " and vehNr = " + vicNur_.ToString() + " order by t";

            OleDbDataReader dataReader = _easyAccess.ExecuteDataReader(SQL);

            if (dataReader.HasRows)
            {
                bool flag = true;
                while (dataReader.Read())
                {
                    if (flag)
                    {
                        innerButton.x = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_X).ToString());
                        innerButton.y = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_Y).ToString());
                        innerButton.z = Convert.ToDouble(dataReader.GetValue(Constant.T).ToString());

                        innerTop.x = innerButton.x;
                        innerTop.y = innerButton.y;
                        innerTop.z = innerButton.z;

                        vecType = Convert.ToDouble(dataReader.GetValue(Constant.TYPE).ToString());
                        flag    = false;
                    }
                    else
                    {
                        innerTop.x = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_X).ToString());
                        innerTop.y = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_Y).ToString());
                        innerTop.z = Convert.ToDouble(dataReader.GetValue(Constant.T).ToString());
                    }
                }
            }

            //获得上外边界点
            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 += innerTop.z.ToString();
            SQL += " and vehNr = " + vicNur_.ToString() + " order by t";

            dataReader = _easyAccess.ExecuteDataReader(SQL);

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    outerTop.x   = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_X).ToString());
                    outerTop.y   = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_Y).ToString());
                    outerTop.z   = Convert.ToDouble(dataReader.GetValue(Constant.T).ToString());
                    haveOuterTop = true;
                    break;
                }
            }

            //获得下外边界点
            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 += innerButton.z.ToString();
            SQL += " and vehNr = " + vicNur_.ToString() + " order by t desc";

            dataReader = _easyAccess.ExecuteDataReader(SQL);

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    outerButton.x   = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_X).ToString());
                    outerButton.y   = Convert.ToDouble(dataReader.GetValue(Constant.WORLD_Y).ToString());
                    outerButton.z   = Convert.ToDouble(dataReader.GetValue(Constant.T).ToString());
                    haveOuterButton = true;
                    break;
                }
            }

            //计算顶部离体时间
            double Li  = 0;
            double Lio = 0;
            double T   = 0;
            double Tio = 0;

            double Tty = -1;
            double Tby = -1;
            double Ttx = -1;
            double Tbx = -1;

            if ((outerTop.x < topX_ && outerTop.x > buttonX_ && outerTop.y < topY_ && outerTop.y > buttonY_) || !haveOuterTop)
            {
                T = endTime_ - innerTop.z;
            }
            else
            {
                Li  = topY_ - innerTop.y;
                Lio = outerTop.y - innerTop.y;
                Tio = outerTop.z - innerTop.z;
                if (Lio > 0.01)
                {
                    Tty = Li * Tio / Lio;
                }

                Li  = innerTop.y - buttonY_;
                Lio = innerTop.y - outerTop.y;
                Tio = outerTop.z - innerTop.z;
                if (Lio > 0.01)
                {
                    Tby = Li * Tio / Lio;
                }

                Li  = topX_ - innerTop.x;
                Lio = outerTop.x - innerTop.x;
                Tio = outerTop.z - innerTop.z;
                if (Lio > 0.01)
                {
                    Ttx = Li * Tio / Lio;
                }

                Li  = innerTop.x - buttonX_;
                Lio = innerTop.x - outerTop.x;
                Tio = outerTop.z - innerTop.z;
                if (Lio > 0.01)
                {
                    Tbx = Li * Tio / Lio;
                }

                if (Ttx > 0)
                {
                    T = Ttx;
                }
                else if (Tbx > 0)
                {
                    T = Tbx;
                }
                else if (Tty > 0)
                {
                    T = Tty;
                }
                else if (Tby > 0)
                {
                    T = Tby;
                }

                if (Tbx < T && Tbx > 0)
                {
                    T = Tbx;
                }
                if (Tby < T && Tby > 0)
                {
                    T = Tby;
                }
                if (Ttx < T && Ttx > 0)
                {
                    T = Ttx;
                }
                if (Tty < T && Tty > 0)
                {
                    T = Tty;
                }
            }
            double Tt = innerTop.z + T;

            if (Tt > endTime_)
            {
                Tt = endTime_;
            }

            //获取底部离体时间
            if ((outerButton.x < topX_ && outerButton.x > buttonX_ && outerButton.y < topY_ && outerButton.y > buttonY_) || !haveOuterButton)
            {
                T = innerButton.z - startTime_;
            }
            else
            {
                Li  = topY_ - innerButton.y;
                Lio = outerButton.y - innerButton.y;
                Tio = innerButton.z - outerButton.z;
                if (Lio > 0.01)
                {
                    Tty = Li * Tio / Lio;
                }

                Li  = innerButton.y - buttonY_;
                Lio = innerButton.y - outerButton.y;

                if (Lio > 0.01)
                {
                    Tby = Li * Tio / Lio;
                }

                Li  = topX_ - innerButton.x;
                Lio = outerButton.x - innerButton.x;

                if (Lio > 0.01)
                {
                    Ttx = Li * Tio / Lio;
                }

                Li  = innerButton.x - buttonX_;
                Lio = innerButton.x - outerButton.x;

                if (Lio > 0.01)
                {
                    Tbx = Li * Tio / Lio;
                }

                if (Ttx > 0)
                {
                    T = Ttx;
                }
                else if (Tbx > 0)
                {
                    T = Tbx;
                }
                else if (Tty > 0)
                {
                    T = Tty;
                }
                else if (Tby > 0)
                {
                    T = Tby;
                }

                if (Tbx < T && Tbx > 0)
                {
                    T = Tbx;
                }
                if (Tby < T && Tby > 0)
                {
                    T = Tby;
                }
                if (Ttx < T && Ttx > 0)
                {
                    T = Ttx;
                }
                if (Tty < T && Tty > 0)
                {
                    T = Tty;
                }
            }
            double Tb = innerButton.z - T;

            if (Tb < startTime_)
            {
                Tb = startTime_;
            }

            VehcShape shape = GetVehcShape(vecType);

            return((Tt - Tb) * shape.length * shape.width);
        }
Ejemplo n.º 3
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);
        }