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 static ITileSchema GetTileSchema() { var schema = new SphericalMercatorWorldSchema(); schema.Resolutions.Clear(); schema.Resolutions.Add(new Resolution { Id = "0", UnitsPerPixel = 156543.033900000 }); schema.Resolutions.Add(new Resolution { Id = "1", UnitsPerPixel = 78271.516950000 }); return schema; }
public void TestSphericalMercatorWorldSchema() { string message; var s1 = new SphericalMercatorWorldSchema(); var s2 = SandD(s1); var equal = EqualTileSchemas(s1, s2, out message); Assert.IsTrue(equal, message); }
public GeodanWorldWmsTileSource() { var schema = new SphericalMercatorWorldSchema { Srs = "EPSG:900913" }; Provider = new WebTileProvider(CreateWmsRequest(schema)); Schema = schema; }
public GeodanWorldTmsTileSource() { const string url = "http://geoserver.nl/tiles/tilecache.aspx/1.0.0/world_GM/"; var parameters = new Dictionary<string, string>(); parameters.Add("seriveparam", "world_GM"); parameters.Add("uid", "4c6b3b161be3a2eb513b66b09a70f18d"); var request = new TmsRequest(new Uri(url), "png", parameters); Provider = new WebTileProvider(request); Schema = new SphericalMercatorWorldSchema(); }
public GeodanWorldTmsTileSource() { const string url = "http://geoserver.nl/tiles/tilecache.aspx/1.0.0/world_GM/"; var parameters = new Dictionary <string, string>(); parameters.Add("seriveparam", "world_GM"); parameters.Add("uid", "4c6b3b161be3a2eb513b66b09a70f18d"); var request = new TmsRequest(new Uri(url), "png", parameters); Provider = new WebTileProvider(request); Schema = new SphericalMercatorWorldSchema(); }
public void WorldToTileShouldReturnCorrectTileRange() { // arrange var expectedRange = new TileRange(1, 2); var schema = new SphericalMercatorWorldSchema(); var extent = new Extent(-15028130, -10018753, -10018755, -5009378); // act var range = TileTransform.WorldToTile(extent, 3, schema); // assert Assert.AreEqual(range, expectedRange); }
public static ITileSchema GetTileSchema() { var schema = new SphericalMercatorWorldSchema(); schema.Resolutions.Clear(); schema.Resolutions["0"] = new Resolution { Id = "0", UnitsPerPixel = 156543.033900000 }; schema.Resolutions["1"] = new Resolution { Id = "1", UnitsPerPixel = 78271.516950000 }; return(schema); }
public void TileToWorldShouldReturnCorrectExtent() { // arrange var range = new TileRange(1, 2); var schema = new SphericalMercatorWorldSchema(); var expectedExtent = new Extent(-15028131.257989, -10018754.173189, -10018754.173189, -5009377.088389); // act var extent = TileTransform.TileToWorld(range, 3, schema); // assert Assert.AreEqual(extent.MinX, expectedExtent.MinX, 0.0001); Assert.AreEqual(extent.MinY, expectedExtent.MinY, 0.0001); Assert.AreEqual(extent.MaxX, expectedExtent.MaxX, 0.0001); Assert.AreEqual(extent.MaxY, expectedExtent.MaxY, 0.0001); }
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); }
private static void DoWork(object sender, DoWorkEventArgs e) { string baseurl = landRepository.GetImageBaseUrl(true); string newurl = landRepository.GetImageBaseUrl(false); //Esto quedo obsoleto si no vamos a usar Azure /* storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=guardianes;AccountKey=vlG2nCfujtarq9++4+Qh21vZvD6c9+PUfNqR/9o+yc7AXifypGBVeEYgSRBMRx9AhLGoIcGJkgSqypduaaBnxw=="); blobClient = storageAccount.CreateCloudBlobClient(); if (includeHexagon) { container = blobClient.GetContainerReference("demand"); } else { container = blobClient.GetContainerReference("minigame"); } * */ //Encoder jgpEncoder = GetEncoder(ImageFormat.Jpeg); System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L); myEncoderParameters.Param[0] = myEncoderParameter; List<string> hexCodes = new List<string>(); if (string.IsNullOrEmpty(_geoHexKey)) { hexCodes = landRepository.GetVerifiedLandsGeoHexCodes(0, includeHexagon); } else { hexCodes.Add(_geoHexKey); } foreach (var geohex in hexCodes) { var zone = GeoHex.Decode(geohex); var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords()); var top = sphericalCoordinates.Max(s => s.Y); var bottom = sphericalCoordinates.Min(s => s.Y); var left = sphericalCoordinates.Min(s => s.X); var right = sphericalCoordinates.Max(s => s.X); var extent = new BruTile.Extent(left, bottom, right, top); var schema = new SphericalMercatorWorldSchema(); schema.Extent = extent; var tiles = schema.GetTilesInView(extent, 13); var newTop = tiles.Max(s => s.Extent.MaxY); var newBottom = tiles.Min(s => s.Extent.MinY); var newLeft = tiles.Min(s => s.Extent.MinX); var newRight = tiles.Max(s => s.Extent.MaxX); int[] cols = tiles.OrderBy(t => t.Index.Col).ThenByDescending(t => t.Index.Row).Select(t => t.Index.Col).Distinct().ToArray(); int[] rows = tiles.OrderBy(t => t.Index.Col).ThenByDescending(t => t.Index.Row).Select(t => t.Index.Row).Distinct().ToArray(); int width = 256 * cols.Length; int height = 256 * rows.Length; float hexLeft = (float)(((left - newLeft) * width) / (newRight - newLeft)); float hexTop = (float)(((top - newTop) * height) / (newBottom - newTop)); CreateCanvas(baseurl, geohex, tiles, width, height, hexLeft, hexTop, cols, rows, true); CreateCanvas(newurl, geohex, tiles, width, height, hexLeft, hexTop, cols, rows, false); } }
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(); }
public GeodanWorldWmsCTileSource() { Schema = new SphericalMercatorWorldSchema(); Provider = GetTileProvider(Schema); }
public DfaTileSource(string url) { Schema = new SphericalMercatorWorldSchema(); //Schema.Resolutions. Provider = new WebTileProvider(new TmsRequest(new Uri(url), "png")); }
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 static void DoWork(object sender, DoWorkEventArgs e) { //Esto quedo obsoleto si no vamos a usar Azure /* * storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=guardianes;AccountKey=vlG2nCfujtarq9++4+Qh21vZvD6c9+PUfNqR/9o+yc7AXifypGBVeEYgSRBMRx9AhLGoIcGJkgSqypduaaBnxw=="); * blobClient = storageAccount.CreateCloudBlobClient(); * if (includeHexagon) * { * container = blobClient.GetContainerReference("demand"); * } * else * { * container = blobClient.GetContainerReference("minigame"); * } * */ //Encoder jgpEncoder = GetEncoder(ImageFormat.Jpeg); System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L); myEncoderParameters.Param[0] = myEncoderParameter; List <string> hexCodes = new List <string>(); if (string.IsNullOrEmpty(_geoHexKey)) { hexCodes = landRepository.GetVerifiedLandsGeoHexCodes(0, includeHexagon); } else { hexCodes.Add(_geoHexKey); } foreach (var geohex in hexCodes) { string baseurl = landRepository.GetImageBaseUrl(true, geohex); string newurl = landRepository.GetImageBaseUrl(false, geohex); var zone = GeoHex.Decode(geohex); var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords()); var top = sphericalCoordinates.Max(s => s.Y); var bottom = sphericalCoordinates.Min(s => s.Y); var left = sphericalCoordinates.Min(s => s.X); var right = sphericalCoordinates.Max(s => s.X); var extent = new BruTile.Extent(left, bottom, right, top); var schema = new SphericalMercatorWorldSchema(); schema.Extent = extent; var tiles = schema.GetTilesInView(extent, 13); var newTop = tiles.Max(s => s.Extent.MaxY); var newBottom = tiles.Min(s => s.Extent.MinY); var newLeft = tiles.Min(s => s.Extent.MinX); var newRight = tiles.Max(s => s.Extent.MaxX); int[] cols = tiles.OrderBy(t => t.Index.Col).ThenByDescending(t => t.Index.Row).Select(t => t.Index.Col).Distinct().ToArray(); int[] rows = tiles.OrderBy(t => t.Index.Col).ThenByDescending(t => t.Index.Row).Select(t => t.Index.Row).Distinct().ToArray(); int width = 256 * cols.Length; int height = 256 * rows.Length; float hexLeft = (float)(((left - newLeft) * width) / (newRight - newLeft)); float hexTop = (float)(((top - newTop) * height) / (newBottom - newTop)); CreateCanvas(baseurl, geohex, tiles, width, height, hexLeft, hexTop, cols, rows, true); CreateCanvas(newurl, geohex, tiles, width, height, hexLeft, hexTop, cols, rows, false); } }