示例#1
0
        private static long[] GetVisibleChunks(Config config, int zoom, double R, TraceListener log)
        {
            int         numR             = 1000;
            List <long> orderedChunkKeys = new List <long>();

            for (int iR = 1; iR <= numR; iR++)
            {
                for (double iTheta = config.MinAngleDec; iTheta <= config.MaxAngleDec; iTheta += (config.MaxAngleDec - config.MinAngleDec) / numR)
                {
                    var dest = Utils.GetDestFromBearing(config.HomePoint, Angle.FromDecimalDegrees(iTheta), R * iR / numR);
                    var curr = StandardChunkMetadata.GetKey(dest.Lat.Fourths, dest.Lon.Fourths, zoom);
                    if (!orderedChunkKeys.Contains(curr))
                    {
                        orderedChunkKeys.Add(curr);
                    }
                }
            }

            orderedChunkKeys.Reverse();
            return(orderedChunkKeys.ToArray());
        }
示例#2
0
        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);
                    }
                }
            }
        }