示例#1
0
 public KmlFolder CloneWithExcluding(IKmlElement[] elementsToExclude)
 {
     return(new KmlFolder(Name,
                          Placemarks
                          .Where(p => !elementsToExclude.Contains(p))
                          .Select(p => p.Clone())));
 }
示例#2
0
 public override void CleanUp()
 {
     triangles.Clear();
     lines.Clear();
     Placemarks.Clear();
     ClearScreenOverlays();
     ClearGroundOverlays();
 }
示例#3
0
        public void UpdateRetainedVisuals()
        {
            triangles.Clear();
            lines.Clear();
            Placemarks.Clear();
            ClearScreenOverlays();
            ClearGroundOverlays();

            if (root.children != null)
            {
                foreach (KmlFeature child in root.children)
                {
                    AddFeatureToDisplay(child, false);
                }
            }
        }
示例#4
0
        public override string ToString()
        {
            string retVal = string.Empty;

            if (Placemarks != null && Placemarks.Any(x => !string.IsNullOrEmpty(x.ToString())))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<kml xmlns=\'http://www.opengis.net/kml/2.2'>");
                sb.AppendLine("<Document>");
                foreach (KMLPlacemark placeMark in Placemarks.Where(x => x.HasData))
                {
                    sb.AppendLine(placeMark.ToString());
                }
                sb.AppendLine("</Document>");
                sb.AppendLine("</kml>");
                retVal = sb.ToString();
            }
            return(retVal);
        }
示例#5
0
        public static Placemarks readPlanets()
        {
            Placemarks placemarks = new Placemarks();

            placemarks.Items = new List <Placemark>();
            string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + excelFilePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
            string query      = "SELECT * FROM [planets$]";

            using (OleDbConnection conn = new OleDbConnection(connString))
            {
                try
                {
                    if (conn.State == System.Data.ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    OleDbCommand cmd = new OleDbCommand(query, conn);

                    OleDbDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Placemark tmp = new Placemark();
                        tmp.Name = reader[1].ToString();
                        double latitude  = Double.Parse(reader[5].ToString());
                        double longitude = Double.Parse(reader[3].ToString());
                        if (longitude > 180)
                        {
                            longitude = -180 + longitude;
                        }
                        tmp.Latitude  = latitude;
                        tmp.Longitude = longitude;
                        tmp.Range     = 12000000;
                        placemarks.Items.Add(tmp);
                    }
                    reader.Close();
                }
                catch
                {
                }
            }
            return(placemarks);
        }
示例#6
0
        public static int WritePlacemarkXml(Placemarks placemarks)
        {
            StreamWriter file = null;

            try
            {
                var serWriter = new XmlSerializer(typeof(Placemarks));
                file = new StreamWriter(PlacemarkXmlFile);
                serWriter.Serialize(file, placemarks);
                file.Close();
                return(0);
            }
            catch (Exception)
            {
                return(1);
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
        }
示例#7
0
        private void AutoSky_Load(object sender, EventArgs e)
        {
            var url = Environment.CurrentDirectory;

            url = url.Substring(0, url.IndexOf("\\bin\\Debug")) + "\\" + "AutoSky.html";
            GoogleSkyWebBrowser.Url = new Uri(url);
            _savedPlacemarks        = XmlHelper.ReadPlacemarkXml();
            _placemarks             = new Placemarks();
            _placemarks.Items       = new List <Placemark>();
            _placemarks.Items.AddRange(_savedPlacemarks.Items);
            _placemarks.Items.AddRange(ExcelHelper.readPlanets().Items);
            regexRA    = new Regex(@"^(?:([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])(.[0-9][0-9]?)?$");
            regexDEC   = new Regex(@"[0-8][0-9]:[0-5][0-9]:[0-5][0-9](.[0-9][0-9]?)?$");
            isRAValid  = false;
            isDECValid = false;


            _hardwareHandler = new HardwareHandler();
            _hardwareHandler.ArduinoMessageEvent  += Listener;
            GoogleSkyWebBrowser.ObjectForScripting = new ScriptManager(this);

            task = new Task(() => _hardwareHandler.ConnectToArduino());
            task.Start();
        }
        /// <summary>
        /// This method visits a KML placemark element
        /// </summary>
        /// <param name="elem">KML placemark element</param>
        protected void VisitPlacemark(XmlElement elem)
        {
            if (elem == null)
            {
                return;
            }

            var placemark = new Placemark();

            placemark.Id = GetAttribute(elem, "id");

            // Visits the child nodes
            foreach (XmlNode child in elem.ChildNodes)
            {
                var childName = child.Name.ToLowerInvariant();
                if (childName.Equals("name"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Name = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("description"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Description = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("address"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Address = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("lookat") && (child as XmlElement) != null)
                {
                    var numOfGeographiesBefore = Geographies.Count;

                    VisitLookAt(child as XmlElement);

                    var numOfGeographiesAfter = Geographies.Count;

                    if (numOfGeographiesAfter > numOfGeographiesBefore)
                    {
                        // Point found where this placemark looks at

                        placemark.LookAt = Geographies[Geographies.Count - 1];
                        Geographies.RemoveAt(Geographies.Count - 1);
                    }
                }
                else
                {
                    var numOfGeographiesBefore = Geographies.Count;

                    Visit(child);

                    var numOfGeographiesAfter = Geographies.Count;

                    if (numOfGeographiesAfter > numOfGeographiesBefore)
                    {
                        // Found the geography instance which describes this placemark

                        placemark.Geography = Geographies[Geographies.Count - 1];
                    }
                }
            }

            Placemarks.Add(placemark);
        }
示例#9
0
 public void AddPlacemark(KmlPlacemark placemark)
 {
     Placemarks.Add(placemark);
 }