Пример #1
0
        public IGPSBounds RelevantArea()
        {
            IGPSBounds area = null;

            if (m_TrailRoutes.Count > 0)
            {
                area = TrailMapPolyline.getGPSBounds(m_TrailRoutes);
            }
            if (m_TrailPoints.Count > 0)
            {
                //Normal trails all have the same radius, should not be much difference anyway
                float      highlightRadius = m_TrailPoints[0].Radius;
                IGPSBounds area2           = TrailGPSLocation.getGPSBounds(m_TrailPoints, 2 * highlightRadius);
                area = this.Union(area, area2);
            }
            if (m_SplitPoints.Count > 0)
            {
                IGPSBounds area2 = SplitGPSLocation.getGPSBounds(m_SplitPoints);
                area = this.Union(area, area2);
            }
            if (m_MarkedTrailRoutes.Count > 0 || m_MarkedTrailRoutesNoShow.Count > 0)
            {
                IGPSBounds area2 = Union(TrailMapPolyline.getGPSBounds(m_MarkedTrailRoutes),
                                         TrailMapPolyline.getGPSBounds(m_MarkedTrailRoutesNoShow));
                area = this.Union(area, area2);
            }
            return(area);
        }
Пример #2
0
 public new void DoZoom(IGPSBounds area)
 {
     //Note no m_showPage here, can be done when creating tracks
     base.DoZoom(area);
     if (m_extraMapLayer != null)
     {
         m_extraMapLayer.DoZoom(area);
     }
 }
Пример #3
0
        public bool IsInBounds(IActivity activity)
        {
            bool result = false;

            if (activity != null && activity.GPSRoute != null)
            {
                IGPSBounds gpsBounds = ActivityCache.GpsBoundsCache(activity);
                result = this.IsInBounds(gpsBounds);
            }
            return(result);
        }
Пример #4
0
 public new void SetLocation(IGPSBounds area)
 {
     if (m_showPage)
     {
         base.SetLocation(area);
         if (m_extraMapLayer != null)
         {
             m_extraMapLayer.SetLocation(area);
         }
     }
 }
Пример #5
0
 public new void EnsureVisible(IGPSBounds area)
 {
     if (m_showPage)
     {
         base.EnsureVisible(area);
         if (m_extraMapLayer != null)
         {
             m_extraMapLayer.EnsureVisible(area);
         }
     }
 }
Пример #6
0
 public void EnsureVisible(IGPSBounds area)
 {
     if (area != null)
     {
         double zoom = this.MapControl.Zoom;
         if (!this.MapControl.MapBounds.Contains(area))
         {
             area = this.MapControl.MapBounds.Union(area);
             zoom = Math.Max(zoom, this.MapControl.ComputeZoomToFit(area));
             this.MapControl.SetLocation(area.Center, zoom);
         }
     }
 }
Пример #7
0
 public IGPSBounds Union(IGPSBounds area1, IGPSBounds area2)
 {
     if (area1 != null && area2 != null)
     {
         area1 = area1.Union(area2);
     }
     else
     {
         //At least one of the areas is null
         if (area2 != null)
         {
             area1 = area2;
         }
     }
     return(area1);
 }
Пример #8
0
 public void SetLocation(IGPSBounds area)
 {
     if (area != null)
     {
         double zoom    = this.MapControl.Zoom;
         double newZoom = zoom;
         if (!this.MapControl.MapBounds.Contains(area))
         {
             newZoom = Math.Max(zoom, this.MapControl.ComputeZoomToFit(area));
         }
         if (newZoom != zoom ||
             Math.Abs(area.Center.LatitudeDegrees - this.MapControl.MapBounds.Center.LatitudeDegrees) / area.LatitudeDegrees > 0.03F ||
             Math.Abs(area.Center.LongitudeDegrees - this.MapControl.MapBounds.Center.LongitudeDegrees) / area.LongitudeDegrees > 0.03F)
         {
             this.MapControl.SetLocation(area.Center, newZoom);
         }
     }
 }
Пример #9
0
 public void DoZoom(IGPSBounds area)
 {
     if (area != null)
     {
         double zoom = this.MapControl.Zoom;
         //An area slightly larger than requested, to avoid zoom to often
         float      latOffset = area.LatitudeDegrees * 0.05F;
         float      lonOffset = area.LongitudeDegrees * 0.05F;
         IGPSBounds area2     = new GPSBounds(new GPSLocation(area.NorthLatitudeDegrees + latOffset, area.WestLongitudeDegrees - lonOffset),
                                              new GPSLocation(area.SouthLatitudeDegrees - latOffset, area.EastLongitudeDegrees + lonOffset));
         double newZoom = this.MapControl.ComputeZoomToFit(area2);
         //Avoid constantly calling SetLocation, slows down
         if (!this.MapControl.MapBounds.Contains(area) || Math.Abs(zoom - newZoom) > 2)
         {
             this.MapControl.SetLocation(area.Center, newZoom);
         }
     }
 }
Пример #10
0
        public static IGPSBounds getGPSBounds(IDictionary <string, MapPolyline> polylines)
        {
            IGPSBounds area = null;

            foreach (MapPolyline m in polylines.Values)
            {
                GPSBounds area2 = GPSBounds.FromGPSPoints(m.Locations);
                if (area2 != null)
                {
                    if (area == null)
                    {
                        area = area2;
                    }
                    else
                    {
                        area = (GPSBounds)area.Union(area2);
                    }
                }
            }
            return(area);
        }
Пример #11
0
        private bool IsInBounds(IGPSBounds activityBounds)
        {
            if (null == activityBounds || this.TrailLocations.Count == 0)
            {
                return(false);
            }
            if (this.GpsBounds == null)
            {
                return(false);
            }
            //Have to adjust as ST will not consider i.e. 11,9453<11,92103<11,92104
            IGPSBounds a2 = activityBounds;

            if (this.GpsBounds.NorthLatitudeDegrees == this.GpsBounds.SouthLatitudeDegrees ||
                this.GpsBounds.WestLongitudeDegrees == this.GpsBounds.EastLongitudeDegrees)
            {
                a2 = new GPSBounds(
                    new GPSLocation(activityBounds.NorthLatitudeDegrees + 0.01F, activityBounds.WestLongitudeDegrees - 0.01F),
                    new GPSLocation(activityBounds.SouthLatitudeDegrees - 0.01F, activityBounds.EastLongitudeDegrees + 0.01F));
            }
            return(a2.Contains(this.GpsBounds));
        }
Пример #12
0
        private void RefreshOverlays(bool clear)
        {
            if (clear || MapControlChanged)
            {
                ClearOverlays();
                ResetMapControl();
            }

            if (!m_showPage)
            {
                return;
            }

            IGPSBounds          windowBounds  = MapControlBounds;
            IList <IMapOverlay> addedOverlays = new List <IMapOverlay>();

            //RouteOverlay
            //Only add a route exactly once, prefer marked routes
            IDictionary <IList <IGPSPoint>, MapPolyline> allRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>();
            IDictionary <IList <IGPSPoint>, MapPolyline> dupRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>();

            foreach (KeyValuePair <string, MapPolyline> pair in m_MarkedTrailRoutes)
            {
                if (!allRoutes.ContainsKey(pair.Value.Locations))
                {
                    allRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value));
                }
            }
            foreach (KeyValuePair <string, MapPolyline> pair in m_TrailRoutes)
            {
                if (!allRoutes.ContainsKey(pair.Value.Locations))
                {
                    allRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value));
                }
                else if (!dupRoutes.ContainsKey(pair.Value.Locations))
                {
                    dupRoutes.Add(new KeyValuePair <IList <IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value));
                }
            }
            IDictionary <IList <IGPSPoint>, MapPolyline> visibleRoutes = new Dictionary <IList <IGPSPoint>, MapPolyline>();

            foreach (KeyValuePair <IList <IGPSPoint>, MapPolyline> pair in allRoutes)
            {
                IList <IGPSPoint> r = new List <IGPSPoint>();
                foreach (IGPSPoint point in pair.Value.Locations)
                {
                    if (windowBounds.Contains(point))
                    {
                        visibleRoutes.Add(pair);
                        break;
                    }
                }
                //check for route in bounds only - the following does not seem to speed up
                //foreach (IGPSPoint point in pair.Value.Locations)
                //{
                //    if (windowBounds.Contains(point))
                //    {
                //        r.Add(point);
                //    }
                //}
                //if (r.Count > 0)
                //{
                //    MapPolyline m = new MapPolyline(r, pair.Value.LineWidth, pair.Value.LineColor);
                //    visibleRoutes.Add(pair.Key, m);
                //}
            }
            IDictionary <IList <IGPSPoint>, IMapOverlay> newRouteOverlays = new Dictionary <IList <IGPSPoint>, IMapOverlay>();

            foreach (KeyValuePair <IList <IGPSPoint>, MapPolyline> pair in visibleRoutes)
            {
                MapPolyline m = pair.Value;
                newRouteOverlays.Add(m.Locations, m);
                if ((!m_scalingChanged) &&
                    m_routeOverlays.ContainsKey(m.Locations) &&
                    !dupRoutes.ContainsKey(m.Locations))
                {
                    //No need to refresh this point
                    m_routeOverlays.Remove(m.Locations);
                }
                else
                {
                    addedOverlays.Add(m);
                }
            }

            //TrailPoints
            IDictionary <IGPSPoint, IMapOverlay> newPointOverlays = new Dictionary <IGPSPoint, IMapOverlay>();

            foreach (TrailGPSLocation location in m_TrailPoints)
            {
                PointMapMarker pointOverlay = new PointMapMarker(location, getCircleIcon(this.MapControl, location.Radius), MouseEvents && (this.m_editTrail != null));
                if (this.MouseEvents && location.Name != "DebugNotClickableDebug")
                {
                    pointOverlay.MouseDown += new MouseEventHandler(pointOverlay_MouseDown);
                    pointOverlay.MouseUp   += new MouseEventHandler(pointOverlay_MouseUp);
                }
                if (!newPointOverlays.ContainsKey(location))
                {
                    newPointOverlays.Add(location, pointOverlay);
                }
                addedOverlays.Add(pointOverlay);
            }

            //SplitPoints
            foreach (SplitGPSLocation location in m_SplitPoints)
            {
                PointMapMarker pointOverlay = new PointMapMarker(location, getRhombusIcon(location.PointColor), false);
                if (!newPointOverlays.ContainsKey(location))
                {
                    newPointOverlays.Add(location, pointOverlay);
                }
                addedOverlays.Add(pointOverlay);
            }

            // Draw overlay
            if (0 == newPointOverlays.Count && 0 == visibleRoutes.Count)
            {
                return;
            }

            m_scalingChanged = false;
            if (!clear && !MapControlChanged)
            {
                ClearOverlays();
            }
            MapControl.AddOverlays(addedOverlays);
            m_pointOverlays = newPointOverlays;
            m_routeOverlays = newRouteOverlays;
            if (m_extraMapLayer != null)
            {
                try
                {
                    //Remove overlays are not working properly, the Map is not very usable
                    m_extraMapLayer.MapControl.AddOverlays(addedOverlays);
                }
                catch (Exception) {}
                m_extraMapLayer.m_pointOverlays = newPointOverlays;
                m_extraMapLayer.m_routeOverlays = newRouteOverlays;
            }
        }
Пример #13
0
 public void DoZoom(IGPSBounds area)
 {
     if (m_showPage)
     {
         if (area != null)
         {
             this.MapControl.SetLocation(area.Center,
             this.MapControl.ComputeZoomToFit(area));
             if (m_extraMapLayer != null)
             {
                 m_extraMapLayer.MapControl.SetLocation(area.Center,
                 m_extraMapLayer.MapControl.ComputeZoomToFit(area));
             }
         }
     }
 }
Пример #14
0
 public IGPSBounds Union(IGPSBounds area1, IGPSBounds area2)
 {
     if (area1 != null && area2 != null)
     {
         area1 = area1.Union(area2);
     }
     else
     {
         //At least one of the areas is null
         if (area2 != null)
         {
             area1 = area2;
         }
     }
     return area1;
 }