private void button6_Click(object sender, EventArgs e) { double scale = Convert.ToSingle(textBox3.Text); RunJSON runJSON = new RunJSON(new RunJSON.Position(0, 0)); runJSON.LoadGPX("map.gpx"); if (runJSON.PositionList.Count == 0) { return; } PointList.Clear(); PointList.Add(new Point(pictureBox1.Width / 2, pictureBox1.Height / 2)); textBox4.Text = runJSON.PositionList[0].Latitude.ToString(); textBox5.Text = runJSON.PositionList[0].Longitude.ToString(); foreach (RunJSON.Position p in runJSON.PositionList) { PointList.Add(PositionToPoint(runJSON.PositionList[0], PointList[0], p, scale)); } textBox2.Text = (runJSON.PositionList.Last().Time - runJSON.PositionList.First().Time).TotalSeconds.ToString(); label4.Text = "距离: " + runJSON.TotalDistance() + " 米"; pictureBox1.Refresh(); Draw(); }
private void button3_Click(object sender, EventArgs e) { double scale = Convert.ToSingle(textBox3.Text); RunJSON runJSON = new RunJSON(new RunJSON.Position(Convert.ToSingle(textBox4.Text), Convert.ToSingle(textBox5.Text))); foreach (Point p in PointList) { runJSON.AddPosition(PointToPosition(runJSON.PositionList[0], PointList[0], p, scale)); } runJSON.DistributeTimeSpan(TimeSpan.FromSeconds(Convert.ToSingle(textBox2.Text))); label4.Text = "距离: " + runJSON.TotalDistance() + " 米"; runJSON.WriteGPX("map.gpx"); }
public static RunPackage GenerateExecRunPackage(bool readgpx) { JArray tNode = (JArray)JsonConvert.DeserializeObject(tNodeArray); RunJSON runJSON = new RunJSON(new RunJSON.Position(Convert.ToDouble(tNode[0]["latitude"]), Convert.ToDouble(tNode[0]["longitude"]))); JArray bNode = (JArray)JsonConvert.DeserializeObject(bNodeArray); foreach (JObject bn in bNode) { runJSON.AddPosition(new RunJSON.Position(Convert.ToDouble(bn["position"]["latitude"]), Convert.ToDouble(bn["position"]["longitude"]))); } while (runJSON.TotalDistance() < 2000) { runJSON.AddPosition(new RunJSON.Position(runJSON.PositionList.Last().Latitude + 0.0001f, 0f)); } runJSON.DistributeTimeSpan(TimeSpan.FromMinutes(30), DateTime.Now); if (readgpx) { if (!runJSON.LoadGPX("map.gpx")) { Console.WriteLine("map.gpx不存在/有问题!回退至自动生成路径!"); } } string json = runJSON.ToJSON(runpgid, userid, bNodeArray, tNodeArray); string pkg = Json2Package.Create(json); RunPackage package = new RunPackage(); package.waittill = DateTime.Now + TimeSpan.FromMinutes(30); package.post = pkg; package.utoken = utoken; package.cookie = cookie.GetCookies(new Uri(API_ROOT))[0].Value; return(package); }