Esempio n. 1
0
        static void imageRequest_ImageRequestReceived(object sender, EventArgs e)
        {
            var _satelliteImages = (List <SatelliteImage>)sender;

            foreach (var _satelliteLayer in _satelliteImages)
            {
                var shouldAdd = false;
                foreach (var layer in _layerlist)
                {
                    if (layer.Equals(_satelliteLayer.Name))
                    {
                        shouldAdd = true;
                    }
                }

                if (!shouldAdd)
                {
                    continue;
                }

                var topLeft     = SphericalMercator.FromLonLat(_satelliteLayer.Extent.MinX, _satelliteLayer.Extent.MinY);
                var bottomRight = SphericalMercator.FromLonLat(_satelliteLayer.Extent.MaxX, _satelliteLayer.Extent.MaxY);
                var newExtend   = new BruTile.Extent(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);

                var schema = new SphericalMercatorWorldSchema {
                    Extent = newExtend
                };

                var max = _satelliteLayer.MaxLevel + 1;
                while (schema.Resolutions.Count > max)
                {
                    schema.Resolutions.RemoveAt(max);
                }
                var tms = new TmsTileSource(_satelliteLayer.UrlTileCache, schema);
                Current.Instance.LayerHelper.AddLayer(new TileLayer(tms)
                {
                    LayerName = _satelliteLayer.Name
                });
            }
        }
Esempio n. 2
0
        public void addForestLawLayer(SatelliteImage image, int positionIndex)
        {
            var topLeft     = SphericalMercator.FromLonLat(image.Extent.MinX, image.Extent.MinY);
            var bottomRight = SphericalMercator.FromLonLat(image.Extent.MaxX, image.Extent.MaxY);
            var newExtend   = new BruTile.Extent(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);

            var schema = new SphericalMercatorWorldSchema();

            schema.Extent = newExtend;

            var max = image.MaxLevel + 1;

            while (schema.Resolutions.Count > max)
            {
                schema.Resolutions.RemoveAt(max);
            }
            var tms = new TmsTileSource(image.UrlTileCache, schema);

            //EL NOMBRE DEL LAW LEYER SIEMPRE ES EL MISMO: RegionId + Constants.RegionLawLayerName
            Current.Instance.LayerHelper.InsertLayer(new TileLayer(tms)
            {
                LayerName = Current.Instance.Earthwatcher.PlayingRegion + Constants.RegionLawLayerName, Opacity = 0, Tag = image.Published.Value
            }, positionIndex);
        }
Esempio n. 3
0
        void CreateTimeLine()
        {
            //Genero los items del combo
            List <SatelliteImage> comboImages = new List <SatelliteImage>();

            foreach (var image in satelliteImages.OrderByDescending(x => x.Published))
            {
                if (!includedSatelliteImages.Any(x => x.Id == image.Id))
                {
                    comboImages.Add(image);
                }
            }
            this.ImagesCombo.ItemsSource = comboImages;

            DatesGrid.Children.Clear();
            DatesGrid.ColumnDefinitions.Clear();

            TimelineMarkersGrid.Children.Clear();
            TimelineMarkersGrid.ColumnDefinitions.Clear();

            int count = 0;

            Current.Instance.LayerHelper.RemoveByLayerType <TileLayer>();

            foreach (var image in includedSatelliteImages.OrderBy(x => x.Published))
            {
                DatesGrid.ColumnDefinitions.Add(new ColumnDefinition());
                TimelineMarkersGrid.ColumnDefinitions.Add(new ColumnDefinition());

                Ellipse ellipse = new Ellipse();
                ellipse.Width            = 12;
                ellipse.Height           = 12;
                ellipse.StrokeThickness  = 1;
                ellipse.IsHitTestVisible = false;
                ellipse.Fill             = new SolidColorBrush(Color.FromArgb(255, 170, 203, 13));
                ellipse.Stroke           = new SolidColorBrush(Color.FromArgb(255, 106, 126, 11));
                Grid.SetRow(ellipse, 1);

                TextBlock textBlock = new TextBlock();
                if (image.Name.IndexOf("base") > -1)
                {
                    textBlock.Text = image.Name.Substring(4);
                }
                else
                {
                    textBlock.Text = image.Published.Value.ToString("dd-MMM-yy");
                }
                textBlock.Foreground        = new SolidColorBrush(Colors.White);
                textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                textBlock.FontSize          = 13;
                textBlock.Tag          = image;
                textBlock.TextWrapping = TextWrapping.Wrap;
                if (includedSatelliteImages.Count() > 1 && image.Name.IndexOf("base") == -1)
                {
                    textBlock.Cursor = System.Windows.Input.Cursors.Hand;
                    textBlock.MouseLeftButtonDown += textBlock_MouseLeftButtonDown;
                    textBlock.MouseEnter          += textBlock_MouseEnter;
                    textBlock.MouseLeave          += textBlock_MouseLeave;
                    ToolTipService.SetToolTip(textBlock, Labels.Layers10);
                }
                textBlock.FontFamily = new System.Windows.Media.FontFamily("/Earthwatchers.UI;component/Resources/MyriadPro-Regular.otf#Myriad Pro");
                Grid.SetColumn(textBlock, count);
                Grid.SetColumn(ellipse, count);

                if (count % 2 == 0)
                {
                    Grid.SetRow(textBlock, 0);
                }
                else
                {
                    Grid.SetRow(textBlock, 2);
                }

                double opacity = 0;
                if (count == includedSatelliteImages.Count() - 1)
                {
                    textBlock.Margin = new Thickness(0, 0, 5, 0);
                    textBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    ellipse.HorizontalAlignment   = System.Windows.HorizontalAlignment.Right;
                    opacity = 1;
                }
                else if (count == 0)
                {
                    textBlock.Margin            = new Thickness(5, 0, 0, 0);
                    ellipse.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                }
                else
                {
                    textBlock.Margin = new Thickness(0, 0, 0, 3);
                    textBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    ellipse.HorizontalAlignment   = System.Windows.HorizontalAlignment.Center;
                }
                this.DatesGrid.Children.Add(textBlock);
                this.TimelineMarkersGrid.Children.Add(ellipse);

                if (Current.Instance.LayerHelper.FindLayer(textBlock.Text) == null)
                {
                    var topLeft     = SphericalMercator.FromLonLat(image.Extent.MinX, image.Extent.MinY);
                    var bottomRight = SphericalMercator.FromLonLat(image.Extent.MaxX, image.Extent.MaxY);
                    var newExtend   = new BruTile.Extent(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);

                    var schema = new SphericalMercatorWorldSchema();
                    schema.Extent = newExtend;

                    var max = image.MaxLevel + 1;
                    while (schema.Resolutions.Count > max)
                    {
                        schema.Resolutions.RemoveAt(max);
                    }
                    var tms = new TmsTileSource(image.UrlTileCache, schema);
                    Current.Instance.LayerHelper.InsertLayer(new TileLayer(tms)
                    {
                        LayerName = textBlock.Text, Opacity = opacity, Tag = image.Published.Value
                    }, count);
                }
                count++;
            }

            if (forestLaw != null && Current.Instance.LayerHelper.FindLayer(Current.Instance.Earthwatcher.PlayingRegion + Constants.RegionLawLayerName) == null)
            {
                layerHelper.addForestLawLayer(forestLaw, count);
            }

            RefreshMap();
        }