Ejemplo n.º 1
0
 internal void RelateToStartPoint(ref WayPoint start) //, out GPXVector distanceVector, out double time)
 {
     _DistanceFromStart = this - start;
     _TimeSinceStart = this.Time.Subtract(start.Time);
 }
Ejemplo n.º 2
0
 public WayPoint Copy()
 {
     WayPoint retVal = new WayPoint();
     retVal.ageofdgpsdata = this.ageofdgpsdata;
     retVal.ageofdgpsdataSpecified = this.ageofdgpsdataSpecified;
     retVal.Comment = this.Comment;
     retVal.Description = this.descField;
     retVal.dgpsid = this.dgpsid;
     retVal.Elevation = this.eleField;
     retVal.fix = (Fix)this.fix;
     retVal.geoidheight = this.geoidheight;
     retVal.hdop = this.hdop;
     //retVal.Latitude = this.lat;
     //retVal.Longitude = this.lon;
     retVal.SetLongitudeLatitude(this.lonField, this.latField);
     retVal.MagneticVariation = this.magvar;
     retVal.Name = this.nameField;
     retVal.pdop = this.pdop;
     retVal.NumberOfSatellites = this.satField;
     retVal.SourceOfData = this.srcField;
     retVal.Symbol = this.symField;
     retVal.Time = this.timeField;
     retVal.Classification = this.typeField;
     return retVal;
 }
Ejemplo n.º 3
0
 public WayPointSelectedEventArgs(WayPoint wp)
     : base()
 {
     _SelectedWaypoint = wp;
 }
Ejemplo n.º 4
0
 public double GetDistanceFrom(WayPoint pt)
 {
     return (this - pt).GetLength(Latitude);
 }
Ejemplo n.º 5
0
        private double GetSelectedValueFromWaypoint(WayPoint wp, DrawCategory drawCategory)
        {
            double retVal = 0;
            switch (drawCategory)
            {
                case DrawCategory.DistanceFromStart:
                    retVal = wp.GetDistanceFromStart().GetLength(wp.Latitude);
                    break;
                case DrawCategory.Elevation:
                    retVal = Convert.ToDouble(wp.Elevation);
                    break;
                case DrawCategory.Latitude:
                    retVal = Convert.ToDouble(wp.Latitude);
                    break;
                case DrawCategory.LatitudeKm:
                    retVal = wp.LatitudeKm;
                    break;
                case DrawCategory.Longitude:
                    retVal = Convert.ToDouble(wp.Longitude);
                    break;
                case DrawCategory.LongitudeKm:
                    retVal = wp.LongitudeKm;
                    break;
                case DrawCategory.Speed:
                    retVal = wp.GetSpeed();
                    break;
                case DrawCategory.SpeedvectorEast:
                    retVal = wp.GetSpeedVector().DeltaLongitude;
                    break;
                case DrawCategory.SpeedvectorElevation:
                    retVal = wp.GetSpeedVector().DeltaElevation;
                    break;
                case DrawCategory.SpeedvectorNorth:
                    retVal = wp.GetSpeedVector().DeltaLatitude;
                    break;
                case DrawCategory.Time:
                    retVal = wp.GetTimeSinceStartSeconds();
                    break;
                case DrawCategory.TrackDistanceFromStart:
                    retVal = wp.GetTrackDistanceFromStart();
                    break;
                case DrawCategory.DirectionEast:
                    retVal = wp.GetDirectionVector().DeltaLongitude;
                    break;
                case DrawCategory.DirectionNorth:
                    retVal = wp.GetDirectionVector().DeltaLatitude;
                    break;
                case DrawCategory.DirectionVertical:
                    retVal = wp.GetDirectionVector().DeltaElevation;
                    break;
                case DrawCategory.PercrentAscent:
                    retVal = wp.GetAscent();
                    break;
                case DrawCategory.Heartrate:
                    retVal = wp.Heartreate;
                    break;
                case DrawCategory.Cadence:
                    retVal = wp.Cadence;
                    break;
                case DrawCategory.Depth:
                    retVal = wp.Depth;
                    break;
                case DrawCategory.Temperature:
                    retVal = wp.Temperature;
                    break;
                case DrawCategory.Watertemperature:
                    retVal = wp.WaterTemperature;
                    break;
                default:
                    //GPX_TrackControl_GetSelectedValueFromWaypoint0=Unknown category for drawing
                    throw new ArgumentException(ResourceManager.GetString("GPX_TrackControl_GetSelectedValueFromWaypoint0"));
            }

            return retVal;
        }
Ejemplo n.º 6
0
        private void SetWaypointValueForCoordinates(WayPoint wp, int x, int y)
        {
            if (_ShowMap)
            {
                GMap.NET.PointLatLng pos = _Core.FromLocalToLatLng(x, y);
                wp.Latitude = Convert.ToDecimal(pos.Lat);
                wp.Longitude = Convert.ToDecimal(pos.Lng);
            }
            else
            {
                switch (_XCategory)
                {
                    case DrawCategory.Elevation:
                        wp.Elevation = Convert.ToDecimal(_XMin + _XFactor * x); //_XMin + _XFactor * (x - _LeftMargin)
                        break;
                    case DrawCategory.Latitude:
                        wp.Latitude = Convert.ToDecimal(_XMin + _XFactor * x);
                        break;
                    case DrawCategory.LatitudeKm:
                        double latitudeKm = _XMin + _XFactor * x;
                        wp.Latitude = Convert.ToDecimal(latitudeKm / GPXUtils.KmPerDegree);
                        break;
                    case DrawCategory.Longitude:
                        wp.Longitude = Convert.ToDecimal(_XMin + _XFactor * x);
                        break;
                    case DrawCategory.LongitudeKm:
                        double longitudeKm = _XMin + _XFactor * x;
                        wp.Longitude = Convert.ToDecimal(longitudeKm / GPXUtils.KmPerDegreeAtLatitude(wp.Latitude));
                        break;
                    default:
                        //GPX_TrackControl_SetWaypointValueForCoordinates0=X Category not valid for editing
                        throw new ArgumentException(ResourceManager.GetString("GPX_TrackControl_SetWaypointValueForCoordinates0"));
                }

                switch (_YCategory)
                {
                    case DrawCategory.Elevation:
                        wp.Elevation = Convert.ToDecimal(_YMax - _YFactor * y); //_YMax - _YFactor * (y - _GeneralMargin)
                        break;
                    case DrawCategory.Latitude:
                        wp.Latitude = Convert.ToDecimal(_YMax - _YFactor * y);
                        break;
                    case DrawCategory.LatitudeKm:
                        double latitudeKm = _YMax - _YFactor * y;
                        wp.Latitude = Convert.ToDecimal(latitudeKm / GPXUtils.KmPerDegree);
                        break;
                    case DrawCategory.Longitude:
                        wp.Longitude = Convert.ToDecimal(_YMax - _YFactor * y);
                        break;
                    case DrawCategory.LongitudeKm:
                        double longitudeKm = _YMax - _YFactor * y;
                        wp.Longitude = Convert.ToDecimal(longitudeKm / GPXUtils.KmPerDegreeAtLatitude(wp.Latitude));
                        break;
                    default:
                        //GPX_TrackControl_SetWaypointValueForCoordinates1=Y Category not valid for editing
                        throw new ArgumentException(ResourceManager.GetString("GPX_TrackControl_SetWaypointValueForCoordinates1"));
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Construct the POI from a waypoint
 /// </summary>
 /// <param name="pt"></param>
 /// <param name="idx"></param>
 public PointOfInterest(WayPoint pt, int idx) : base(pt, idx)
 {
     Connections = new List<ConnectInfo>();
 }
Ejemplo n.º 8
0
 public WayPointOnMap(WayPoint wp)
 {
     _WayPoint = wp;
     _IsHidden = false;
     _IsHighlighted = false;
 }
Ejemplo n.º 9
0
        private bool CanDelete(WayPoint wp, WayPoint previous, double neighbourDistanceSquare, double lineDistanceSquare, double angleSineSquare)
        {
            //we cannot delete the first or last point
            if (previous == null)
                return false;
            if (wp.NextWaypoint == null)
                return false;

            //calculate distances (actually their squares)
            double distancePreviousThis = 1000000* (wp.LatitudeKm - previous.LatitudeKm) * (wp.LatitudeKm - previous.LatitudeKm) + (wp.LongitudeKm - previous.LongitudeKm) * (wp.LongitudeKm - previous.LongitudeKm);
            double distancePreviousNext = 1000000 * (wp.NextWaypoint.LatitudeKm - previous.LatitudeKm) * (wp.NextWaypoint.LatitudeKm - previous.LatitudeKm) + (wp.NextWaypoint.LongitudeKm - previous.LongitudeKm) * (wp.NextWaypoint.LongitudeKm - previous.LongitudeKm);
            double distanceThisNext = 1000000 * (wp.LatitudeKm - wp.NextWaypoint.LatitudeKm) * (wp.LatitudeKm - wp.NextWaypoint.LatitudeKm) + (wp.LongitudeKm - wp.NextWaypoint.LongitudeKm) * (wp.LongitudeKm - wp.NextWaypoint.LongitudeKm);

            //if the point is close to a neighbor, remove it
            if (distancePreviousThis < neighbourDistanceSquare)
                return true;
            if (distanceThisNext < neighbourDistanceSquare)
                return true;

            //calculate distance of this point to the direct line from previous to next point (actually square)
            double distanceFromLine = 1000000 *( distancePreviousThis - (distancePreviousThis - distanceThisNext + distancePreviousNext) * (distancePreviousThis - distanceThisNext + distancePreviousNext) / (4 * distancePreviousNext));

            //keep the point if the distance from line is bigger than a threshold
            if (distanceFromLine > lineDistanceSquare)
                return false;

            //keep the point if the angle at it is smaller than 90 degrees (easy to calculate, and removes problems in later steps)
            if (distancePreviousNext - distancePreviousThis - distanceThisNext < 0)
                return false;

            //calculate the angles at previos and next point (actually square of sine)
            double anglePrevious = distanceFromLine / distancePreviousThis;
            if (anglePrevious > angleSineSquare)
                return false;
            double angleNext = distanceFromLine / distanceThisNext;
            if (angleNext > angleSineSquare)
                return false;

            //in all other cases, we delete it
            return true;
        }
Ejemplo n.º 10
0
        public void DeleteWaypoint(WayPoint wp)
        {
            if (wp.PreviousWaypoint != null)
                wp.PreviousWaypoint.NextWaypoint = wp.NextWaypoint;
            else
                _FirstWayPoint = wp.NextWaypoint;

            if (wp.NextWaypoint != null)
                wp.NextWaypoint.PreviousWaypoint = wp.PreviousWaypoint;
            else
                _LastWayPoint = wp.PreviousWaypoint;

            if (!_Updating)
                CreateListFromPoints();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Connect the WayPoints to their neighbours.
        /// </summary>
        public void ConnectWayPoints()
        {
            if (trkptField.Count > 0)
                _FirstWayPoint = trkptField[0];
            else
            {
                _FirstWayPoint = null;
                _LastWayPoint = null;
            }

            int index = 0;
            WayPoint previousWayPoint = null;
            foreach (WayPoint wp in trkptField)
            {
                index++;
                wp.Index = index;
                wp.PreviousWaypoint = previousWayPoint;
                if (previousWayPoint != null)
                    previousWayPoint.NextWaypoint = wp;
                wp.NextWaypoint = null;
                previousWayPoint = wp;
                _LastWayPoint = wp;
            }
        }