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); }
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)); }
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); }