Esempio n. 1
0
        private void getStartPositionByFp(out Data.PathStartPoint2 startPosition, Model.FastonPosition fp1)
        {
            double startX, startY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp1.Longitude, fp1.Latitde, out startX, out startY);
            startPosition = new Data.PathStartPoint2()
            {
                x = Convert.ToInt32(startX * 256),
                y = Convert.ToInt32(startY * 256)
            };
        }
Esempio n. 2
0
        /// <summary>
        /// 获取路径
        /// </summary>
        /// <param name="dataResult">路径</param>
        /// <param name="fpLast">起始点</param>
        /// <param name="speed">速度</param>
        /// <param name="result">ref path的结果。</param>
        /// <param name="startT">ref 时间结果</param>
        internal void GetAFromBPoint(List <OssModel.MapGo.nyrqPosition> dataResult, OssModel.FastonPosition fpLast, int speed, ref List <PathResult> result, ref int startT)
        {
            for (var i = 0; i < dataResult.Count; i++)
            {
                if (i == 0)
                {
                    //var startX = result.Last().x1;
                    //var startY = result.Last().y1;
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fpLast.positionLongitudeOnRoad, fpLast.positionLatitudeOnRoad, out startX, out startY);

                    //var length=

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fpLast.positionLatitudeOnRoad, fpLast.positionLongitudeOnRoad, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);
                    var animate1  = new Data.PathResult()
                    {
                        t0 = startT + 0,
                        x0 = startX,
                        y0 = startY,
                        t1 = startT + interview,
                        x1 = endX,
                        y1 = endY
                    };
                    startT += interview;
                    result.Add(animate1);
                }
                else if (dataResult[i].roadCode == dataResult[i - 1].roadCode)
                {
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i - 1].BDlongitude, dataResult[i - 1].BDlatitude, out startX, out startY);

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);

                    // var length = CommonClass.Geography.getLengthOfTwoPoint.
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(dataResult[i - 1].BDlatitude, dataResult[i - 1].BDlongitude, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);
                    var animate1  = new Data.PathResult()
                    {
                        t0 = startT + 0,
                        x0 = startX,
                        y0 = startY,
                        t1 = startT + interview,
                        x1 = endX,
                        y1 = endY
                    };
                    startT += interview;
                    result.Add(animate1);
                }
            }
        }
Esempio n. 3
0
        public List <OssModel.MapGo.nyrqPosition> GetAFromB(OssModel.FastonPosition fpStart, string fpID2)
        {
            //  throw new Exception("");
            // var dt1 = DateTime.Now;
            FindF.DataToNavigateWithTimeFunction2 data = new FindF.DataToNavigateWithTimeFunction2();
            data.ReadRoadInfo(this._road, this._allFp);
            // bool findObjSuccess;
            var dataResult = data.FindPlace(fpStart, fpID2);

            return(dataResult);
            //var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataResult);
            //// Console.WriteLine(json);
            //// var dt2 = DateTime.Now;
            ////Console.WriteLine($"计算时间{(dt2 - dt1).TotalSeconds}");
            //return json;
        }
Esempio n. 4
0
 public bool theNearestToPlayerIsCarNotMoney(RoleInGame player, Car car, RoleInGame victim, out OssModel.FastonPosition fp)
 {
     return(theNearestToObjIsCarNotMoney(player, car, victim, out fp));
 }
Esempio n. 5
0
        bool theNearestToObjIsCarNotMoney(RoleInGame player, Car car, interfaceOfHM.GetFPIndex getF, out OssModel.FastonPosition fp)
        {
            fp = null;
            if (car.state == CarState.waitAtBaseStation)
            {
                double distanceToDiamond;
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                {
                    var fpTo = Program.dt.GetFpByIndex(player.StartFPIndex);; //this.GetPromotePositionTo(pType);

                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    //  var from = Program.dt.GetFpByIndex(player.StartFPIndex);
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        distanceToDiamond = distanceToMoney;
                        fp = fpTo;
                        //  return false;
                    }
                }
                return(fp == null);
            }
            else if (car.state == CarState.waitOnRoad)
            {
                var    from = Program.dt.GetFpByIndex(getF.GetFPIndex());
                double distanceToDiamond;
                {
                    var fpTo = Program.dt.GetFpByIndex(car.targetFpIndex);
                    distanceToDiamond = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                }
                foreach (var item in this._collectPosition)
                {
                    var fpTo            = Program.dt.GetFpByIndex(item.Value);
                    var distanceToMoney = CommonClass.Geography.getLengthOfTwoPoint.GetDistance(from.Latitde, from.Longitude, fpTo.Latitde, fpTo.Longitude);
                    if (distanceToMoney <= distanceToDiamond)
                    {
                        distanceToDiamond = distanceToMoney;
                        fp = fpTo;
                    }
                }
                return(fp == null);
            }
            else
            {
                throw new Exception("非法调用");
            }
        }
Esempio n. 6
0
 public bool theNearestToDiamondIsCarNotMoney(RoleInGame player, Car car, string pType, out OssModel.FastonPosition fp)
 {
     return(theNearestToObjIsCarNotMoney(player, car, new PromoteObj(pType), out fp));
 }
Esempio n. 7
0
        public void getEndPositon(Model.FastonPosition fp, int initPosition, ref List <int> animateResult, ref int startTInput, bool speedImproved)
        {
            if (initPosition > 5)
            {
                initPosition = initPosition % 5;
            }
            double endX, endY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.Longitude, fp.Latitde, out endX, out endY);
            int startT1;

            double startX, startY;

            CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.positionLongitudeOnRoad, fp.positionLatitudeOnRoad, out startX, out startY);
            int endT1;

            //这里要考虑前台坐标系(左手坐标系)。
            var cc = new Complex(startX - endX, (-startY) - (-endY));

            cc = ToOne(cc);

            var     positon1 = cc * (new Complex(-0.309016994, 0.951056516));
            var     positon2 = positon1 * (new Complex(0.809016994, 0.587785252));
            var     positon3 = positon2 * (new Complex(0.809016994, 0.587785252));
            var     positon4 = positon3 * (new Complex(0.809016994, 0.587785252));
            var     positon5 = positon4 * (new Complex(0.809016994, 0.587785252));
            Complex position;

            switch (initPosition)
            {
            case 0:
            {
                position = positon1;
            }; break;

            case 1:
            {
                position = positon2;
            }; break;

            case 2:
            {
                position = positon3;
            }; break;

            case 3:
            {
                position = positon4;
            }; break;

            case 4:
            {
                position = positon5;
            }; break;

            default:
            {
                position = positon1;
            }; break;
            }
            var    percentOfPosition = 0.25;
            double carPositionX      = endX + position.Real * percentOfPosition;
            double carPositionY      = endY - position.Imaginary * percentOfPosition;


            /*
             * 这里由于是返程,为了与getStartPositon 中的命名保持一致性,(位置上)end实际为start,时间上还保持一致
             */
            //  List<Data.PathResult> animateResult = new List<Data.PathResult>();

            /*
             * 上道路的速度为10m/s 即36km/h
             */
            var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fp.Latitde, fp.Longitude, fp.positionLatitudeOnRoad, fp.positionLongitudeOnRoad) / 10 * 1000);

            interview    = this.magicE.shotTime(interview, speedImproved);
            startT1      = startTInput;
            endT1        = startT1 + interview;
            startTInput += interview;
            var animate2 = new Data.PathResult3()
            {
                x = Convert.ToInt32((endX - startX) * 256),
                y = Convert.ToInt32((endY - startY) * 256),
                t = interview
            };

            //var animate2 = new Data.PathResult()
            //{
            //    t0 = startT1,
            //    x0 = startX,
            //    y0 = startY,
            //    t1 = endT1,
            //    x1 = endX,
            //    y1 = endY
            //};
            //animateResult.Add(animate2);
            if (animate2.t != 0)
            {
                animateResult.Add(animate2.x);
                animateResult.Add(animate2.y);
                animateResult.Add(animate2.t);
            }

            //  startT0 = startTInput;
            //    endT0 = startT0 + 500;
            startTInput += this.magicE.shotTime(500, speedImproved);

            var animate1 = new Data.PathResult3()
            {
                x = Convert.ToInt32((carPositionX - endX) * 256),
                y = Convert.ToInt32((carPositionY - endY) * 256),
                t = this.magicE.shotTime(500, speedImproved)
            };

            //var animate1 = new Data.PathResult()
            //{
            //    t0 = startT0,
            //    x0 = endX,
            //    y0 = endY,
            //    t1 = endT0,
            //    x1 = carPositionX,
            //    y1 = carPositionY
            //};
            //  animateResult.Add(animate1);
            if (animate1.t != 0)
            {
                animateResult.Add(animate1.x);
                animateResult.Add(animate1.y);
                animateResult.Add(animate1.t);
            }
        }
Esempio n. 8
0
        //public class PathResult
        //{
        //    public double x0 { get; set; }
        //    public double y0 { get; set; }
        //    public int t0 { get; set; }

        //    public double x1 { get; set; }
        //    public double y1 { get; set; }
        //    public int t1 { get; set; }
        //}

        /// <summary>
        /// 获取路径
        /// </summary>
        /// <param name="dataResult">路径</param>
        /// <param name="fpLast">起始点</param>
        /// <param name="speed">速度</param>
        /// <param name="result">ref path的结果。</param>
        /// <param name="startT">ref 时间结果</param>
        internal void GetAFromBPoint(List <OssModel.MapGo.nyrqPosition> dataResult, OssModel.FastonPosition fpLast, int speed, ref List <int> result, ref int startT)
        {
            for (var i = 0; i < dataResult.Count; i++)
            {
                if (i == 0)
                {
                    //var startX = result.Last().x1;
                    //var startY = result.Last().y1;
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fpLast.positionLongitudeOnRoad, fpLast.positionLatitudeOnRoad, out startX, out startY);

                    //var length=

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fpLast.positionLatitudeOnRoad, fpLast.positionLongitudeOnRoad, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);


                    if (result.Count == 0)
                    {
                        var animate0 = new PathResult3()
                        {
                            t = startT,
                            x = 0,
                            y = 0
                        };
                        if (animate0.t != 0)
                        {
                            result.Add(animate0.x);
                            result.Add(animate0.y);
                            result.Add(animate0.t);
                        }
                        // result.Add(animate0);
                    }
                    var animate1 = new PathResult3()
                    {
                        t = interview,
                        x = Convert.ToInt32((endX - startX) * 256),
                        y = Convert.ToInt32((endY - startY) * 256),
                    };
                    if (animate1.t != 0)
                    {
                        result.Add(animate1.x);
                        result.Add(animate1.y);
                        result.Add(animate1.t);
                    }
                    //result.Add(animate1);
                    //var animate1 = new Data.PathResult()
                    //{
                    //    t0 = startT + 0,
                    //    x0 = startX,
                    //    y0 = startY,
                    //    t1 = startT + interview,
                    //    x1 = endX,
                    //    y1 = endY
                    //};
                    startT += interview;
                    // result.Add(animate1);
                }
                else if (dataResult[i].roadCode == dataResult[i - 1].roadCode)
                {
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i - 1].BDlongitude, dataResult[i - 1].BDlatitude, out startX, out startY);

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);

                    // var length = CommonClass.Geography.getLengthOfTwoPoint.
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(dataResult[i - 1].BDlatitude, dataResult[i - 1].BDlongitude, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);

                    var animate1 = new Data.PathResult3()
                    {
                        x = Convert.ToInt32((endX - startX) * 256),
                        y = Convert.ToInt32((endY - startY) * 256),
                        t = interview
                    };
                    //var animate1 = new Data.PathResult()
                    //{
                    //    t0 = startT + 0,
                    //    x0 = startX,
                    //    y0 = startY,
                    //    t1 = startT + interview,
                    //    x1 = endX,
                    //    y1 = endY
                    //};
                    startT += interview;
                    if (animate1.t != 0)
                    {
                        result.Add(animate1.x);
                        result.Add(animate1.y);
                        result.Add(animate1.t);
                    }
                    // result.Add(animate1);
                }
            }
        }
Esempio n. 9
0
        internal void GetAFromBPoint(string fpID1, string fpID2, int speed, ref List <PathResult> result, ref int startT)
        {
            //throw new Exception("");
            // var dt1 = DateTime.Now;
            FindF.DataToNavigateWithTimeFunction2 data = new FindF.DataToNavigateWithTimeFunction2();
            data.ReadRoadInfo(this._road, this._allFp);
            bool findObjSuccess;

            OssModel.FastonPosition fpLast = this._allFp.FindLast(item => item.FastenPositionID == fpID1);
            var dataResult = data.FindPlace(fpLast, fpID2, out findObjSuccess);

            //   List<PathResult> animateResult = new List<PathResult>();
            //    double sumCostTime = 0;
            for (var i = 0; i < dataResult.Count; i++)
            {
                if (i == 0)
                {
                    //var startX = result.Last().x1;
                    //var startY = result.Last().y1;
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fpLast.positionLongitudeOnRoad, fpLast.positionLatitudeOnRoad, out startX, out startY);

                    //var length=

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(fpLast.positionLatitudeOnRoad, fpLast.positionLongitudeOnRoad, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);
                    var animate1  = new Data.PathResult()
                    {
                        t0 = startT + 0,
                        x0 = startX,
                        y0 = startY,
                        t1 = startT + interview,
                        x1 = endX,
                        y1 = endY
                    };
                    startT += interview;
                    result.Add(animate1);
                }
                else if (dataResult[i].roadCode == dataResult[i - 1].roadCode)
                {
                    double startX, startY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i - 1].BDlongitude, dataResult[i - 1].BDlatitude, out startX, out startY);

                    double endX, endY;
                    CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(dataResult[i].BDlongitude, dataResult[i].BDlatitude, out endX, out endY);

                    // var length = CommonClass.Geography.getLengthOfTwoPoint.
                    //  var interview =
                    var interview = Convert.ToInt32(CommonClass.Geography.getLengthOfTwoPoint.GetDistance(dataResult[i - 1].BDlatitude, dataResult[i - 1].BDlongitude, dataResult[i].BDlatitude, dataResult[i].BDlongitude) / dataResult[i].maxSpeed * 3.6 / 20 * 1000 * 50 / speed);
                    var animate1  = new Data.PathResult()
                    {
                        t0 = startT + 0,
                        x0 = startX,
                        y0 = startY,
                        t1 = startT + interview,
                        x1 = endX,
                        y1 = endY
                    };
                    startT += interview;
                    result.Add(animate1);
                }
            }
        }