private void AddFeatureToTree(KmlFeature feature, LayerUITreeNode parent) { feature.Dirty = false; string text = feature.Name; //if (!string.IsNullOrEmpty(feature.description)) //{ // text += Environment.NewLine + feature.description; //} bool bold = false; if (text.Contains("<b>")) { bold = true; text = text.Replace("<b>", "").Replace("</b>", ""); } LayerUITreeNode node = null; if (!(feature is KmlNetworkLink)) { node = parent.Add(text); node.Tag = feature; node.Checked = feature.visibility; node.Opened = feature.open; node.NodeChecked += new LayerUITreeNodeCheckedDelegate(node_NodeChecked); node.NodeUpdated += new LayerUITreeNodeUpdatedDelegate(node_NodeUpdated); node.NodeActivated += new LayerUITreeNodeActivatedDelegate(node_NodeActivated); node.NodeSelected += new LayerUITreeNodeSelectedDelegate(node_NodeSelected); if (bold) { node.Bold = true; } } if (feature is KmlContainer) { KmlContainer container = (KmlContainer)feature; if (container.children != null) { // if (feature.Style.GetStyle(false).ListStyle.ListItemType != KmlListItemTypes.CheckHideChildren) { foreach (KmlFeature child in container.children) { AddFeatureToTree(child, node); } } } } else { if (feature is KmlNetworkLink) { KmlNetworkLink netLink = (KmlNetworkLink)feature; if (netLink.LinkRoot != null) { AddRootToTree(netLink.LinkRoot, parent); } } } }
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); } } } } } }
//todo this stuff below is too tightly coupled to implementtion for winforms public static void GotoLookAt(KmlFeature feature) { //todo add sky support CameraParameters camera = new CameraParameters(); camera.Lat = feature.LookAt.latitude; camera.Lng = feature.LookAt.longitude; camera.Rotation = feature.LookAt.heading / 180 * Math.PI; camera.Angle = -feature.LookAt.tilt / 180 * Math.PI; camera.Zoom = UiTools.MetersToZoom(feature.LookAt.range); TourPlace p = new TourPlace(feature.Name, camera, Classification.Unidentified, "", ImageSetType.Earth, SolarSystemObjects.Earth); Earth3d.MainWindow.GotoTarget(p, false, false, true); }
private static void UpdateLinks(KmlFeature feature, KmlViewInformation viewInfo) { if (feature.visibility) { if (feature is KmlContainer) { KmlContainer container = (KmlContainer)feature; if (container.children != null) { foreach (KmlFeature child in container.children) { UpdateLinks(child, viewInfo); } } } else { if (feature is KmlNetworkLink) { KmlNetworkLink netLink = (KmlNetworkLink)feature; netLink.ConditionalUpdate(viewInfo); if (netLink.LinkRoot != null) { UpdateRootLinks(netLink.LinkRoot, viewInfo); } } } } }