Example #1
0
        private void CalculateLod()
        {
            if (_imageSource == null)
            {
                return;
            }

            if (_map != null)
            {
                _map.Clear();
                _map = null;
            }

            var s = new RainforestLodSimplifier(ImageSource.ConvertToBitmap(_numPixelWidth).ToImageSource(), LevelOfDetail);

            _map = s.CalculateLod();
            UpdateLayout();
        }
Example #2
0
        private static void GenerateLODFile(int lod)
        {
            string fileName = lod + ".lod";

            Console.WriteLine("Generating file: " + fileName);

            // Open file for writing
            FileStream file = File.OpenWrite(fileName);

            // Calculate LOD of map
            var rainforestLodSimplifier          = new RainforestLodSimplifier(_mapImageSource, lod + 1);
            Dictionary <Int32Rect, byte> lodDict = rainforestLodSimplifier.CalculateLod();

            // Merge these together!
            var concurrentDictionary = new ConcurrentDictionary <Int32Rect, byte>();

            Parallel.ForEach(lodDict, (entry) =>
            {
                byte mapValue      = ConvertMapValueToTile(entry.Value);
                byte combinedValue = mapValue;

                concurrentDictionary[entry.Key] = combinedValue;
            });

            Console.WriteLine();

            // Write our special format to the file
            var lodFileFormatWriter = new LODFileFormatWriter();

            lodFileFormatWriter.Write(file, concurrentDictionary.ToDictionary(c => c.Key, c => c.Value));

            file.Close();

            Console.WriteLine("Done generating: " + fileName);
            Console.WriteLine();
        }