/// <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); } } }
private void getEndPositon(Model.FastonPosition fp, string car, ref List <Data.PathResult> animateResult, ref int startTInput) { double endX, endY; CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.Longitude, fp.Latitde, out endX, out endY); int startT0, startT1; double startX, startY; CommonClass.Geography.calculatBaideMercatorIndex.getBaiduPicIndex(fp.positionLongitudeOnRoad, fp.positionLatitudeOnRoad, out startX, out startY); int endT0, 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 (car) { case "carA": { position = positon1; }; break; case "carB": { position = positon2; }; break; case "carC": { position = positon3; }; break; case "carD": { position = positon4; }; break; case "carE": { 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); startT1 = startTInput; endT1 = startT1 + interview; startTInput += interview; var animate2 = new Data.PathResult() { t0 = startT1, x0 = startX, y0 = startY, t1 = endT1, x1 = endX, y1 = endY }; animateResult.Add(animate2); startT0 = startTInput; endT0 = startT0 + 500; startTInput += 500; var animate1 = new Data.PathResult() { t0 = startT0, x0 = endX, y0 = endY, t1 = endT0, x1 = carPositionX, y1 = carPositionY }; animateResult.Add(animate1); }
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); } } }