Ejemplo n.º 1
0
 public KmlPlacemark(string name, string desc, KmlView v)
 {
     Init(name, desc, v);
 }
Ejemplo n.º 2
0
        private void WriteKmlView(KmlView v)
        {
            WriteStartElement("LookAt");

            if (v.TimeSpan != null && v.TimeSpan.StartTime != null && v.TimeSpan.EndTime != null)
            {
                WriteStartElement("gx:TimeSpan");
                WriteElementString("begin", ConvertToKmlDateTime(v.TimeSpan.StartTime));
                WriteElementString("end", ConvertToKmlDateTime(v.TimeSpan.EndTime));
                WriteEndElement();
            }
            else if (v.TimeStamp != null)
            {
                WriteStartElement("gx:TimeStamp");
                WriteElementString("when", ConvertToKmlDateTime((DateTime)v.TimeStamp));
                WriteEndElement();
            }

            if (v.Coordinates != null)
            {
                if (v.Coordinates.Value.Lon != null)
                    WriteElementString("longitude", v.Coordinates.Value.Lon.ToString());
                if (v.Coordinates.Value.Lat != null)
                    WriteElementString("latitude", v.Coordinates.Value.Lat.ToString());
                if (v.Coordinates.Value.Alt != null)
                    WriteElementString("altitude", v.Coordinates.Value.Alt.ToString());
            }

            WriteElementString("range", v.Range.ToString());

            if (v.Tilt != null)
                WriteElementString("tilt", v.Tilt.ToString());
            if (v.Heading != null)
                WriteElementString("heading", v.Heading.ToString());
            if (v.AltMode != null)
            {
                if (v.AltMode == AltitudeMode.absolute || v.AltMode == AltitudeMode.clampToGround || v.AltMode == AltitudeMode.relativeToGround)
                    WriteElementString("altitudeMode", v.AltMode.ToString());
                else
                    WriteElementString("gx:altitudeMode", v.AltMode.ToString());
            }

            WriteEndElement();
        }
Ejemplo n.º 3
0
 public KmlView(KmlView v)
 {
     TimeSpan = v.TimeSpan;
     TimeStamp = v.TimeStamp;
     Coordinates = v.Coordinates;
     Heading = v.Heading;
     Tilt = v.Tilt;
     Range = v.Range;
 }
Ejemplo n.º 4
0
        public void WriteKmlPlacemark(KmlPlacemark pm)
        {
            if (pm != null)
            {
                WriteStartElement("Placemark");
                WriteComment("Placemark Guid: " + pm.CN);

                WriteElementString("name", pm.Name);

                WriteKmlDescription(pm.Desctription);

                if (pm.View != null && pm.View.Coordinates != null)
                    WriteKmlView(pm.View);
                else
                {
                    KmlView v = new KmlView();

                    if (pm.Polygons != null && pm.Polygons.Count > 0)
                    {
                        v.Coordinates = pm.Polygons[0].AveragedCoords;
                        v.AltMode = pm.Polygons[0].AltMode;
                    }
                    else if (pm.Points != null && pm.Points.Count > 0)
                    {
                        v.Coordinates = pm.Points[0].Coordinates;
                        v.AltMode = pm.Points[0]._AltMode;
                    }

                    WriteKmlView(v);
                }

                if(pm.StyleUrl != null && pm.StyleUrl != "")
                    WriteElementString("styleUrl", pm.StyleUrl);

                if (pm.Visibility != null)
                    WriteElementString("visibility", ConvertBool((bool)pm.Visibility).ToString());
                if (pm.Open != null)
                    WriteElementString("open", ConvertBool((bool)pm.Open).ToString());

                if (pm.Properties != null)
                    WriteKmlProperties(pm.Properties);

                if ((pm.Points.Count + pm.Polygons.Count) > 1)
                {
                    WriteStartElement("MultiGeometry");

                    foreach (KmlPolygon poly in pm.Polygons)
                    {
                        WriteKmlPolygon(poly);
                    }
                    foreach (KmlPoint point in pm.Points)
                    {
                        WriteKmlPoint(point);
                    }

                    //end MultiGeo
                    WriteEndElement();
                }
                else
                {
                    if (pm.Polygons.Count > 0)
                    {
                        WriteKmlPolygon(pm.Polygons[0]);
                    }
                    else if (pm.Points.Count > 0)
                    {
                        WriteKmlPoint(pm.Points[0]);
                    }
                    else
                    {
                        //just point and polys for now
                    }
                }

                //end placemark
                WriteEndElement();
            }
        }
Ejemplo n.º 5
0
        private void Init(string name, string desc, KmlView v)
        {
            Name = name;
            View = v;

            if (desc != null)
                Desctription = desc;
            else
                Desctription = "";

            _CN = Guid.NewGuid().ToString();

            StyleUrl = null;
            Properties = null;
            Visibility = null;
            Open = null;

            _Polygons = new List<KmlPolygon>();
            _Points = new List<KmlPoint>();
        }