Пример #1
0
        /// <summary>
        /// Perform delineation for the specified region.
        /// </summary>
        /// <param name="inputGrid">Input data set.</param>
        /// <param name="outputDir">Output directory where the delineationated image tiles have to be persisted.</param>
        /// <param name="referenceImagePath">Reference image tiles folder path.</param>
        /// <param name="colorMapPath">Color map file path.</param>
        /// <param name="orientation">Color orientation.</param>
        /// <param name="maxLevel">Maximum level of the pyramid.</param>
        private static void DelineateImage(string inputGrid, string outputDir, string referenceImagePath, string colorMapPath, ColorMapOrientation orientation, int maxLevel)
        {
            Trace.TraceInformation("{0}: Starting delineation..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
            Trace.TraceInformation("{0}: Reading dataset..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
            ImageFormat imageFormat = ImageFormat.Png;

            // Read and parse the input dataset.
            var equirectangularGrid = new EquirectangularGrid(inputGrid);

            equirectangularGrid.MaximumLevelsOfDetail = maxLevel;

            // Define a color map to lookup color pixel for double values.
            var colorMap = new EquirectangularColorMap(colorMapPath, equirectangularGrid, orientation);

            // Define serialization mechanism for storing/retrieving reference tiles.
            var referenceTileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(referenceImagePath), ImageFormat.Png);

            // Define an instance of ITielCreator to create the tiles.
            var tileSerializer   = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            var imageTileCreator = new MaskedTileCreator(colorMap, tileSerializer, true);

            // Start building the image tiles.
            var tileGenerator = new TileGenerator(imageTileCreator);

            imageTileCreator.ReferenceTileSerializer = referenceTileSerializer;
            tileGenerator.Generate(maxLevel);

            string fileName = Path.GetFileNameWithoutExtension(inputGrid);

            // Generate Thumbnail Images.
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");

            TileHelper.GenerateThumbnail(tileSerializer.GetFileName(0, 0, 0), 96, 45, thumbnailFile);

            // Create and save WTML file.
            string         textureTilePath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());
            WtmlCollection wtmlCollection  = new WtmlCollection(fileName, thumbnailFile, textureTilePath, equirectangularGrid.MaximumLevelsOfDetail, ProjectionTypes.Toast);
            string         path            = Path.Combine(outputDir, fileName + ".wtml");

            wtmlCollection.Save(path);
            Trace.TraceInformation("{0}: Collection successfully generated.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
        }
Пример #2
0
        /// <summary>
        /// Perform delineation for the specified region.
        /// </summary>
        /// <param name="inputGrid">Input data set.</param>
        /// <param name="outputDir">Output directory where the delineationated image tiles have to be persisted.</param>
        /// <param name="referenceImagePath">Reference image tiles folder path.</param>
        /// <param name="colorMapPath">Color map file path.</param>
        /// <param name="orientation">Color orientation.</param>
        /// <param name="maxLevel">Maximum level of the pyramid.</param>
        private static void DelineateImage(string inputGrid, string outputDir, string referenceImagePath, string colorMapPath, ColorMapOrientation orientation, int maxLevel)
        {
            Trace.TraceInformation("{0}: Starting delineation..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
            Trace.TraceInformation("{0}: Reading dataset..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
            ImageFormat imageFormat = ImageFormat.Png;

            // Read and parse the input dataset.
            var equirectangularGrid = new EquirectangularGrid(inputGrid);
            equirectangularGrid.MaximumLevelsOfDetail = maxLevel;

            // Define a color map to lookup color pixel for double values.
            var colorMap = new EquirectangularColorMap(colorMapPath, equirectangularGrid, orientation);

            // Define serialization mechanism for storing/retrieving reference tiles.
            var referenceTileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(referenceImagePath), ImageFormat.Png);

            // Define an instance of ITielCreator to create the tiles.
            var tileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            var imageTileCreator = new MaskedTileCreator(colorMap, tileSerializer, true);

            // Start building the image tiles.
            var tileGenerator = new TileGenerator(imageTileCreator);
            imageTileCreator.ReferenceTileSerializer = referenceTileSerializer;
            tileGenerator.Generate(maxLevel);

            string fileName = Path.GetFileNameWithoutExtension(inputGrid);

            // Generate Thumbnail Images.
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");
            TileHelper.GenerateThumbnail(tileSerializer.GetFileName(0, 0, 0), 96, 45, thumbnailFile);

            // Create and save WTML file.
            string textureTilePath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, textureTilePath, equirectangularGrid.MaximumLevelsOfDetail, ProjectionTypes.Toast);
            string path = Path.Combine(outputDir, fileName + ".wtml");
            wtmlCollection.Save(path);
            Trace.TraceInformation("{0}: Collection successfully generated.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
        }