/* * 航线box * */ void frm_changebox12_event(Boolean selected, int flag) { if (selected || (2 == flag && airRoute == true)) { airRoute = true; airRouteOverlay.Clear(); this.gMapControl1.Overlays.Add(airRouteOverlay); //获取最新的航段、航站点 List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT DISTINCT Name FROM AirRoute WHERE Show = '是'"); foreach (Dictionary <string, object> dictionary in result) { String name = Convert.ToString(dictionary["Name"]); if (!string.IsNullOrEmpty(name)) { List <Dictionary <string, object> > resultSub = ProfileHelper.Instance.Select("SELECT * FROM AirRoute WHERE Name = '" + name + "'"); List <PointLatLng> points = new List <PointLatLng>(); if (null != resultSub && resultSub.Count > 0) { // 找出机场起点 PointLatLng p = geAirPorttByName(Convert.ToString(resultSub[0]["PointBegin"])); points.Add(p); } // 找出中间点 List <Dictionary <string, object> > resultRouteWayPoint = ProfileHelper.Instance.Select("SELECT * FROM RouteWayPoint WHERE PortId = '" + name + "'"); foreach (Dictionary <string, object> dictionarySub in resultRouteWayPoint) { String beginWayPoint = Convert.ToString(dictionarySub["WayPoint"]); GMapWayPoint wayPoint = getGMapWayPointByName(beginWayPoint); points.Add(wayPoint.Position); } if (null != resultSub && resultSub.Count > 0) { // 找出机场终点 PointLatLng p = geAirPorttByName(Convert.ToString(resultSub[0]["PointEnd"])); points.Add(p); } GMapRoute r = new GMapRoute(points, ""); r.Stroke = new Pen(Color.Red, 1); airRouteOverlay.Routes.Add(r); } } gMapControl1.Refresh(); } else { if (1 == flag) { airRoute = false; airRouteOverlay.Clear(); this.gMapControl1.Overlays.Remove(airRouteOverlay); gMapControl1.Refresh(); } } }
/** * 根据航站点名称获得航站点信息 * */ private GMapWayPoint getGMapWayPointByName(String name) { List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM WayPoint WHERE Name = '" + name + "'"); double lat = Convert.ToDouble(result[0]["Lat"]); double lang = Convert.ToDouble(result[0]["Lng"]); GMapWayPoint way_Point = new GMapWayPoint(new PointLatLng(lat, lang), name); return(way_Point); }
/* * 航段box * */ void frm_changebox3_event(Boolean selected, int flag) { if (selected || (2 == flag && airSegment == true)) { airSegment = true; airSegmentOverlay.Clear(); this.gMapControl1.Overlays.Add(airSegmentOverlay); //获取最新的航段、航站点 listAirSegment = new List <GMapAirSegment>(); List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM AirSegment"); foreach (Dictionary <string, object> dictionary in result) { String name = Convert.ToString(dictionary["Name"]); String beginWayPoint = Convert.ToString(dictionary["BeginWayPoint"]); GMapWayPoint begin = getGMapWayPointByName(beginWayPoint); String endWayPoint = Convert.ToString(dictionary["EndWayPoint"]); GMapWayPoint end = getGMapWayPointByName(endWayPoint); GMapAirSegment airSegment = new GMapAirSegment(name, begin, end); listAirSegment.Add(airSegment); } foreach (GMapAirSegment airSegmentl in listAirSegment) { List <PointLatLng> points = new List <PointLatLng>(); points.Add(airSegmentl.pStart.Position); points.Add(airSegmentl.pEnd.Position); GMapPolygon polygon = new GMapPolygon(points, airSegmentl.name); polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red)); polygon.Stroke = new Pen(Color.Red, 1); airSegmentOverlay.Polygons.Add(polygon); } gMapControl1.Refresh(); } else { if (1 == flag) { airSegment = false; airSegmentOverlay.Clear(); this.gMapControl1.Overlays.Remove(airSegmentOverlay); gMapControl1.Refresh(); } } }
/* * 航站点box * */ void frm_changebox5_event(Boolean selected, int flag) { if (selected || (2 == flag && wayPoint == true)) { wayPoint = true; wayPointOverlay.Clear(); this.gMapControl1.Overlays.Add(wayPointOverlay); listWayPoint = new List <GMapWayPoint>(); List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM WayPoint"); foreach (Dictionary <string, object> dictionary in result) { String name = Convert.ToString(dictionary["Name"]); double lat = Convert.ToDouble(dictionary["Lat"]); double lang = Convert.ToDouble(dictionary["Lng"]); PointLatLng point = new PointLatLng(lat, lang); GMapWayPoint gMapWayPoint = new GMapWayPoint(point, name); listWayPoint.Add(gMapWayPoint); } foreach (GMapWayPoint wayPoint in listWayPoint) { wayPointOverlay.Markers.Add(wayPoint); } gMapControl1.Refresh(); } else { if (1 == flag) { wayPoint = false; wayPointOverlay.Clear(); this.gMapControl1.Overlays.Remove(wayPointOverlay); gMapControl1.Refresh(); } } }
public GMapAirSegment(String name, GMapWayPoint pStart, GMapWayPoint pEnd) { this.name = name; this.pStart = pStart; this.pEnd = pEnd; }