public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["longitude"] != null) { Double.TryParse(node["longitude"].InnerText, out longitude); } if (node["latitude"] != null) { Double.TryParse(node["latitude"].InnerText, out latitude); } if (node["altitude"] != null) { Double.TryParse(node["altitude"].InnerText, out altitude); } if (node["heading"] != null) { Double.TryParse(node["heading"].InnerText, out heading); } if (node["tilt"] != null) { Double.TryParse(node["tilt"].InnerText, out tilt); } if (node["range"] != null) { Double.TryParse(node["range"].InnerText, out range); } if (node["altitudeMode"] != null) { try { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText); } catch { } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["scale"] != null) { float.TryParse(node["scale"].InnerText, out Scale); } }
private static Layer LoadKmlFile(string path, string parentFrame) { KmlRoot newRoot = new KmlRoot(path, (KmlRoot)null); KmlLayer layer = new KmlLayer(); layer.root = newRoot; KmlCollection.UpdateRootLinks(layer.root, Earth3d.MainWindow.KmlViewInfo); layer.UpdateRetainedVisuals(); layer.Enabled = true; layer.Name = path.Substring(path.LastIndexOf('\\') + 1); LayerList.Add(layer.ID, layer); layer.ReferenceFrame = currentMap; AllMaps[currentMap].Layers.Add(layer); AllMaps[currentMap].Open = true; version++; LoadTree(); if (newRoot.children != null && newRoot.children.Count > 0) { if (newRoot.children[0].LookAt != null) { KmlLayerUI.GotoLookAt(newRoot.children[0]); } } return layer; }
// todo Define remainder of vars public override void LoadDetails(XmlNode node, KmlRoot owner) { if (node["name"] != null) { Name = node["name"].InnerText; } foreach (XmlNode child in node.ChildNodes) { if (child.Name == "Style") { KmlStyle style = new KmlStyle(); style.LoadDetails(child, owner); Style = style; if (!string.IsNullOrEmpty(style.ID)) { owner.Styles.Add(style.ID, style); } } if (child.Name == "StyleMap") { KmlStyleMap style = new KmlStyleMap(); style.LoadDetails(child, owner); if (!string.IsNullOrEmpty(style.ID)) { owner.Styles.Add(style.ID, style); } } } base.LoadDetails(node, owner); if (node["open"] != null) { open = node["open"].InnerText.Trim() == "1"; } if (node["visibility"] != null) { visibility = node["visibility"].InnerText.Trim() == "1"; } if (node["atom:author"] != null) { atom_author = node["atom:author"].InnerText; } if (node["atom:link"] != null) { atom_link = node["atom:link"].InnerText; } if (node["address"] != null) { address = node["address"].InnerText; } if (node["xal:AddressDetails"] != null) { xal_AddressDetails = node["xal:AddressDetails"].InnerText; } if (node["description"] != null) { description = node["description"].InnerText; } if (node["Snippet"] != null) { Snippet = node["Snippet"].InnerText; } if (node["Region"] != null) { region = new KmlRegion(); region.LoadDetails(node["Region"], owner); } if (node["LookAt"] != null) { LookAt = new KmlLookAt(); LookAt.LoadDetails(node["LookAt"], owner); } if (node["TimeSpan"] != null) { Time = new KmlTimeSpan(); Time.LoadDetails(node["TimeSpan"], owner); owner.UpdateTimeSpanRange(Time); } if (node["TimeStamp"] != null) { Time = new KmlTimeSpan(); Time.LoadDetails(node["TimeStamp"], owner); owner.UpdateTimeSpanRange(Time); } if (node["styleUrl"] != null) { string url = node["styleUrl"].InnerText; if (url.StartsWith("#")) { // Internal reference if (owner != null) { if (owner.Document != null) { this.Style = owner.Styles[url.Remove(0, 1)]; } } } } if (node["StyleSelector"] != null) { Style = new KmlStyle(); if (node["StyleSelector"]["Style"] != null) { Style.LoadDetails(node["StyleSelector"]["Style"], owner); } //todo add stle options } //todo finish up all of this ! Missing fields and types galore }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["gx:x"] != null) { X = Convert.ToInt32(node["gx:x"].InnerText); } if (node["gx:y"] != null) { Y = Convert.ToInt32(node["gx:y"].InnerText); } if (node["gx:w"] != null) { W = Convert.ToInt32(node["gx:w"].InnerText); } if (node["gx:h"] != null) { H = Convert.ToInt32(node["gx:h"].InnerText); } }
public void Add(KmlRoot root) { Roots.Add(root); }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); foreach (XmlNode child in node.ChildNodes) { KmlFeature newChild = null; switch (child.Name) { case "NetworkLink": newChild = new KmlNetworkLink(); break; case "Placemark": newChild = new KmlPlacemark(); break; case "PhotoOverlay": newChild = new KmlPhotoOverlay(); break; case "ScreenOverlay": newChild = new KmlScreenOverlay(); break; case "GroundOverlay": newChild = new KmlGroundOverlay(); break; case "Folder": newChild = new KmlFolder(); break; case "Document": newChild = new KmlDocument(); break; } if (newChild != null) { newChild.sky = this.sky; newChild.LoadDetails(child, owner); if (children == null) { children = new List<KmlFeature>(); } children.Add(newChild); } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["Point"] != null) { geometry = new KmlPoint(); geometry.LoadDetails(node["Point"], owner); } else if (node["LineString"] != null) { geometry = new KmlLineString(); geometry.LoadDetails(node["LineString"], owner); } else if (node["LinearRing"] != null) { geometry = new KmlLinearRing(); geometry.LoadDetails(node["LinearRing"], owner); } else if (node["Polygon"] != null) { geometry = new KmlPolygon(); geometry.LoadDetails(node["Polygon"], owner); } else if (node["MultiGeometry"] != null) { geometry = new KmlMultiGeometry(); geometry.LoadDetails(node["MultiGeometry"], owner); } //else if (node["Model"] != null) //{ // geometry = new KmlModel(); // geometry.LoadDetails(node["Model"]); //} //todo support models someday }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["coordinates"] != null) { string[] split = node["coordinates"].InnerText.Split(new char[] { ',' }); if (split.Length > 0) { double.TryParse(split[0], out longitude); } if (split.Length > 1) { double.TryParse(split[1], out latitude); } if (split.Length > 2) { double.TryParse(split[2], out altitude); } } if (node["extrude"] != null) { extrude = node["extrude"].InnerText.Trim() == "1"; } if (node["altitudeMode"] != null) { try { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText.Trim()); } catch { } } }
public virtual void LoadDetails(XmlNode node, KmlRoot owner) { Owner = owner; if (node.Attributes["id"] != null) { ID = node.Attributes["id"].Value; } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["geomColor"] != null) { int abgr = Convert.ToInt32(node["geomColor"].InnerText, 16); byte alpha = (byte)(abgr >> 24); byte blue = (byte)(abgr >> 16); byte green = (byte)(abgr >> 8); byte red = (byte)(abgr); color = Color.FromArgb(alpha, red, green, blue); } else if (node["color"] != null) { color = GetColor(node); } if (node["drawOrder"] != null) { drawOrder = Convert.ToInt32(node["drawOrder"].InnerText); } if (node["Icon"] != null) { Icon = new KmlIcon(); Icon.LoadDetails(node["Icon"], owner); } }
private void UpdateLink(KmlViewInformation viewInfo) { try { if (Link != null) { string url; if (Link.ViewRefreshMode == viewRefreshModeEnum.onStop) //if (!String.IsNullOrEmpty(Link.viewFormat)) { url = viewInfo.PrepLinkUrl(Link.Href + "?" + Link.ViewFormat); } else { url = Link.Href; } LinkRoot = new KmlRoot(url, Owner); Dirty = true; //if (open) //{ // if (LinkRoot.children != null) // { // foreach (KmlFeature feature in LinkRoot.children) // { // feature.open = true; // } // } //} //if (visibility) //{ // if (LinkRoot.children != null) // { // foreach (KmlFeature feature in LinkRoot.children) // { // feature.visibility = true; // } // } //} } } catch { } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["refreshVisibility"] != null) { refreshVisibility = node["refreshVisibility"].InnerText.Trim() == "1"; } if (node["flyToView"] != null) { flyToView = node["flyToView"].InnerText.Trim() == "1"; } if (node["Link"] != null) { Link = new KmlLink(); Link.LoadDetails(node["Link"], owner); } else if (node["Url"] != null) { Link = new KmlLink(); Link.LoadDetails(node["Url"], owner); } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); foreach (XmlNode child in node.ChildNodes) { KmlGeometry geometry = null; switch (child.Name) { case "Point": { geometry = new KmlPoint(); geometry.LoadDetails(child, owner); } break; case "LineString": { geometry = new KmlLineString(); geometry.LoadDetails(child, owner); } break; case "LinearRing": { geometry = new KmlLinearRing(); geometry.LoadDetails(child, owner); } break; case "Polygon": { geometry = new KmlPolygon(); geometry.LoadDetails(child, owner); } break; case "MultiGeometry": { geometry = new KmlMultiGeometry(); geometry.LoadDetails(child, owner); } break; } if (geometry != null) { Children.Add(geometry); } } if (node["extrude"] != null) { extrude = node["extrude"].InnerText.Trim() == "1"; } if (node["altitudeMode"] != null) { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText.Trim()); } }
public void LoadDetails(XmlElement node, KmlRoot owner) { if (node["begin"] != null) { UnBoundedBegin = !DateTime.TryParse(node["begin"].InnerText, out BeginTime); if (UnBoundedBegin) { int year = 0; if (int.TryParse(node["begin"].InnerText, out year)) { year = Math.Max(1, Math.Min(3999,year)); BeginTime = new DateTime(year, 1, 1); UnBoundedBegin = false; } } if (BeginTime.Kind == DateTimeKind.Local) { BeginTime = BeginTime.ToUniversalTime(); } } // alternative timestamp if (node["when"] != null) { UnBoundedBegin = !DateTime.TryParse(node["when"].InnerText, out BeginTime); if (UnBoundedBegin) { int year = 0; if (int.TryParse(node["when"].InnerText, out year)) { year = Math.Max(1, Math.Min(3999, year)); BeginTime = new DateTime(year, 1, 1); UnBoundedBegin = false; } } if (BeginTime.Kind == DateTimeKind.Local) { BeginTime = BeginTime.ToUniversalTime(); } } if (node["end"] != null) { UnBoundedEnd = !DateTime.TryParse(node["end"].InnerText, out EndTime); if (UnBoundedEnd) { int year = 0; if (int.TryParse(node["end"].InnerText, out year)) { year = Math.Max(1, Math.Min(3999,year)); EndTime = new DateTime(year, 12, 31, 23, 59, 59); UnBoundedEnd = false; } } if (EndTime.Kind == DateTimeKind.Local) { EndTime = EndTime.ToUniversalTime(); } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["outerBoundaryIs"] != null) { if (node["outerBoundaryIs"]["LinearRing"] != null) { OuterBoundary = new KmlLinearRing(); OuterBoundary.LoadDetails(node["outerBoundaryIs"]["LinearRing"], owner); } } foreach(XmlNode child in node.ChildNodes) { if (child.Name == "innerBoundaryIs") { KmlLinearRing innerRing = new KmlLinearRing(); innerRing.LoadDetails(child, owner); InnerBoundarys.Add(innerRing); } } if (node["extrude"] != null) { extrude = node["extrude"].InnerText.Trim() == "1"; } if (node["altitudeMode"] != null) { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText.Trim()); } }
public static void UpdateRootLinks(KmlRoot root, KmlViewInformation viewInfo) { if (root.children != null) { foreach (KmlFeature child in root.children) { UpdateLinks(child, viewInfo); } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); Fill = GetBoolValue(node, "fill"); Outline = GetBoolValue(node, "outline"); }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); Color = GetColor(node); ColorMode = GetColorMode(node); if (ColorMode == KmlColorModes.Random) { byte red = (Byte)(Color.R * rnd.NextDouble()); byte green = (Byte)(Color.G * rnd.NextDouble()); byte blue = (Byte)(Color.B * rnd.NextDouble()); byte alpha = (Byte)(Color.A * rnd.NextDouble()); Color = Color.FromArgb(alpha, red, green, blue); } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["LatLonAltBox"] != null) { XmlNode box = node["LatLonAltBox"]; if (box["north"] != null) { north = Convert.ToDouble(box["north"].InnerText); } if (box["south"] != null) { south = Convert.ToDouble(box["south"].InnerText); } if (box["east"] != null) { east = Convert.ToDouble(box["east"].InnerText); } if (box["west"] != null) { west = Convert.ToDouble(box["west"].InnerText); } if (box["minAltitude"] != null) { minAltitude = Convert.ToDouble(box["minAltitude"].InnerText); } if (box["maxAltitude"] != null) { maxAltitude = Convert.ToDouble(box["maxAltitude"].InnerText); } if (box["altitudeMode"] != null) { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), box["altitudeMode"].InnerText); } } if (node["Lod"] != null) { XmlNode lod = node["Lod"]; if (lod["minLodPixels"] != null) { minLodPixels = Convert.ToSingle(lod["minLodPixels"].InnerText); } if (lod["maxLodPixels"] != null) { maxLodPixels = Convert.ToSingle(lod["maxLodPixels"].InnerText); } if (lod["minFadeExtent"] != null) { minFadeExtent = Convert.ToSingle(lod["minFadeExtent"].InnerText); } if (lod["maxFadeExtent"] != null) { maxFadeExtent = Convert.ToSingle(lod["maxFadeExtent"].InnerText); } } }
//todo <!-- 0 or more Schema elements --> public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); }
public KmlRoot(string filename, KmlRoot owner) { TimeSpan = new KmlTimeSpan(); // Set high and low points. TimeSpan.BeginTime = new DateTime(3999, 1, 1); TimeSpan.EndTime = new DateTime(1, 1, 1); Owner = owner; if (Uri.IsWellFormedUriString(filename, UriKind.Absolute)) { BaseUri = new Uri(filename); } if (!File.Exists(filename) && owner != null & owner.BaseUri != null) { Uri newUri = new Uri(owner.BaseUri, filename); filename = newUri.ToString(); } XmlDocument doc = new XmlDocument(); XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(doc.NameTable); NamespaceManager.AddNamespace("atom", "http://www.w3.org/2005/Atom"); if (filename.ToLower().Contains(".kmz")) { if (Uri.IsWellFormedUriString(filename, UriKind.Absolute)) { Stream fs = UiTools.GetMemoryStreamFromUrl(filename); Archive = new ZipArchive(fs); foreach (ZipEntry entry in Archive.Files) { if (entry.Filename.ToLower().EndsWith(".kml")) { doc.Load(entry.GetFileStream()); } } } else { // using (FileStream fs = new FileStream(filename, FileMode.Open)) FileStream fs = new FileStream(filename, FileMode.Open); { ZipArchive archive = new ZipArchive(fs); foreach (ZipEntry entry in archive.Files) { if (entry.Filename.ToLower().EndsWith(".kml")) { doc.Load(entry.GetFileStream()); Archive = archive; } } } } } else { try { //todo this really needs to be fixed. doc.Load(filename); } catch { } } XmlNode kml = doc["kml"]; if (kml == null) { return; } if (kml.Attributes["hint"] != null) { if (kml.Attributes["hint"].InnerText.ToLower().Contains("sky")) { sky = true; } } LoadDetails(kml); LoadStatus = KmlLoadStatus.Loaded; }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["altitude"] != null) { altitude = Convert.ToDouble(node["altitude"].InnerText); } if (node["altitudeMode"] != null) { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText); } if (node["LatLonBox"] != null) { XmlNode box = node["LatLonBox"]; if (box["north"] != null) { north = Convert.ToDouble(box["north"].InnerText); } if (box["south"] != null) { south = Convert.ToDouble(box["south"].InnerText); } if (box["east"] != null) { east = Convert.ToDouble(box["east"].InnerText); } if (box["west"] != null) { west = Convert.ToDouble(box["west"].InnerText); } if (box["rotation"] != null) { rotation = Convert.ToSingle(box["rotation"].InnerText); } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["overlayXY"] != null) { OverlaySpot = new KmlSpot(node, "overlayXY"); } if (node["screenXY"] != null) { ScreenSpot = new KmlSpot(node,"screenXY"); } if (node["rotationXY"] != null) { RotationSpot = new KmlSpot(node, "rotationXY"); } if (node["size"] != null) { Size = new KmlSpot(node, "size"); } if (node["rotation"] != null) { Double.TryParse(node["rotation"].Value, out Rotation); } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["scale"] != null) { Scale = Convert.ToSingle(node["scale"].InnerText); } if (node["Icon"] != null) { Icon.LoadDetails(node["Icon"], owner); } if (node["hotSpot"] != null) { HotSpot = new KmlSpot(node,"hotSpot"); } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["PolyStyle"] != null) { PolyStyle.LoadDetails(node["PolyStyle"], owner); } if (node["LineStyle"] != null) { LineStyle.LoadDetails(node["LineStyle"], owner); } if (node["ListStyle"] != null) { ListStyle.LoadDetails(node["ListStyle"], owner); } if (node["LabelStyle"] != null) { LabelStyle.LoadDetails(node["LabelStyle"], owner); } if (node["IconStyle"] != null) { IconStyle.LoadDetails(node["IconStyle"], owner); } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["coordinates"] != null) { string data = node["coordinates"].InnerText; data = data.Replace(", ", ",").Replace(" ,", ",").Replace(" , ", ",").Replace("(", "").Replace(")", ""); string[] lines = data.Split(new char[] { '\n', '\r', ' ' }); foreach (string line in lines) { string[] parts = line.Split(new char[] { ',' }); if (parts.Length > 1) { KmlCoordinate pnt = new KmlCoordinate(); pnt.Lng = double.Parse(parts[0]); pnt.Lat = double.Parse(parts[1]); if (parts.Length > 2) { pnt.Alt = double.Parse(parts[2]); } else { pnt.Alt = 0; } PointList.Add(pnt); } } } if (node["extrude"] != null) { extrude = node["extrude"].InnerText.Trim() == "1"; } if (node["altitudeMode"] != null) { try { altitudeMode = (altitudeModeEnum)Enum.Parse(typeof(altitudeModeEnum), node["altitudeMode"].InnerText.Trim()); } catch { } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); foreach (XmlNode child in node.ChildNodes) { if (child.Name == "Pair" ) { if (child["key"] != null && child["styleUrl"] != null) { if (child["key"].InnerText.Trim() == "normal") { normal = child["styleUrl"].InnerText.Trim(); } else { highlight = child["styleUrl"].InnerText.Trim(); } } } } }
private void AddRootToTree(KmlRoot root, LayerUITreeNode node) { if (root.children != null) { foreach (KmlFeature child in root.children) { AddFeatureToTree(child, node); } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); if (node["listItemType"] != null) { switch (node["listItemType"].InnerText) { case "radioFolder": ListItemType = KmlListItemTypes.RadioFolder; break; case "checkOffOnly": ListItemType = KmlListItemTypes.CheckOffOnly; break; case "checkHideChildren": ListItemType = KmlListItemTypes.CheckHideChildren; break; default: case "check": ListItemType = KmlListItemTypes.Check; break; } } Background = GetBgColor(node); if (node["ItemIcon"] != null) { if (node["ItemIcon"]["state"] != null) { ItemIconState = node["ItemIcon"]["state"].InnerText; } if (node["ItemIcon"]["href"] != null) { ItemIconHref = node["ItemIcon"]["href"].InnerText; } } }