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()); }
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); } } }
private void AddFeatureToDisplay(KmlFeature feature, bool sky) { KmlDocument doc = feature as KmlDocument; if (doc != null) { sky = doc.sky; } if (!(feature is KmlNetworkLink)) { if (feature.visibility == false) { return; } else if (feature is KmlPlacemark) { KmlPlacemark placemark = (KmlPlacemark)feature; KmlStyle style = placemark.Style.GetStyle(placemark.Selected); Color lineColor = Color.White; if (style != null) { lineColor = style.LineStyle.Color; } if (placemark.geometry is KmlPoint) { placemark.Point = (KmlPoint)placemark.geometry; AddPlacemark(placemark); } else if (placemark.geometry is KmlMultiGeometry) { KmlMultiGeometry geo = (KmlMultiGeometry)placemark.geometry; AddMultiGeometry(sky, placemark, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo); } else if (placemark.geometry is KmlPolygon) { KmlPolygon geo = (KmlPolygon)placemark.geometry; if (geo.OuterBoundary != null) { AddLines(sky, geo.OuterBoundary as KmlLineList, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo.extrude); // to do 3d work and subtract inner rings } } else if (placemark.geometry is KmlLineString) { KmlLineString geo = (KmlLineString)placemark.geometry; List <Vector3d> vertexList = new List <Vector3d>(); for (int i = 0; i < (geo.PointList.Count); i++) { vertexList.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / geo.MeanRadius))); } for (int i = 0; i < (geo.PointList.Count - 1); i++) { if (sky) { lines.AddLine(Coordinates.RADecTo3d(-(180.0 - geo.PointList[i].Lng) / 15 + 12, geo.PointList[i].Lat, 1), Coordinates.RADecTo3d(-(180.0 - geo.PointList[i + 1].Lng) / 15 + 12, geo.PointList[i + 1].Lat, 1), lineColor, new Dates()); } else { lines.AddLine(vertexList[i], vertexList[i + 1], lineColor, new Dates()); } } } } if (feature is KmlGroundOverlay && feature.visibility) { AddGroundOverlay(feature as KmlGroundOverlay); } if (feature is KmlScreenOverlay && feature.visibility) { AddScreenOverlay(feature as KmlScreenOverlay); } } if (feature.visibility) { if (feature is KmlContainer) { KmlContainer container = (KmlContainer)feature; if (container.children != null) { foreach (KmlFeature child in container.children) { AddFeatureToDisplay(child, sky); } } } else { if (feature is KmlNetworkLink) { KmlNetworkLink netLink = (KmlNetworkLink)feature; if (netLink.LinkRoot != null) { foreach (KmlFeature child in netLink.LinkRoot.children) { AddFeatureToDisplay(child, sky); } } } } } }