private void SaveORGPLocation(string placeid, MapPointEx mappoint) { PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.PersonSchedule.I_CO_IA_PersonSchedule>(channel => { channel.SavePP_OrgInfoLocation(OrgInfo.GUID, mappoint.X.ToString(), mappoint.Y.ToString()); }); }
private void UpdateVehicle(KeyValuePair <string, Point> item) { if (idDic.ContainsKey(item.Key)) { string groupid = idDic[item.Key]; var group = Obj.screenMap.DrawElementList.Where(o => MapGroupTypes.MonitorGroup_.ToString() + groupid == o.Key).ToArray(); if (group != null && group.Length == 1) { Obj.screenMap.MainMap.Dispatcher.BeginInvoke(new Action(() => { OrgToMapStyle orgPoint = group[0].Value as OrgToMapStyle; if (orgPoint != null) { if (orgPoint.ElementTag != null && orgPoint.ElementTag is MapPointEx) { MapPointEx p = orgPoint.ElementTag as MapPointEx; if (p.X != item.Value.X || p.Y != item.Value.Y) { //移动位置 Obj.screenMap.RemoveElement(MapGroupTypes.MonitorGroup_.ToString() + groupid); Obj.screenMap.AddElement(orgPoint, Obj.screenMap.GetMapPointEx(item.Value.X, item.Value.Y)); } } } })); } } }
/// <summary> /// 判断指定位置是否在指定范围内 /// </summary> /// <param name="pExtent">范围</param> /// <param name="pPoint">位置</param> /// <returns>true - 在该范围</returns> public static bool ContainsPoint(MapExtent pExtent, MapPointEx pPoint) { return(pPoint.X >= pExtent.XY1.X && pPoint.Y <= pExtent.XY1.Y && pPoint.X <= pExtent.XY2.X && pPoint.Y >= pExtent.XY2.Y); }
private void DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { double left = this.Margin.Left + e.HorizontalChange; if (left < 0) { left = 0; } if (left > _mapGis.MainMap.ActualWidth - 10) { left = _mapGis.MainMap.ActualWidth - 10; } double top = this.Margin.Top + e.VerticalChange; if (top < 0) { top = 0; } if (top > _mapGis.MainMap.ActualHeight - 10) { top = _mapGis.MainMap.ActualHeight - 10; } this.Margin = new Thickness(left, top, 0, 0); MapPointEx point = _mapGis.MainMap.ScreenToMap(new PointEx(left, top)); if (OnLocationMove != null) { OnLocationMove(point); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="pJson">Json对象</param> public MapTileInfo(JObject pJson) { Width = pJson["rows"].Value <int>(); Height = pJson["cols"].Value <int>(); Dpi = pJson["dpi"].Value <int>(); Format = pJson["format"].Value <string>(); JObject origin = pJson["origin"].Value <JObject>(); Origin = new MapPointEx(origin["x"].Value <double>(), origin["y"].Value <double>()); JToken reference = pJson["spatialReference"].Value <JObject>()["wkid"]; if (reference == null) { reference = pJson["spatialReference"].Value <JObject>()["wkt"]; } SpatialReference = reference.Value <string>(); if (string.IsNullOrWhiteSpace(SpatialReference)) { throw new Exception("地图服务配置错误,缺少“空间参考”数据。"); } JArray lods = pJson["lods"].Value <JArray>(); List <LodInfo> lodList = (from JObject lod in lods select new LodInfo(lod)).ToList(); Lods = lodList; }
private void DrawStation(List <ActivitySurroundStation> stations) { Obj.screenMap.ClearStation(); Obj.screenMap.SetCluster(true); foreach (ActivitySurroundStation station in stations) { MapPointEx point = Obj.screenMap.MainMap.MapPointFactory.Create(station.STAT_LG, station.STAT_LA); Obj.screenMap.DrawStationPoint(point, true, station); } }
//private void LocationFix(object sender, RoutedEventArgs e) //{ // ActivityPlaceLocation delLocation = dg_LocationList.SelectedItem as ActivityPlaceLocation; // if (delLocation != null) // { // Obj.screenMap.setExtent(new AT_BC.Data.GeoPoint() { Longitude = delLocation.LocationLG, Latitude = delLocation.LocationLA }); // } //} private void DataGridRow_MouseDoubleClick(object sender, RoutedEventArgs e) { ActivityPlaceLocation delLocation = dg_LocationList.SelectedItem as ActivityPlaceLocation; if (delLocation != null) { MapPointEx p = Obj.screenMap.MainMap.MapPointFactory.Create(delLocation.LocationLG, delLocation.LocationLA); Obj.screenMap.setExtent(p); Obj.screenMap.SelectPointShine(p); } }
private MapPlace GetMapPlace(PP_OrgInfo OrgInfo, MapPointEx point) { //MapPlace place = placeMap.ShowMap.DrawElementList.FirstOrDefault(r => r.Key == OrgInfo.GUID).Value as MapPlace; //if (place == null) //{ // place = new MapPlace(); // place.BeforeDragPlaceEvent += OnBeforeDragPlace; // //place.DeletePlaceEvent += place_DeletePlaceEvent; //} //place.ORGinfo = OrgInfo; //place.MapPoint = point; //return place; return(null); }
private void UpdatePerson(KeyValuePair <string, Point> item) { //根据对象ID找组 if (idDic.ContainsKey(item.Key)) { string groupid = idDic[item.Key]; var person = Obj.screenMap.DrawElementList.Where(o => MapGroupTypes.Person_.ToString() + item.Key == o.Key).ToArray(); if (person != null && person.Length == 1) { Obj.screenMap.MainMap.Dispatcher.BeginInvoke(new Action(() => { //修改位置 PersonPoint personPoint = person[0].Value as PersonPoint; if (personPoint != null) { if (personPoint.ElementTag != null && personPoint.ElementTag is MapPointEx) { MapPointEx p = personPoint.ElementTag as MapPointEx; if (p.X != item.Value.X || p.Y != item.Value.Y) { //移动位置 Obj.screenMap.RemoveElement(MapGroupTypes.Person_.ToString() + item.Key); Obj.screenMap.AddElement(personPoint, Obj.screenMap.GetMapPointEx(item.Value.X, item.Value.Y)); } } } })); } else { //添加 var group = Obj.screenMap.DrawElementList.Where(o => MapGroupTypes.MonitorGroup_.ToString() + groupid == o.Key).ToArray(); if (group != null && group.Length == 1) { Obj.screenMap.MainMap.Dispatcher.BeginInvoke(new Action(() => { OrgToMapStyle orgPoint = group[0].Value as OrgToMapStyle; PP_OrgInfo orginfo = orgPoint.OrgInfo; PersonPoint personPoint = new PersonPoint(orginfo, ObjDic[item.Key] as PP_PersonInfo); personPoint.ContextMenu = GetContextMenu(); Obj.screenMap.AddElement(personPoint, Obj.screenMap.GetMapPointEx(item.Value.X, item.Value.Y)); })); } } } }
public void GetRadomXY(MapPointEx pointBegin, MapPointEx pointEnd, out double x, out double y, Random random = null) { if (random == null) { random = new Random(); } x = 0; y = 0; int xStepCount = 50; int yStepCount = 30; double xoffset = pointEnd.X - pointBegin.X; double yoffset = pointBegin.Y - pointEnd.Y; double xStep = xoffset * 1.0 / xStepCount; double yStep = yoffset * 1.0 / yStepCount; x = pointBegin.X + xStep * 1.0 * random.Next(xStepCount); y = pointEnd.Y + yStep * 1.0 * random.Next(yStepCount); }
public void AddPoint(MapPointEx point) { if (points.Count == 0) { mapLayer.DrawPoint(point, new I_GS_MapBase.Portal.SymbolElement("track") { ControlTemplate = Obj.screenMap.MainMap.Resources["TrackBegin"], }); } else { DrawLine(new MapPointEx[] { points[points.Count-1],point}); } points.Add(point); DrawClose(point); }
private void MainMap_Drop(object sender, DragEventArgs e) { if (OrgInfo != null) { Point scpoint = e.GetPosition(this); MapPointEx currentmappoint = ActivityMap.ShowMap.MainMap.ScreenToMap(new PointEx(scpoint.X, scpoint.Y)); string placeid = ActivityMap.GetMouseLocationPlaceID(currentmappoint.X, currentmappoint.Y); if (string.IsNullOrEmpty(placeid)) { MessageBoxResult msgresult = MessageBox.Show("当前地点不是活动区域,是否手动选择地点?", "提示", MessageBoxButton.YesNo); if (msgresult == MessageBoxResult.Yes) { SelectPlaceDialog selectplace = new SelectPlaceDialog(); selectplace.WindowStartupLocation = WindowStartupLocation.CenterScreen; selectplace.SelectedPlaceChangeEvent += (currentplaceId) => { ActivityMap.CurrentPlaceId = currentplaceId; }; selectplace.SelectedPlaceEvent += (placeguid) => { placeid = placeguid; ActivityMap.CurrentPlaceId = null; }; selectplace.ShowDialog(this); } } MapPlace place = ActivityMap.ShowMap.DrawElementList.FirstOrDefault(r => r.Key == OrgInfo.GUID).Value as MapPlace; if (place == null) { place = new MapPlace(); place.BeforeDragPlaceEvent += OnBeforeDragPlace; place.DeletePlaceEvent += place_DeletePlaceEvent; } place.ORGinfo = OrgInfo; place.PlaceGuid = placeid; place.MapPoint = currentmappoint; SaveORGPLocation(placeid, currentmappoint); DrawORGToMap(place, currentmappoint); } }
private void LocationItem_Click(object sender, RoutedEventArgs e) { if (tv_PersonPlan.SelectedItem != null) { PP_OrgInfo orginfo = tv_PersonPlan.SelectedItem as PP_OrgInfo; if (orginfo != null) { var org = Obj.screenMap.DrawElementList.Where(item => item.Key == MapGroupTypes.MonitorGroup_.ToString() + orginfo.GUID).ToArray(); if (org != null && org.Length == 1) { OrgToMapStyle orgPoint = org[0].Value as OrgToMapStyle; if (orgPoint != null) { MapPointEx p = orgPoint.ElementTag as MapPointEx; if (p != null) { Obj.screenMap.setExtent(p); } } } } } }
private void LoadJH(MapExtent extent) { Obj.screenMap.ClearHaveStation(); if (_fixedPoint.X == 0) { _fixedPoint.X = extent.Xy1.X; _fixedPoint.Y = extent.Xy1.Y; } List <double[]> list = getJHParam(new double[] { extent.Xy1.X, extent.Xy1.Y }, new double[] { extent.Xy2.X, extent.Xy2.Y }, 50, new double[] { _fixedPoint.X, _fixedPoint.Y }); JHCondition jhCon = new JHCondition() { Range = list[0], xInterval = list[1][0], yInterval = list[1][1], CC = list[2][0], LotdOffset = list[2][1] }; List <JHStation> stationList = PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.Display.I_CO_IA_Display, List <JHStation> >(channel => { return(channel.GetStationToJH(jhCon)); }); if (stationList != null && stationList.Count > 0) { for (int i = 0; i < stationList.Count; i++) { double x = 0; double y = 0; if (double.TryParse(stationList[i].STAT_LG, out x) && double.TryParse(stationList[i].STAT_LA, out y)) { //if (x != 0 && y != 0) //{ // double[] p = I_GS_MapBase.Portal.CoordOffset.transform(x, y);//进行坐标校正 // x = p[1]; // y = p[0]; //} } if (x == 0 || y == 0) { continue; } MapPointEx point = Obj.screenMap.MainMap.MapPointFactory.Create(x, y); int statCount = Convert.ToInt32(stationList[i].CO); if (statCount == 1) { Obj.screenMap.DrawStationPoint(point, true, stationList[i], Obj.screenMap.HaveStationLayer); } else { double size = 0; if (statCount < 10) { size = 22; } else if (statCount < 50) { size = 24; } else if (statCount < 100) { size = 27; } else if (statCount < 200) { size = 30; } else if (statCount < 1000) { size = 33; } else { size = 37; } Obj.screenMap.DrawPoint(point, new I_GS_MapBase.Portal.SymbolElement("stationCluser") { ControlTemplate = Obj.screenMap.MainMap.Resources["ClustererSymbol"] as ControlTemplate, DataSources = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Count", statCount.ToString()), new KeyValuePair <string, object>("Size", size), new KeyValuePair <string, object>("Color", ClustererInterpolateColor(size - 12, 100)), new KeyValuePair <string, object>("Range", new string[] { stationList[i].XMin, stationList[i].YMax, stationList[i].XMax, stationList[i].YMin }), } }, Obj.screenMap.HaveStationLayer); } } } }
private void DrawClose(MapPointEx point) { mapLayer.AddSlElement(closeButton,point); }
/// <summary> /// 根据屏幕范围获得网格信息 /// </summary> /// <param name="p_leftTopPoint"></param> /// <param name="p_rightBottomPoint"></param> /// <param name="p_intervalValue"></param> /// <param name="p_fixedPoint"></param> /// <returns>返回大网格范围,和经纬度的网格步长,存储格式double[4],double[2] public List <double[]> getJHParam(double[] p_leftTopPoint, double[] p_rightBottomPoint, double p_intervalValue, double[] p_fixedPoint = null) { if (p_fixedPoint != null) { FixedPoint = new double[] { p_fixedPoint[0], p_fixedPoint[1] }; } if (FixedPoint == null) { FixedPoint = new double[] { p_leftTopPoint[0], p_leftTopPoint[1] }; } PointEx pBase = Utils.MapFun.MainMap.MapToScreen(Utils.MapFun.MainMap.MapPointFactory.Create(FixedPoint[0], FixedPoint[1])); double xInterval = 0, yInterval = 0; PointEx pBase1 = new PointEx(pBase.X + p_intervalValue, pBase.Y); MapPointEx p1 = Utils.MapFun.MainMap.ScreenToMap(pBase1); xInterval = Math.Abs(p1.X - FixedPoint[0]); PointEx pBase2 = new PointEx(pBase.X, pBase.Y + p_intervalValue); MapPointEx p2 = Utils.MapFun.MainMap.ScreenToMap(pBase2); yInterval = Math.Abs(p2.Y - FixedPoint[1]); double x1 = FixedPoint[0]; if (x1 > p_leftTopPoint[0]) { while (x1 > p_leftTopPoint[0]) { x1 -= xInterval; } } else { while (x1 < p_leftTopPoint[0]) { x1 += xInterval; } } int cc = 0; double y1 = FixedPoint[1]; if (y1 > p_leftTopPoint[1]) { while (y1 > p_leftTopPoint[1]) { y1 -= yInterval; cc++; if (cc == 4) { cc = 0; } } } else { cc = 4; while (y1 < p_leftTopPoint[1]) { y1 += yInterval; cc--; if (cc < 0) { cc = 4; } } } if (cc == 4) { cc = 0; } double x2 = FixedPoint[0]; if (x2 > p_rightBottomPoint[0]) { while (x2 > p_rightBottomPoint[0]) { x2 -= xInterval; } } else { while (x2 < p_rightBottomPoint[0]) { x2 += xInterval; } } double loOffset = Math.Abs(((FixedPoint[0] - x2) % (xInterval / 3)) * (xInterval / 3)); double y2 = FixedPoint[1]; if (y2 > p_rightBottomPoint[1]) { while (y2 > p_rightBottomPoint[1]) { y2 -= yInterval; } } else { while (y2 < p_rightBottomPoint[1]) { y2 += yInterval; } } List <double[]> lst = new List <double[]>(); double[] xy2 = new double[4] { x1, y1, x2, y2 }; lst.Add(xy2);//存储范围坐标 double[] wh = new double[2] { xInterval, yInterval }; lst.Add(wh);//存储经纬度步长,单位度 double[] firstOffsetIndex = new double[] { cc, loOffset }; lst.Add(firstOffsetIndex); return(lst); }
private void DrawORGToMap(MapPlace place, MapPointEx mappoint) { //placeMap.ShowMap.AddElement(place, placeMap.ShowMap.GetMapPointEx(mappoint.X, mappoint.Y)); }
private void DrawORGToMap(MapPlace place, MapPointEx mappoint) { ActivityMap.ShowMap.RemoveElement(place.ElementId); ActivityMap.ShowMap.AddElement(place, ActivityMap.ShowMap.GetMapPointEx(mappoint.X, mappoint.Y)); }