private void AddMultiGeometry(bool sky, KmlPlacemark placemark, float width, Color polyColor, Color lineColor, KmlMultiGeometry geo) { foreach (KmlGeometry childGeo in geo.Children) { if (childGeo is KmlPoint) { KmlPoint point = (KmlPoint)childGeo; placemark.Point = (KmlPoint)childGeo; AddPlacemark(placemark); } else if (childGeo is KmlLineList) { AddLines(sky, childGeo as KmlLineList, width, lineColor, lineColor, false); } else if (childGeo is KmlPolygon) { KmlPolygon child = (KmlPolygon)childGeo; if (child.OuterBoundary != null) { AddLines(sky, child.OuterBoundary as KmlLineList, width, polyColor, lineColor, child.extrude); // to do 3d work and subtract inner rings } } else if (childGeo is KmlMultiGeometry) { AddMultiGeometry(sky, placemark, width, polyColor, lineColor, childGeo as KmlMultiGeometry); } } }
public Point_ArcMap(AxMapControl _mapControl, KmlPoint point, FactoryArcMap _mapFactory) { this.mapControl = _mapControl; this.mapFactory = _mapFactory; Dosomething((Action)(delegate { IPoint pt = new PointClass(); pt.PutCoords(point.Position.Lng, point.Position.Lat); base.Geometry = pt; pMarkerSymbol = new SimpleMarkerSymbolClass(); IRgbColor color = new RgbColorClass() { Transparency = point.Color.A, Red = point.Color.R, Green = point.Color.G, Blue = point.Color.B }; bColor = point.Color; pMarkerSymbol.Color = color; pMarkerSymbol.Size = 5; pMarkerSymbol.Angle = 90; pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; base.Symbol = pMarkerSymbol; this.Description = point.Description; }), true); position = new MapLngLat(); position = point.Position;//目标位置 flashTimer = new Timer(); flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml.Position == null) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; //图元 Point_ArcGlobe pointElement = new Point_ArcGlobe(graphicsLayer, pointKml); this.Dosomething((Action) delegate() { IGlobeGraphicsElementProperties properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = pointKml.Rasterize; //栅格化 graphicsLayer.AddElement(pointElement, properties, out index); pointElement.Index = index; //指定索引 pointElement.ElementName = kml.Placemark.Name; }, true); return(pointElement); }
public static KmlGeometry[] ParseGeometryChildren(XElement xml, XmlNamespaceManager namespaces) { List <KmlGeometry> temp = new List <KmlGeometry>(); foreach (XElement element in xml.Elements()) { switch (element.Name.LocalName) { case "extrude": case "tessellate": case "altitudeMode": continue; case "Point": temp.Add(KmlPoint.Parse(element)); break; case "LineString": temp.Add(KmlLineString.Parse(element)); break; case "Polygon": temp.Add(KmlPolygon.Parse(element)); break; case "MultiGeometry": temp.Add(KmlMultiGeometry.Parse(element)); break; } } return(temp.ToArray()); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图标的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml == null) { return(null); } if (pointKml.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } PointIco_ArcMap pictureElement = new PointIco_ArcMap(mapControl, pointKml, mapFactory); pictureElement.ElementType = ElementTypeEnum.Picture; graphicLayer.AddElement(pictureElement, 0); return(pictureElement); }
public virtual GeoJsonPoint Convert(KmlPoint point) { double latitude = point.Coordinates.Latitude; double longitude = point.Coordinates.Longitude; double altitude = point.Coordinates.Altitude; return(new GeoJsonPoint(longitude, latitude, altitude)); }
public Point_Mgis(Kml kml) { KmlPoint kmlPoint = kml.Placemark.Graph as KmlPoint; if (kmlPoint.Position == null || kml.Placemark.Name == string.Empty) { return; } mapControl.MgsDrawDotByJBID(kml.Placemark.Name, 12, 0, 0, 0); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图元的kml对象</param> /// <param name="layerName">图层名称</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, string layerName) { KmlPoint kmlPoint = kml.Placemark.Graph as KmlPoint; if (kml.Placemark.Graph == null) { return(null); } Point_Mgis pointMgis = new Point_Mgis(kml); return(pointMgis); }
/// <summary> /// 构造函数,没传图片的情况,用GDI绘制点 /// </summary> /// <param name="pos">位置</param> /// <param name="point">点的kml对象</param> /// <param name="elementName">图元名称</param> public Point_GMap(PointLatLng pos, KmlPoint point, string elementName) : base(pos) { this.ElementName = elementName; this.Description = point.Description; this.ElementType = ElementTypeEnum.Point; // 鼠标经过可见 base.IsHitTestVisible = true; // 大小 if (point.Size == null) { base.Size = new Size(5, 5); } else { int width = point.Size.Width; int height = point.Size.Height; base.Size = new System.Drawing.Size(width, height); } // 画笔 m_HightLightPen = new Pen(Brushes.Green, 1); if (point.Color.ToArgb() == 0) { m_Pen = new Pen(Brushes.Blue, 2); } else { m_Pen = new Pen(point.Color, 2); } // 计时器 flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += flashTimer_Elapsed; flashTimer.Interval = 100; bIsFlash = false; base.Tag = this; }
public PlacemarkPoint(List <GpsPointData> gps, int idx, string iconStyleMapNameGreen, string iconStyleMapNameYellow, string iconStyleMapNameRed) : this() { TimeSpan duration = (gps[idx].FixTime - gps[0].FixTime); name = "Location: " + idx; description = string.Format("Point {0} from start", duration); styleUrl = "#" + PointColor(gps[idx], iconStyleMapNameGreen, iconStyleMapNameYellow, iconStyleMapNameRed); extendedData = new ExtendedData() { data = new ExtendedData.KmlData[] { new ExtendedData.KmlData() { name = "TimeStamp", value = gps[idx].FixTime.ToString() }, new ExtendedData.KmlData() { name = "Speed", value = gps[idx].SpeedMph.ToString("0.0 mph") }, new ExtendedData.KmlData() { name = "Heading", value = gps[idx].Course.ToString("0.0") }, new ExtendedData.KmlData() { name = "Lattitude", value = gps[idx].Latitude.ToString("0.000000") }, new ExtendedData.KmlData() { name = "Longtitude", value = gps[idx].Longitude.ToString("0.000000") } } }; point = new KmlPoint(gps[idx]); }
public void Add(KmlPoint point) { pointList.Add(point); }
/// <summary> /// 调用此方法 /// </summary> /// <param name="xmlname">xml名称</param> /// <param name="filename">导出文件名</param> /// <param name="lst">数据</param> /// <returns></returns> public static int CreateKml(string xmlname, string filename, List <dataFormat> lst) { List <KmlPlacemark> ls = new List <KmlPlacemark>(); foreach (dataFormat d in lst) { string type = d.type; string coords = d.coordinates.Trim(); string styleUrl = d.styleUrl; string name = d.name; if (string.IsNullOrEmpty(name)) { name = ""; } string description = d.description; if (string.IsNullOrEmpty(description)) { description = ""; } if (type == "point") { if (string.IsNullOrEmpty(styleUrl)) { styleUrl = "#downArrowIcon"; } KmlPoint p = new KmlPoint(coords); KmlPlacemark placemark = new KmlPlacemark(name, description, styleUrl, p, null, null); ls.Add(placemark); } else if (type == "line") { if (string.IsNullOrEmpty(styleUrl)) { styleUrl = "#blue"; } KmlLineString line = new KmlLineString(coords.Split(';').ToList()); KmlPlacemark placemark = new KmlPlacemark(name, description, styleUrl, null, line, null); ls.Add(placemark); } else if (type == "polygon") { if (string.IsNullOrEmpty(styleUrl)) { styleUrl = "#blue"; } KmlPolygon polygon = new KmlPolygon(coords.Split(';').ToList()); KmlPlacemark placemark = new KmlPlacemark(name, description, styleUrl, null, null, polygon); ls.Add(placemark); } } try { KmlDocument document = new KmlDocument(xmlname, filename, ls); Kml kml = new Kml(document); kml.GenerateKmlFile("a.kml"); return(1); } catch (Exception e) { return(0); } }
/// <summary> /// 添加图元 /// </summary> /// <param name="layerName">图层名称</param> /// <param name="kml">Kml对象</param> /// <returns></returns> public MapFrame.Core.Interface.IMFElement AddElement(string layerName, Core.Model.Kml kml) { if (kml == null) { return(null); } if (kml.Placemark == null) { return(null); } if (kml.Placemark.Graph == null) { return(null); } if (string.IsNullOrEmpty(kml.Placemark.Name)) { return(null); } var layer = lyMgr.GetLayer(layerName); if (layer == null) { return(null); } IElementFactory elementFactory = null; Type type = kml.Placemark.Graph.GetType(); // 点 if (type == typeof(KmlPoint)) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml == null) { return(null); } if (string.IsNullOrEmpty(pointKml.IcoUrl))//没有图标纯点 { elementFactory = pointFac; } else //有图标 { elementFactory = pointIcoFac; } } // 线 else if (type == typeof(KmlLineString)) { elementFactory = lineFac; } // 面 else if (type == typeof(KmlPolygon)) { elementFactory = polygonFac; } // 文字 else if (type == typeof(KmlText)) { elementFactory = textFac; } // 圆 else if (type == typeof(KmlCircle)) { elementFactory = circleFac; } if (elementFactory == null) { return(null); } MapFrame.Core.Interface.IMFElement element = elementFactory.CreateElement(kml, layer); if (element != null) { element.ElementName = kml.Placemark.Name; } Refresh(layer as Core.Interface.IMFLayer); return(element); }
public KmlPlacemark() { TimeStamp = new KmlTimeStamp(); Point = new KmlPoint(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphicsLayer">图层</param> /// <param name="pointKml">点kml</param> public Point_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlPoint pointKml) { graphicsLayer = _graphicsLayer; this.ElementType = Core.Model.ElementTypeEnum.Point; //图元类型 this.Description = pointKml.Description; //图元描述 #region 位置 IPoint pt = new PointClass(); pt.PutCoords(pointKml.Position.Lng, pointKml.Position.Lat); pt.Z = pointKml.Position.Alt; (pt as IZAware).ZAware = true;//设置高度 base.Geometry = pt; #endregion #region 符号 markerSymbol = new SimpleMarker3DSymbolClass(); //设置颜色 if (pointKml.Color.ToArgb() == 0) { IRgbColor color = new RgbColorClass() { Transparency = 50, Red = Color.Green.R, Green = Color.Green.G, Blue = Color.Green.B }; markerSymbol.Color = color; } else { IRgbColor color = new RgbColorClass() { Transparency = pointKml.Color.A, Red = pointKml.Color.R, Green = pointKml.Color.G, Blue = pointKml.Color.B }; markerSymbol.Color = color; } //设置大小 if (pointKml.Size.Height == 0) { markerSymbol.Size = 500; } else { markerSymbol.Size = pointKml.Size.Height; } markerSymbol.Angle = 90; markerSymbol.Style = (esriSimple3DMarkerStyle)pointKml.PointStyle; base.Symbol = markerSymbol; #endregion flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 3000; isFlash = false; }
/// <summary> /// 添加点图元 /// </summary> /// <param name="kml">kml对象</param> /// <param name="gmapOverlay">图层</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, GMapOverlay gmapOverlay) { KmlPoint point = kml.Placemark.Graph as KmlPoint; if (point == null) { return(null); } if (point.Position == null) { return(null); } PointLatLng p = new PointLatLng(point.Position.Lat, point.Position.Lng, point.Position.Alt); IMFElement element = null; // 位置和图标 Point_GMap pointElement = new Point_GMap(p, point, kml.Placemark.Name); // 大小 pointElement.Size = new Size(pointElement.Size.Width, pointElement.Size.Height); // Tip if (!string.IsNullOrEmpty(point.TipText)) { pointElement.ToolTipText = point.TipText; pointElement.ToolTipMode = MarkerTooltipMode.OnMouseOver; pointElement.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐 } element = pointElement; //if (string.IsNullOrEmpty(point.IcoUrl))//纯点 //{ // // 位置和图标 // Point_GMap pointElement = new Point_GMap(p, point, kml.Placemark.Name); // // 大小 // pointElement.Size = new Size(pointElement.Size.Width, pointElement.Size.Height); // // Tip // if (!string.IsNullOrEmpty(point.TipText)) // { // pointElement.ToolTipText = point.TipText; // pointElement.ToolTipMode = MarkerTooltipMode.OnMouseOver; // pointElement.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐 // } // element = pointElement; //} //else //目标点 //{ // Picture_GMap moveObj = new Picture_GMap(p, point, kml.Placemark.Name); // // Tip // if (!string.IsNullOrEmpty(point.TipText)) // { // moveObj.ToolTipText = point.TipText; // moveObj.ToolTipMode = MarkerTooltipMode.OnMouseOver; // moveObj.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐 // } // // 设置图元的类型 // moveObj.ElementType = ElementTypeEnum.Point; // // 设置图元的描述信息 // moveObj.Description = point.Description; // // 鼠标经过可见 // moveObj.IsHitTestVisible = true; // element = moveObj; //} // 添加图元到图层 if (gmapOverlay.Control.InvokeRequired) { gmapOverlay.Control.BeginInvoke(new Action(delegate { gmapOverlay.Markers.Add((element as GMapMarker)); })); } else { gmapOverlay.Markers.Add((element as GMapMarker)); } return(element); }