Ejemplo n.º 1
0
        public KmlLineString(XmlNode parent) : this()
        {
            if (null != parent.Attributes["id"])
            {
                Id = parent.Attributes["id"].Value;
            }

            foreach (XmlNode node in parent.ChildNodes)
            {
                string key = node.Name.ToLower();
                switch (key)
                {
                case "extrude":
                    _extrude = node.InnerText.Equals("!") ? true : false;
                    break;

                case "tessellate":
                    _tessellate = node.InnerText.Equals("1") ? true : false;
                    break;

                case "altitudemode":
                    _altitudeMode = KmlAltitudeModes.altitudeModeFromString(node.InnerText);
                    break;

                case "coordinates":
                    _coordinates = KmlCoordinate.makeList(node.InnerText, Log);
                    break;

                default:
                    debug("skipping key :: " + key);
                    break;
                }
                ;
            }
        }
Ejemplo n.º 2
0
 public KmlCamera()
     : base()
 {
     _coordinate   = new KmlCoordinate();
     _heading      = 0;
     _tilt         = 0;
     _roll         = 100;
     _altitudeMode = string.Empty;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Copies the current KmlCoordinate
        /// </summary>
        /// <returns>KmlCoordinate on success, null on failure</returns>
        public KmlCoordinate Copy()
        {
            KmlCoordinate result = new KmlCoordinate();

            result.Altitude  = this.Altitude;
            result.Latitude  = this.Latitude;
            result.Longitude = this.Longitude;
            return(result);
        }
Ejemplo n.º 4
0
        }                //	computeLevel

        private String createEncodings(List <KmlCoordinate> points, double[] dists)
        {
            StringBuilder encodedPoints = new StringBuilder();

            double maxlat = 0, minlat = 0, maxlon = 0, minlon = 0;

            int plat = 0;
            int plng = 0;

            for (int i = 0; i < points.Count; i++)
            {
                // determin bounds (max/min lat/lon)
                if (i == 0)
                {
                    maxlat = minlat = points[i].Latitude;
                    maxlon = minlon = points[i].Longitude;
                }
                else
                {
                    if (points[i].Latitude > maxlat)
                    {
                        maxlat = points[i].Latitude;
                    }
                    else if (points[i].Latitude < minlat)
                    {
                        minlat = points[i].Latitude;
                    }
                    else if (points[i].Longitude > maxlon)
                    {
                        maxlon = points[i].Longitude;
                    }
                    else if (points[i].Longitude < minlon)
                    {
                        minlon = points[i].Longitude;
                    }
                }

                if (dists[i] != 0 || i == 0 || i == points.Count - 1)
                {
                    KmlCoordinate point = points[i];

                    int late5 = floor1e5(point.Latitude);
                    int lnge5 = floor1e5(point.Longitude);

                    int dlat = late5 - plat;
                    int dlng = lnge5 - plng;

                    plat = late5;
                    plng = lnge5;

                    encodedPoints.Append(encodeSignedNumber(dlat));
                    encodedPoints.Append(encodeSignedNumber(dlng));
                }
            }
            return(encodedPoints.ToString());
        } //	createEncodings
Ejemplo n.º 5
0
        public int CompareTo(KmlCoordinate value)
        {
            int result = (Altitude.CompareTo(value.Altitude));

            if (result == 0)
            {
                result = (Latitude.CompareTo(value.Latitude));
                if (result == 0)
                {
                    result = (Longitude.CompareTo(value.Longitude));
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        }                       //dpEncode

        public double distance(KmlCoordinate p0, KmlCoordinate p1, KmlCoordinate p2)
        {
            double u, result = 0.0;

            if (p1.Latitude == p2.Latitude &&
                p1.Longitude == p2.Longitude)
            {
                result = Math.Sqrt(Math.Pow(p2.Latitude - p0.Latitude, 2)
                                   + Math.Pow(p2.Longitude - p0.Longitude, 2));
            }
            else
            {
                u = ((p0.Latitude - p1.Latitude)
                     * (p2.Latitude - p1.Latitude) + (p0
                                                      .Longitude - p1.Longitude)
                     * (p2.Longitude - p1.Longitude))
                    / (Math.Pow(p2.Latitude - p1.Latitude, 2) + Math
                       .Pow(p2.Longitude - p1.Longitude, 2));

                if (u <= 0)
                {
                    result = Math.Sqrt(Math.Pow(p0.Latitude - p1.Latitude,
                                                2)
                                       + Math.Pow(p0.Longitude - p1.Longitude, 2));
                }
                else if (u >= 1)
                {
                    result = Math.Sqrt(Math.Pow(p0.Latitude - p2.Latitude,
                                                2)
                                       + Math.Pow(p0.Longitude - p2.Longitude, 2));
                }
                else if (0 < u && u < 1)
                {
                    result = Math.Sqrt(Math.Pow(p0.Latitude - p1.Latitude
                                                - u * (p2.Latitude - p1.Latitude), 2)
                                       + Math.Pow(p0.Longitude - p1.Longitude - u
                                                  * (p2.Longitude - p1.Longitude), 2));
                }
            }
            return(result);
        }                //	distance
Ejemplo n.º 7
0
        public KmlPoint(XmlNode parent, Logger log) : base(parent, log)
        {
            foreach (XmlNode node in parent.ChildNodes)
            {
                string key = node.Name.ToLower();
                switch (key)
                {
                case "extrude":
                    _extrude = (node.InnerText.Equals("1") ? true : false);
                    break;

                case "altitudemode":
                    _altitudeMode = KmlAltitudeModes.altitudeModeFromString(node.InnerText);
                    break;

                case "coordinates":
                    _coordinate = new KmlCoordinate(node.InnerText, log);
                    break;
                }
                ;
            }
        }        //	constructor
Ejemplo n.º 8
0
 public KmlPoint() : base()
 {
     _coordinate = new KmlCoordinate();
 }
Ejemplo n.º 9
0
        int IComparable.CompareTo(object obj)
        {
            KmlCoordinate temp = obj as KmlCoordinate;

            return(this.CompareTo(temp));
        }        //	CompareTo