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 }); } }
private void UpdateExtent() { var spanX = _width * _resolution; var spanY = _height * _resolution; _extent = new BruTile.Extent(_center.X - spanX * 0.5f, _center.Y - spanY * 0.5f, _center.X + spanX * 0.5f, _center.Y + spanY * 0.5f); }
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 }); } }
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); }
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; 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("2008") > -1) { textBlock.Text = image.Name; } else { textBlock.Text = image.Published.Value.ToString("dd-MMM"); } 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("2008") == -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++; } RefreshMap(); }
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(); }
private Extent parseTiles(Extent extent, int level, List<BruTile.TileInfo> tis, jsTileInfo[] tiles) { foreach (var ti in tiles) { Match m = rex.Match(ti.Url); if (m.Success) { int x = Convert.ToInt32(m.Groups["x"].Value); int y = Convert.ToInt32(m.Groups["y"].Value); int z = Convert.ToInt32(m.Groups["z"].Value); Extent e = new BruTile.Extent( extent.MinX + ti.Left * Resolutions[level].UnitsPerPixel, extent.MaxY - (ti.Top + 256) * Resolutions[level].UnitsPerPixel, extent.MinX + (ti.Left + Width) * Resolutions[level].UnitsPerPixel, extent.MaxY - (ti.Top) * Resolutions[level].UnitsPerPixel ); if (e.Intersects(extent)) { tis.Add(new BruTile.GoogleMaps.GoogleV3TileInfo() { Url = ti.Url, Index = new TileIndex(x, y, ti.Url.GetHashCode()), Extent = e, ZIndex = ti.zIndex }); } } else { System.Diagnostics.Debug.WriteLine("Could not match " + ti.Url); } } System.Diagnostics.Debug.WriteLine("got " + tis.Count + " tiles"); return extent; }