public static async Task ProcessRawData(StandardChunkMetadata template, TraceListener log) { bool doMore = false; if (template.ZoomLevel <= Heights.Current.SourceDataZoom) { var ok = await Heights.Current.ExistsComputedChunk(template, log); log?.Write(ok ? "." : ("Heights:" + Heights.Current.GetShortFilename(template) + ":" + "missing")); doMore = true; } if (template.ZoomLevel <= Images.Current.SourceDataZoom) { var ok = await Images.Current.ExistsComputedChunk(template, log); log?.Write(ok ? "." : ("Images:" + Images.Current.GetShortFilename(template) + ":" + "missing")); doMore = true; } if (!doMore) { return; } foreach (var c in template.GetChildChunks()) { await ProcessRawData(c, log); } }
public void Execute(string channelName, int fromPostId, int toPostId) { if (string.IsNullOrWhiteSpace(channelName)) { throw new ArgumentException(nameof(channelName)); } _traceListener.WriteLine($"Start getting '{channelName}' posts ({fromPostId} to {toPostId})...\n"); try { for (int postId = fromPostId; postId <= toPostId; postId++) { _traceListener.Write($"\nStart getting post #{postId} "); var telegramPost = _channelTools.GetPost(channelName, postId); if (telegramPost == null) { _traceListener.WriteLine($"\n\tCould not read post #{postId}."); } else { foreach (var postSaver in _postSavers) { SpinAnimation.Start(250); try { postSaver.Save(telegramPost); SpinAnimation.Stop(); _traceListener.Write($"\n\t{postSaver.GetType().Name} has saved post #{postId}."); } catch (Exception ex) { _traceListener.WriteLine($"\n\tError in storing {postId} from '{channelName}'."); _traceListener.WriteLine($"\t\tError:\n\t\t{ex}\n"); } } } } } catch (Exception ex) { _traceListener.WriteLine("\nError:"); _traceListener.WriteLine($"\t{ex.Message}"); } _traceListener.WriteLine($"\nFinished storing posts #{fromPostId} to #{toPostId} from channel '{channelName}'.\n"); }
public static void Test(TraceListener log) { KDNode root = KDNode.Process(new Tuple <Vector2d, int>[] { new Tuple <Vector2d, int>(new Vector2d(+0, +0), 0), new Tuple <Vector2d, int>(new Vector2d(+1, +1), 1), new Tuple <Vector2d, int>(new Vector2d(-1, +1), 2), new Tuple <Vector2d, int>(new Vector2d(+1, -1), 3), new Tuple <Vector2d, int>(new Vector2d(-1, -1), 4), new Tuple <Vector2d, int>(new Vector2d(-2, -0), 5), }); log?.WriteLine(root); double x = -2.0; double y = 0.1; Vector2d buff = new Vector2d(); for (y = 2.0; y > -2; y -= 0.25) { for (x = -3.0; x < 3; x += 0.25) { buff.X = x; buff.Y = y; var ret = root.GetNearest(ref buff); log?.Write(ret); } log?.WriteLine(""); } }
private static async Task NewMethod(TraceListener log, Action <Stream> drawToScreen) { var x = await BlobHelper.GetFileNames("mapv8", null, log); var y = x .Select(p => new { Name = p, P = p.Split('.') }) .Select(p => new { p.Name, Base = StandardChunkMetadata.ParseBase(p.P[0]), V = p.P[1], Ext = p.P[2] }) .GroupBy(p => new { p.Ext, p.V, p.Base.ZoomLevel }) .Select(p => new { p.Key.Ext, p.Key.V, p.Key.ZoomLevel, Data = p.Select(q => new { q.Name, q.Base }).ToArray() }) .OrderBy(p => p.ZoomLevel) .ThenBy(p => p.Ext) .ThenBy(p => p.V) .ToArray(); var baseBmp = new DirectBitmap(1000, 1000); baseBmp.SetAllPixels(new MyColor(255, 255, 255)); foreach (var dfgdfg in y.Where(p => p.Ext == "jpeg" && p.ZoomLevel == 6)) { var lats = dfgdfg.Data.Select(p => p.Base.LatLo.Abs).Distinct().OrderBy(p => p).ToArray(); var lons = dfgdfg.Data.Select(p => p.Base.LonLo.Abs).Distinct().OrderBy(p => p).ToArray(); if (dfgdfg.Ext == "jpeg") { for (int i = 0; i < lats.Length; i++) { for (int j = 0; j < lons.Length; j++) { var t = dfgdfg.Data.FirstOrDefault(p => p.Base.LatLo.Abs == lats[i] && p.Base.LonLo.Abs == lons[j])?.Base; if (t != null) { var tmpImg = await JpegImages.Current.GetData(t, log); var gggg = new DirectBitmap(tmpImg); //device.RenderInto(chunkBmp); baseBmp.DrawAt(gggg, j, i, lons.Length, lats.Length); drawToScreen?.Invoke(baseBmp.GetStream(OutputType.PNG)); } } } } else if (dfgdfg.Ext == "hdata") { } else if (dfgdfg.Ext == "idata") { } else if (dfgdfg.Ext == "mdata") { } else { } log?.WriteLine(dfgdfg.Ext + "\t" + dfgdfg.ZoomLevel + "\t" + dfgdfg.V); for (int i = 0; i < lats.Length; i++) { for (int j = 0; j < lons.Length; j++) { log?.Write(dfgdfg.Data.Any(p => p.Base.LatLo.Abs == lats[i] && p.Base.LonLo.Abs == lons[j]) ? "X" : " "); } log?.WriteLine(""); } } }
public override void Write(string message) { _defListener.Write(message); }
public override void Write(string message) { _listener.Write("[helloTrace]" + message); }
public static async Task Test12(string outputFolder, TraceListener log, Action <MemoryStream> getBitmap = null) { var lat = Angle.FromDecimalDegrees(47.6867797); var lon = Angle.FromDecimalDegrees(-122.2907541); for (int i = 0; i <= StandardChunkMetadata.MaxZoomLevel; i++) { var k1 = StandardChunkMetadata.GetRangeContaingPoint(lat, lon, i); log?.WriteLine(i + ", 1: " + k1); } log?.WriteLine(lat.ToLatString() + "," + lon.ToLonString()); for (int zoomLevel = StandardChunkMetadata.MaxZoomLevel; zoomLevel >= 0; zoomLevel--) { var kay = StandardChunkMetadata.GetKey(lat.Fourths, lon.Fourths, zoomLevel); var xxx = StandardChunkMetadata.GetRangeFromKey(kay); var cc = StandardChunkMetadata.GetRangeContaingPoint(lat, lon, zoomLevel); if (cc == null) { log?.WriteLine("Chunk is null"); } else { log?.Write(zoomLevel + "\t" + cc.LatDelta); log?.WriteLine("\t" + cc.LatLo.ToLatString() + "," + cc.LonLo.ToLonString() + ", " + cc.LatHi.ToLatString() + "," + cc.LonHi.ToLonString()); var template = cc; try { var pixels2 = await Heights.Current.GetData(template, log); if (pixels2 != null) { Utils.WriteImageFile(pixels2, Path.Combine(outputFolder, "AChunkH" + zoomLevel + ".png"), a => Utils.GetColorForHeight(a), OutputType.JPEG); getBitmap?.Invoke(Utils.GetBitmap(pixels2, a => Utils.GetColorForHeight(a), OutputType.JPEG)); } } catch (Exception ex) { log?.WriteLine(ex.Message); } try { var pixels = await Images.Current.GetData(template, log); if (pixels != null) { Utils.WriteImageFile(pixels, Path.Combine(outputFolder, "AChunkC" + zoomLevel + ".png"), a => a, OutputType.JPEG); getBitmap?.Invoke(Utils.GetBitmap(pixels, a => a, OutputType.JPEG)); } } catch (Exception ex) { log?.WriteLine(ex.Message); } } } }
public override void Write(string message) => core.Write(message);
public override void Write(string message) => Lock(() => listener.Write(message));