Exemplo n.º 1
0
        // keep in mind to lock(m_waypointsAll)
        public static void addWaypoint(Waypoint wp)
        {
            WaypointsCache.pushBoundaries(wp.Location);		// need this for files dropped on the icon at start, or on the program

            /*
                        if (wp.Location.X > -127 || wp.Location.X < -130 || wp.Location.Y > 45 || wp.Location.Y < 43)
                        {
                            return;
                        }
                        */

            Track _currentTrack;

            if(currentTrack != null && wp.TrackId == currentTrack.Id)		// save some time
            {
                currentTrack.insertWaypoint(wp);
            }
            else if(wp.TrackId != -1 && (_currentTrack=WaypointsCache.getTrackById(wp.TrackId)) != null)
            {
                _currentTrack.insertWaypoint(wp);
            }
            else
            {
                //double lng = wp.Location.Lng;
                double lat = wp.Location.Lat;

                int ii = 0;
                for (ii=0; ii < m_waypointsAll.Count ;ii++)
                {
                    Waypoint other = (Waypoint)m_waypointsAll[ii];
                    double lngo = other.Location.Lng;
                    double lato = other.Location.Lat;

                    //if(lngo == lng)
                    if(lato == lat)
                    {
                        if(wp.LiveObjectType != LiveObjectTypes.LiveObjectTypeTrackpoint
                            && wp.LiveObjectType != LiveObjectTypes.LiveObjectTypeRoutepoint
                            && wp.sameAs(other))
                        {
                            //LibSys.StatusBar.Trace(" ---- ignored duplicate waypoint (orig from " + other.Source + ") : " + wp);
                            return;		// ignore if it ain't new, but push boundaries for zooming
                        }
                    }
                        //else if(lngo < lng)	// sort east to west
                        //else if(lato > lat)	// sort south to north
                    else if(lato < lat)	// sort north to south
                    {
                        break;
                    }
                }
                if(ii == m_waypointsAll.Count)
                {
                    m_waypointsAll.Add(wp);
                }
                else
                {
                    m_waypointsAll.Insert(ii, wp);
                }
            }

            // invalidating every object's drawing area is VERY expensive, we do PictureManager.Refresh() instead
            // at the end of interpreting all files. So the next line is commented out.
            //DynamicObjectCreateCallback(wp);
        }
Exemplo n.º 2
0
        private static int InsertWaypointToDisplay(Waypoint wp)
        {
            double lng = wp.Location.Lng;
            double lat = wp.Location.Lat;

            int ii;
            for (ii=0; ii < m_waypointsDisplayed.Count ;ii++)
            {
                Waypoint other = (Waypoint)m_waypointsDisplayed[ii];
                double lato = other.Location.Lat;

                if(lato == lat)
                {
                    if(wp.sameAs(other))
                    {
                        //LibSys.StatusBar.Trace(" ---- ignored duplicate waypoint (orig from " + other.Source + ") : " + wp);
                        return 0;		// ignore if it ain't new
                    }
                }
                else if(lato < lat)	// sort north to south
                {
                    break;
                }
            }
            if(ii == m_waypointsDisplayed.Count)
            {
                m_waypointsDisplayed.Add(wp);
            }
            else
            {
                m_waypointsDisplayed.Insert(ii, wp);
            }
            m_waypointsDisplayedNotSorted.Add(wp);
            return 1;
        }