Example #1
0
        protected override async Task <ChunkHolder <float> > GenerateData(StandardChunkMetadata template, TraceListener log)
        {
            var ret = new ChunkHolder <float>(
                template.LatSteps, template.LonSteps,
                template.LatLo, template.LonLo,
                template.LatHi, template.LonHi,
                null,
                toDouble,
                fromDouble);

            int latMin = (int)(Math.Min(template.LatLo.DecimalDegree, template.LatHi.DecimalDegree) + 1.0e-5);
            int latMax = (int)(Math.Max(template.LatLo.DecimalDegree, template.LatHi.DecimalDegree) - 1.0e-5);
            int lonMin = (int)(Math.Min(template.LonLo.DecimalDegree, template.LonHi.DecimalDegree) + 1.0e-5);
            int lonMax = (int)(Math.Max(template.LonLo.DecimalDegree, template.LonHi.DecimalDegree) - 1.0e-5);
            var chunks = new List <ChunkHolder <float> >();

            for (int latInt = latMin; latInt <= latMax; latInt++)
            {
                for (int lonInt = lonMin; lonInt <= lonMax; lonInt++)
                {
                    chunks.Add(await UsgsRawChunks.GetRawHeightsInMeters(latInt, lonInt, log));
                }
            }

            ret.RenderChunksInto(chunks, aggregate, log);
            return(ret);
        }
Example #2
0
        public async Task <ChunkHolder <T> > ProcessRawData(StandardChunkMetadata template, TraceListener log)
        {
            var computedChunk = await GetComputedChunk(template, log);

            string          fileName = computedChunk.Item1;
            ChunkHolder <T> ret      = computedChunk.Item2;

            if (computedChunk.Item2 != null)
            {
                log?.WriteLine("Cached " + description + " chunk file exists: " + fileName);
                return(computedChunk.Item2);
            }

            log?.WriteLine("Cached " + description + " chunk file does not exist: " + fileName);

            if (template.ZoomLevel > this.SourceDataZoom)
            {
                // Nothing to do for processing
                return(null);
            }
            else if (template.ZoomLevel == this.SourceDataZoom)
            {
                log?.WriteLine("Starting generation...");
                ret = await GenerateData(template, log);
                await WriteChunk(ret, fileName, log);

                log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName);
                return(ret);
            }

            log?.WriteLine("Need to aggregate up from higher zoom data");
            var children = template.GetChildChunks();
            List <ChunkHolder <T> > chunks = new List <ChunkHolder <T> >();

            foreach (var child in children)
            {
                log?.WriteLine(child);
                chunks.Add(await ProcessRawData(child, log));
            }

            ret = new ChunkHolder <T>(
                template.LatSteps, template.LonSteps,
                template.LatLo, template.LonLo,
                template.LatHi, template.LonHi,
                null,
                toDouble,
                fromDouble);

            ret.RenderChunksInto(chunks, aggregate, log);
            await WriteChunk(ret, fileName, log);

            log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName);

            return(ret);
        }
Example #3
0
        public async Task <ChunkHolder <T> > GetData(StandardChunkMetadata template, TraceListener log)
        {
            var computedChunk = await GetComputedChunk(template, log);

            string          fileName = computedChunk.Item1;
            ChunkHolder <T> ret      = computedChunk.Item2;

            if (computedChunk.Item2 != null)
            {
                log?.WriteLine("Cached " + description + " chunk file exists: " + fileName);
                return(computedChunk.Item2);
            }

            log?.WriteLine("Cached " + description + " chunk file does not exist: " + fileName);

            if (template.ZoomLevel <= this.SourceDataZoom)
            {
                throw new MountainViewException("Source data is missing for chunk " + template.ToString());
                //log?.WriteLine("Starting generation...");
                //ret = await GenerateData(template, log);
                //await WriteChunk(ret, fileName, log);
                //log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName);
                //return ret;
            }

            log?.WriteLine("Need to interpolate from lower zoom data");
            var parent = template.GetParentChunk();
            var chunks = new ChunkHolder <T>[] { await GetData(parent, log) };

            ret = new ChunkHolder <T>(
                template.LatSteps, template.LonSteps,
                template.LatLo, template.LonLo,
                template.LatHi, template.LonHi,
                null,
                toDouble,
                fromDouble);
            ret.RenderChunksInto(chunks, aggregate, log);
            await WriteChunk(ret, fileName, log);

            log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName);
            return(ret);
        }
Example #4
0
        protected override async Task <ChunkHolder <MyColor> > GenerateData(StandardChunkMetadata template, TraceListener log)
        {
            var ret = new ChunkHolder <MyColor>(
                template.LatSteps, template.LonSteps,
                template.LatLo, template.LonLo,
                template.LatHi, template.LonHi,
                null,
                toDouble,
                fromDouble);

            var targetChunks = (await UsgsRawImageChunks.GetChunkMetadata(log))
                               .Select(p => new
            {
                p,
                Chunk = new ChunkMetadata(0, 0,
                                          Angle.FromDecimalDegrees(p.Points.Min(q => q.Item1)),
                                          Angle.FromDecimalDegrees(p.Points.Min(q => q.Item2)),
                                          Angle.FromDecimalDegrees(p.Points.Max(q => q.Item1)),
                                          Angle.FromDecimalDegrees(p.Points.Max(q => q.Item2)))
            })
                               .Where(p => !ret.Disjoint(p.Chunk))
                               .ToArray();

            var chunks = new List <ChunkHolder <MyColor> >();

            foreach (var tmp in targetChunks)
            {
                log?.WriteLine(tmp.Chunk);
                var col = await UsgsRawImageChunks.GetRawColors(
                    Angle.Add(tmp.Chunk.LatLo, Angle.Divide(tmp.Chunk.LatDelta, 2)),
                    Angle.Add(tmp.Chunk.LonLo, Angle.Divide(tmp.Chunk.LonDelta, 2)), log);

                if (col != null)
                {
                    chunks.Add(col);
                }
            }

            ret.RenderChunksInto(chunks, aggregate, log);
            return(ret);
        }