Example #1
0
        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);
        }
Example #2
0
        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");
        }