Beispiel #1
0
        public Brush GetBrush(MapColors mc)
        {
            Color tmp = GetColor(mc);

            if (_bindsBrushStyle.ContainsKey(mc))
            {
                return(new HatchBrush(_bindsBrushStyle[mc], tmp, Color.Transparent));
            }
            else
            {
                return(new SolidBrush(tmp));
            }
        }
Beispiel #2
0
        public Color GetColor(MapColors mc)
        {
            Color tmp = Color.Gray;

            if (_bindsBrushColor.ContainsKey(mc))
            {
                tmp = _bindsBrushColor[mc];
            }
            if (!_bindsBrushColor.ContainsKey(mc) && (_bindsBrushColor.ContainsKey(MapColors.MapBackground)))
            {
                tmp = Color.FromArgb(255 - _bindsBrushColor[MapColors.MapBackground].R,
                                     255 - _bindsBrushColor[MapColors.MapBackground].G,
                                     255 - _bindsBrushColor[MapColors.MapBackground].B);
            }
            return(tmp);
        }
 public Color GetColor(MapColors mc)
 {
     Color tmp = Color.Gray;
     if (_bindsBrushColor.ContainsKey(mc))
         tmp = _bindsBrushColor[mc];
     if (!_bindsBrushColor.ContainsKey(mc) && (_bindsBrushColor.ContainsKey(MapColors.MapBackground)))
         tmp = Color.FromArgb(255 - _bindsBrushColor[MapColors.MapBackground].R,
             255 - _bindsBrushColor[MapColors.MapBackground].G,
             255 - _bindsBrushColor[MapColors.MapBackground].B);
     return tmp;
 }
 public Brush GetBrush(MapColors mc)
 {
     Color tmp = GetColor(mc);
     if (_bindsBrushStyle.ContainsKey(mc))
         return new HatchBrush(_bindsBrushStyle[mc], tmp,Color.Transparent);
     else
         return new SolidBrush(tmp);
 }
Beispiel #5
0
        public void AddTripTrails(Trip trip)
        {
            if (_tripTrailLayer != null)
            {
                _map.Layers.Remove(_tripTrailLayer);
            }

            if (_tripInfoLayer != null)
            {
                _map.Layers.Remove(_tripInfoLayer);
            }

            Features trailFeatures = new Features();
            Features infoFeatures  = new Features();

            int          lastSpeedColorIndex = -1;
            Point        lastPoint           = null;
            List <Point> points = new List <Point>();

            double?firstLat = null;
            double?firstLon = null;

            foreach (Video video in trip.Videos)
            {
                foreach (KeyValuePair <int, TrailItem> kvp in video.TrailItems.ToList())
                {
                    var item = kvp.Value;

                    if (item.Longitude == 0 && item.Latitude == 0)
                    {
                        continue;
                    }

                    if (firstLat == null)
                    {
                        firstLat = item.Latitude;
                        firstLon = item.Longitude;
                    }

                    var location = SphericalMercator.FromLonLat(item.Longitude, item.Latitude);

                    if (lastPoint != null && location.Distance(lastPoint) < 35)
                    {
                        continue;
                    }

                    infoFeatures.Add(new Feature()
                    {
                        Geometry    = location,
                        ["Video"]   = video,
                        ["Seconds"] = kvp.Key
                    });

                    lastPoint = location;
                    int index = MapColors.GetStyleIndexFromSpeed(item.SpeedMph);

                    if (index != lastSpeedColorIndex)
                    {
                        if (lastSpeedColorIndex != -1)
                        {
                            points.Add(location);
                        }

                        if (points.Count > 0)
                        {
                            List <IStyle> styleList = new List <IStyle> {
                                MapColors.LineStyles[lastSpeedColorIndex]
                            };
                            trailFeatures.Add(new Feature()
                            {
                                Geometry = new LineString(points),
                                Styles   = styleList
                            });
                        }
                        points.Clear();
                    }

                    points.Add(location);
                    lastSpeedColorIndex = index;
                }
            }

            _tripTrailLayer = new MemoryLayer
            {
                DataSource = new MemoryProvider()
                {
                    Features = trailFeatures
                },
                Name  = "TripLayer",
                Style = null
            };

            _tripInfoLayer = new MemoryLayer
            {
                DataSource = new MemoryProvider()
                {
                    Features = infoFeatures
                },
                Name  = "MoviesLayer",
                Style = new SymbolStyle
                {
                    SymbolScale  = 0.5,
                    SymbolOffset = new Offset(0, 0),
                    SymbolType   = SymbolType.Ellipse,
                    //Line = new Pen(Color.Black, 2),
                    //Fill = new Brush(Color.White),
                    //Opacity = 0.1
                    Line    = new Pen(Color.White, 0),
                    Fill    = new Brush(Color.Transparent),
                    Opacity = 0.0
                }
            };

            _map.Layers.Insert(1, _tripTrailLayer);

            //_map.Layers.Insert(1, _tripInfoLayer);
            _map.InfoLayers.Add(_tripInfoLayer);

            if (_positionLayer != null)
            {
                MemoryProvider dataSource = ((MemoryProvider)((MemoryLayer)_positionLayer).DataSource);
                dataSource.Features.Clear();
            }

            if (firstLat != null && firstLon != null)
            {
                MoveToArea((double)firstLat, (double)firstLon, 0.001);
            }

            MapControl.RefreshData();
        }