示例#1
0
        private void WriteSubPoint(string elementName, GpxPoint point)
        {
            Writer_.WriteStartElement(elementName, GARMIN_EXTENSIONS_NAMESPACE);

            Writer_.WriteAttributeString("lat", point.Latitude.ToString(CultureInfo.InvariantCulture));
            Writer_.WriteAttributeString("lon", point.Longitude.ToString(CultureInfo.InvariantCulture));

            Writer_.WriteEndElement();
        }
示例#2
0
        private GpxPoint ReadGarminAutoRoutePoint(XmlReader reader)
        {
            GpxPoint point = new GpxPoint();

            string elementName    = reader.Name;
            bool   isEmptyElement = reader.IsEmptyElement;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "lat":
                    point.Latitude = double.Parse(reader.Value, CultureInfo.InvariantCulture.NumberFormat);
                    break;

                case "lon":
                    point.Longitude = double.Parse(reader.Value, CultureInfo.InvariantCulture.NumberFormat);
                    break;
                }
            }

            if (isEmptyElement)
            {
                return(point);
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    SkipElement(reader);
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name != elementName)
                    {
                        throw new FormatException(reader.Name);
                    }
                    return(point);
                }
            }

            throw new FormatException(elementName);
        }
示例#3
0
文件: Gpx.cs 项目: AgentTy/General
        public double GetDistnaceFrom(GpxPoint other)
        {
            double thisLatitude   = this.Latitude;
            double otherLatitude  = other.Latitude;
            double thisLongitude  = this.Longitude;
            double otherLongitude = other.Longitude;

            double deltaLatitude  = Math.Abs(this.Latitude - other.Latitude);
            double deltaLongitude = Math.Abs(this.Longitude - other.Longitude);

            thisLatitude   *= RADIAN;
            otherLatitude  *= RADIAN;
            deltaLongitude *= RADIAN;

            double cos = Math.Cos(deltaLongitude) * Math.Cos(thisLatitude) * Math.Cos(otherLatitude) +
                         Math.Sin(thisLatitude) * Math.Sin(otherLatitude);

            return(EARTH_RADIUS * Math.Acos(cos));
        }
示例#4
0
文件: Gpx.cs 项目: AgentTy/General
        public GpxPointCollection <GpxPoint> ToGpxPoints()
        {
            GpxPointCollection <GpxPoint> points = new GpxPointCollection <GpxPoint>();

            foreach (T gpxPoint in Points_)
            {
                GpxPoint point = new GpxPoint
                {
                    Longitude = gpxPoint.Longitude,
                    Latitude  = gpxPoint.Latitude,
                    Elevation = gpxPoint.Elevation,
                    Time      = gpxPoint.Time
                };

                points.Add(point);
            }

            return(points);
        }