public HttpResponseMessage <List <string> > GetVerifiedLandsGeoHexCodes(Earthwatcher earthwatcher, HttpRequestMessage <Earthwatcher> request) { try { return(new HttpResponseMessage <List <string> >(landRepository.GetVerifiedLandsGeoHexCodes(earthwatcher.Id, earthwatcher.IsPowerUser)) { StatusCode = HttpStatusCode.OK }); } catch (Exception ex) { return(new HttpResponseMessage <List <string> >(new List <string> { ex.Message }) { StatusCode = HttpStatusCode.InternalServerError }); } }
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); } }