예제 #1
0
파일: kml.cs 프로젝트: williammc/sentience
        /// <summary>
        /// add a point to the ring
        /// </summary>
        /// <param name="longitude"></param>
        /// <param name="latitude"></param>
        /// <param name="altitude"></param>
        public void Add(float longitude, float latitude, float altitude)
        {
            kmlPoint pt = new kmlPoint();

            pt.longitude = longitude;
            pt.latitude  = latitude;
            pt.altitude  = altitude;
            Add(pt);
        }
예제 #2
0
파일: kml.cs 프로젝트: williammc/sentience
 /// <summary>
 /// relocate the line at the new position
 /// </summary>
 /// <param name="longitude"></param>
 /// <param name="latitude"></param>
 public void Relocate(float longitude, float latitude)
 {
     // adjust the position of each point relative to the centre
     for (int i = 0; i < Points.Count; i++)
     {
         kmlPoint pt = (kmlPoint)Points[i];
         pt.longitude += longitude - centre_longitude;
         pt.latitude  += latitude - centre_latitude;
     }
     updateCentrePoint();
 }
예제 #3
0
파일: kml.cs 프로젝트: williammc/sentience
 /// <summary>
 /// recalculate the centre point of the ring
 /// </summary>
 private void updateCentrePoint()
 {
     if (Points.Count > 0)
     {
         float tot_x = 0;
         float tot_y = 0;
         for (int i = 0; i < Points.Count; i++)
         {
             kmlPoint pt = (kmlPoint)Points[i];
             tot_x += pt.longitude;
             tot_y += pt.latitude;
         }
         centre_longitude = tot_x / Points.Count;
         centre_latitude  = tot_y / Points.Count;
     }
 }
예제 #4
0
파일: kml.cs 프로젝트: williammc/sentience
        /// <summary>
        /// return an xml element
        /// </summary>
        /// <param name="doc">xml document to add the data to</param>
        /// <returns>an xml element</returns>
        public XmlElement getXml(XmlDocument doc)
        {
            String coords = "";

            for (int i = 0; i < Points.Count; i++)
            {
                kmlPoint pt = (kmlPoint)Points[i];
                coords += "\r\n" +
                          Convert.ToString(pt.longitude) + "," +
                          Convert.ToString(pt.latitude) + "," +
                          Convert.ToString(pt.altitude) + ",";
            }
            coords += "\r\n";

            XmlElement elem = doc.CreateElement("LinearRing");

            doc.DocumentElement.AppendChild(elem);
            xml.AddTextElement(doc, elem, "coordinates", coords);
            return(elem);
        }
예제 #5
0
파일: kml.cs 프로젝트: williammc/sentience
        /// <summary>
        /// returns true if the given location is inside the ring
        /// </summary>
        /// <param name="longitude"></param>
        /// <param name="latitude"></param>
        /// <returns>true if the given location is inside this ring</returns>
        public bool isInside(float longitude, float latitude)
        {
            bool inside = false;

            int i, j;

            for (i = 0, j = Points.Count - 1; i < Points.Count; j = i++)
            {
                kmlPoint pt1 = (kmlPoint)Points[i];
                kmlPoint pt2 = (kmlPoint)Points[j];

                if ((((pt1.latitude <= latitude) && (latitude < pt2.latitude)) ||
                     ((pt2.latitude <= latitude) && (latitude < pt1.latitude))) &&
                    (longitude < (pt2.longitude - pt1.longitude) * (latitude - pt1.latitude) /
                     (pt2.latitude - pt1.latitude) + pt1.longitude))
                {
                    inside = !inside;
                }
            }
            return(inside);
        }
예제 #6
0
파일: kml.cs 프로젝트: kasertim/sentience
 /// <summary>
 /// add a point to the ring
 /// </summary>
 /// <param name="pt"></param>
 public void Add(kmlPoint pt)
 {
     Points.Add(pt);
     updateCentrePoint();
 }
예제 #7
0
파일: kml.cs 프로젝트: kasertim/sentience
 /// <summary>
 /// add a point to the ring
 /// </summary>
 /// <param name="longitude"></param>
 /// <param name="latitude"></param>
 /// <param name="altitude"></param>
 public void Add(float longitude, float latitude, float altitude)
 {
     kmlPoint pt = new kmlPoint();
     pt.longitude = longitude;
     pt.latitude = latitude;
     pt.altitude = altitude;
     Add(pt);
 }
예제 #8
0
파일: kml.cs 프로젝트: williammc/sentience
 /// <summary>
 /// add a point to the ring
 /// </summary>
 /// <param name="pt"></param>
 public void Add(kmlPoint pt)
 {
     Points.Add(pt);
     updateCentrePoint();
 }