//private LocationCollection mulitLoc(LocationCollection locvol) //{ // LocationCollection templc1=locvol; // int count = locvol.Count; // for (int i = 0; i < count-1; i++) // { // if (0 < i && i < count-6) // { // double x = (templc1.ElementAt(i + 1).Longitude - templc1.ElementAt(i).Longitude) / 5; // double y = (templc1.ElementAt(i + 1).Latitude - templc1.ElementAt(i).Latitude) / 5; // if (Math.Abs(x)>0.00001||Math.Abs(y)>0.00001) // { // for (int m = 1; m < 5; m++) // { // Location loc = new Location(); // loc.Latitude = templc1.ElementAt(i).Latitude + m * y; // loc.Longitude = templc1.ElementAt(i).Longitude + m * x; // if ((i + (i-1) * 4 )<locvol.Count-1) // { // locvol.Insert(i + (i - 1) * 4, loc); // } // } // } // } // } // return locvol; //} //定时去获取路径 private void Dtimer_Completed(object sender, EventArgs e) { //if (cbxCar.IsChecked == true) //{ CustomPushpin cp = GetCarByMSID("car", carml); if (cp != null) { GetBegionRoad(cp.Location.Latitude, cp.Location.Longitude, 100); isgetloc = true; timer.Stop(); } //} //else //{ // DraggablePushpin dp = GetDCarByMSID("drapcar", carml); // if (dp != null) // { // GetBeginPoint(dp.Location.Latitude, dp.Location.Longitude, 100); // } //} //if (isrealroadupdated==true) //{ Dtimer.Begin(); //} }
private void DtimerCompleted(object sender, EventArgs e) { var c = GetCarByName("car", MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer); if (c != null && _beginNum == 0) { GetBeginPoint((c.Geometry as CustomMapPoint).Y, (c.Geometry as CustomMapPoint).X, 100); } if (_beginNum != 0) { dt1 = DateTime.Now; //fcarloc.Clear(); var cmp = GetCarByName("car", MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer); //foreach (var trigger in carloc.Where(trigger => trigger.Node==cmp.Node)) //{ // fcarloc.Add(trigger); //} if (cmp.Node != 0) { GetRouting("routing", cmp.Node, _lastNum); } } if (_isupdatelength == false) { Dtimer.Begin(); } }
void rsc_updateLengthCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { isrealroadupdated = true; Dtimer.Begin(); realwms.Visibility = Visibility.Collapsed; //getrouting("routing", begin, last); }
public void UpdateLength() { _isupdatelength = true; Dtimer.Stop(); var rsc = new RoutingWebServiceSoapClient(); rsc.updateLengthCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(RscUpdateLengthCompleted); rsc.updateLengthAsync(); }
private void CarBeginRun() { var c = GetCarByName("car", MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer); if (c != null) { //MessageBox.Show(dt1.ToString()); GetBeginPoint((c.Geometry as CustomMapPoint).Y, (c.Geometry as CustomMapPoint).X, 100); } Dtimer.Begin(); Ltimer.Begin(); }
private void initiate(System.Windows.Forms.Timer[] Clock) { for (int i = 0; i < 5; i++) { Clock[i].Interval = TimeSlice; //Clock[i].Tick+= new EventHandler(Clock_Tick); Clock[i].Enabled = true; Clock[i].Start(); } Dtimer.Interval = TimeSlice / 2; Dtimer.Enabled = true; Dtimer.Start(); }
private void ctlMap_MouseClick(object sender, MapMouseEventArgs e) { if (isbegin == true) { BaseGeometry bg = GetItemByID("routing", "begin"); if (bg != null) { LayerReset(); } var data = new ObservableCollection <VectorLayerData>(); var point = new Point(ctlMap.ViewportPointToLocation(e.ViewportPoint).Longitude, ctlMap.ViewportPointToLocation(e.ViewportPoint).Latitude); data.Add(new VectorLayerData { Geo = point.AsBinary(), ID = "begin", Label = "起点", }); layer.Add(data); isbegin = false; } if (islast == true) { var data = new ObservableCollection <VectorLayerData>(); var point = new Point(ctlMap.ViewportPointToLocation(e.ViewportPoint).Longitude, ctlMap.ViewportPointToLocation(e.ViewportPoint).Latitude); data.Add(new VectorLayerData { Geo = point.AsBinary(), ID = "last", Label = "终点", }); layer.Add(data); DraggablePushpin dp = GetDCarByMSID("drapcar", carml); if (dp != null) { GetBegionRoad(dp.Location.Latitude, dp.Location.Longitude, 100); } Dtimer.Begin(); Ltimer.Begin(); islast = false; } if (isbarrier == true) { //初始化一个图标 var data = new ObservableCollection <VectorLayerData>(); var point = new Point(ctlMap.ViewportPointToLocation(e.ViewportPoint).Longitude, ctlMap.ViewportPointToLocation(e.ViewportPoint).Latitude); GetBarrier(point.X, point.Y, 30); data.Add(new VectorLayerData { Geo = point.AsBinary(), ID = "barrier", Label = "障碍" + bn.ToString(), }); layer.Add(data); isbarrier = false; bn++; } }
void RscGetRoutingCompleted(object sender, GetRoutingCompletedEventArgs e) { if (e.Result.Count() == 0) { Dtimer.Stop(); timer.Stop(); Ltimer.Stop(); return; } carloc.Clear(); _cari = 0; var lineLayer = MyMap.Layers["MyLineLayer"] as GraphicsLayer; if (lineLayer != null) { lineLayer.ClearGraphics(); } var builder = new StringBuilder(); if (e.Error == null) { Color color = Colors.Blue; for (int i = 0; i < e.Result.Count; i++) { string[] strArray = e.Result[i].Split(new char[] { ';' }); builder.Length = 0; int index = 2; while (index < (strArray.Length - 1)) { builder.Append(strArray[index] + ": "); index++; } string[] strArray2 = strArray[strArray.Length - 1].Split(new char[] { ',' }); string[] strArrayPoints = strArray[strArray.Length - 2].Split(new char[] { ',' }); int beginNode = int.Parse(strArray[3]); if (i == 0) { otmpFirstArrays = strArrayPoints; } if ((strArray2.Length == 1) && (strArray2[0].Length > 1)) { //面 } else { var locations = new ESRI.ArcGIS.Client.Geometry.PointCollection(); CustomMapPoint location2; CustomMapPoint locPoint; if (strArray2[0].Equals(strArray2[strArray2.Length - 1])) { } else { var polyline = new ESRI.ArcGIS.Client.Geometry.Polyline(); for (index = strArray2.Length - 1; index >= 0; index--) { location2 = new CustomMapPoint( double.Parse(strArray2[index].Split(new char[] { ' ' })[1]), double.Parse(strArray2[index].Split(new char[] { ' ' })[0])) { Node = beginNode }; locations.Add(location2); } //添加坐标到小车轨迹 if (fcarloc.Count > 0) { //取出轨迹数据的第一个点 var floc1 = new CustomMapPoint(double.Parse(otmpFirstArrays[0].Split(new char[] { ' ' })[1]), double.Parse(otmpFirstArrays[0].Split(new char[] { ' ' })[0])); var ffloc1 = fcarloc.ElementAt(0); var loc1 = new CustomMapPoint(double.Parse(strArrayPoints[0].Split(new char[] { ' ' })[1]), double.Parse(strArrayPoints[0].Split(new char[] { ' ' })[0])); var loc2 = new CustomMapPoint(double.Parse(strArrayPoints[strArrayPoints.Length - 1].Split(new char[] { ' ' })[1]), double.Parse(strArrayPoints[strArrayPoints.Length - 1].Split(new char[] { ' ' })[0])); CustomMapPoint oPoint = GetCarByName("car", MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer).Geometry as CustomMapPoint; if (i == 0) { //当前车辆不在在轨迹上 if (!IsInLine(oPoint, otmpFirstArrays)) { //调节车辆最后所在轨迹段顺序 if (!Isclost(ffloc1, loc1, 0.0001) && !Isclost(ffloc1, loc2, 0.0001)) { for (index = 0; index < fcarloc.Count - 1; index++) { var tmoloc = fcarloc.ElementAt(index); carloc.Add(tmoloc); } } else { for (index = fcarloc.Count - 1; index >= 0; index--) { var tmoloc1 = fcarloc.ElementAt(index); carloc.Add(tmoloc1); } } } } if (i == 1) { //调节第一段轨迹段顺序 if (!Isclost(floc1, loc1, 0.00001) && !Isclost(floc1, loc2, 0.00001)) { for (index = 0; index < otmpFirstArrays.Length - 1; index++) { var tmoloc = new CustomMapPoint( double.Parse(otmpFirstArrays[index].Split(new char[] { ' ' })[1]), double.Parse(otmpFirstArrays[index].Split(new char[] { ' ' })[0])) { Node = beginNode }; carloc.Add(tmoloc); } } else { for (index = otmpFirstArrays.Length - 1; index >= 0; index--) { var tmoloc1 = new CustomMapPoint( double.Parse(otmpFirstArrays[index].Split(new char[] { ' ' })[1]), double.Parse(otmpFirstArrays[index].Split(new char[] { ' ' })[0])) { Node = beginNode }; carloc.Add(tmoloc1); } } OrderPoints(strArrayPoints, carloc.ElementAt(carloc.Count - 1), loc1, loc2, beginNode); } if (i > 1) { OrderPoints(strArrayPoints, carloc.ElementAt(carloc.Count - 1), loc1, loc2, beginNode); } } polyline.Paths.Add(locations); if (lineLayer != null) { lineLayer.Graphics.Add(new Graphic() { Geometry = polyline, Symbol = DefaultLineSymbol }); } } } } } CustomMapPoint c = GetCarByName("car", MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer).Geometry as CustomMapPoint; for (int i = 0; i < carloc.Count - 1; i++) { var item = carloc.ElementAt(i); if (Isclost(c, item, 0.0001)) { for (int y = 0; y < i + 2; y++) { if (carloc.Count > y + 1) { carloc.RemoveAt(0); } } } } _isgetlocing = false; timer.Begin(); }
void RscUpdateLengthCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { _isupdatelength = false; Dtimer.Begin(); }