Пример #1
0
        /// <summary>
        /// Processes the input equirectangular dataset.
        /// </summary>
        /// <param name="inputFile">
        /// Input File path.
        /// </param>
        /// <param name="outputDir">
        /// Output directory where pyramid is generated.
        /// </param>
        /// <param name="colorMapPath">
        /// Map of color map file.
        /// </param>
        /// <param name="orientation">
        /// Orientation of color map file.
        /// </param>
        /// <param name="projection">
        /// Projection type.
        /// </param>
        public static void ProcessEquirectangularGrid(string inputFile, string outputDir, string colorMapPath, ColorMapOrientation orientation, ProjectionTypes projection)
        {
            Trace.TraceInformation("{0}: Reading input dataset...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));

            // Get grid details from the input file
            var dataGridDetails = DataGridHelper.LoadFromFile(inputFile);

            // Populate the data grid using grid details
            var dataGrid = new DataGrid(dataGridDetails.Data, true);

            // Build a equirectangular projection grid map using the data grid and boundary details
            var equirectangularGridMap = new EquirectangularGridMap(dataGrid, dataGridDetails.Boundary);

            // Build a color map using equirectangular projection grid map
            var dataColorMap = new DataColorMap(colorMapPath, equirectangularGridMap, orientation, dataGridDetails.MinimumThreshold, dataGridDetails.MaximumThreshold);

            // Define an instance of ITileCreator to create image tiles.
            ITileCreator imageTileCreator = TileCreatorFactory.CreateImageTileCreator(dataColorMap, projection, outputDir);

            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            TileGenerator tileGenerator = new TileGenerator(imageTileCreator);
            int           zoomLevels    = 5;

            tileGenerator.Generate(zoomLevels);

            string fileName = Path.GetFileNameWithoutExtension(inputFile);

            // Generate Thumbnail Images.
            Trace.TraceInformation("{0}: Building Thumbnail image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer tileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");

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

            // Create and save WTML file.
            Trace.TraceInformation("{0}: Generating WTML file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string         textureTilePath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png.ToString());
            WtmlCollection wtmlCollection  = new WtmlCollection(fileName, thumbnailFile, textureTilePath, zoomLevels, projection);

            wtmlCollection.IsElevationModel = false;
            string path = Path.Combine(outputDir, fileName + ".wtml");

            wtmlCollection.Save(path);
            Trace.TraceInformation("{0}: Collection successfully generated.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
        }
Пример #2
0
        /// <summary>
        /// Processes the input equirectangular dataset.
        /// </summary>
        /// <param name="inputGrid">
        /// Input image path.
        /// </param>
        /// <param name="outputDir">
        /// Output directory where pyramid is generated.
        /// </param>
        /// <param name="projection">
        /// Projection type.
        /// </param>
        private static void ProcessEquirectangularGrid(string inputGrid, string outputDir, ProjectionTypes projection)
        {
            Trace.TraceInformation("{0}: Reading dataset..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageFormat imageFormat = ImageFormat.Png;

            // Read and parse glacier bay dataset.
            // Define a color map with relief shading implemented.
            var datagridDetails = DataGridHelper.LoadFromFile(inputGrid);

            // Build a data grid using the input data set
            var dataGrid = new DataGrid(datagridDetails.Data, false);

            // Build the grid map for equirectangular projection using the data grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(dataGrid, datagridDetails.Boundary);

            // Build the color map using equirectangular projection grid map
            var dataColorMap = new ShadedReliefColorMap(equirectangularGridMap);

            var maximumLevelsOfDetail = 15;

            // Define an instance of ITileCreator to create image tiles.
            ITileCreator imageTileCreator = TileCreatorFactory.CreateImageTileCreator(dataColorMap, projection, outputDir);

            // Define an instance of ITileCreator to create DEM tiles.
            // Define serialization mechanism for storing and retrieving DEM tiles.
            ITileCreator demTileCreator = TileCreatorFactory.CreateDemTileCreator(dataColorMap, projection, outputDir);

            // MultiTile creator encapsulates image and DEM tile creators.
            var multiTileCreator = new MultiTileCreator(new Collection <ITileCreator>()
            {
                imageTileCreator, demTileCreator
            }, projection);

            // Define boundary for the region.
            var boundary = new Boundary(datagridDetails.Boundary.Left, datagridDetails.Boundary.Top, datagridDetails.Boundary.Right, datagridDetails.Boundary.Bottom);

            if (projection == ProjectionTypes.Toast)
            {
                boundary.Left  += 180.0;
                boundary.Right += 180.0;
            }

            // Generate base tiles and fill up the pyramid.
            var tileGenerator = new TileGenerator(multiTileCreator);

            tileGenerator.Generate(maximumLevelsOfDetail, boundary);

            // Path of Mercator and Toast DEM tile server.
            const string MercatorDemTilePath = @"http://(web server address)?Q={0},{1},{2},Mercator,dem2178";
            const string ToastDemTilePath    = @"http://(web server address)?Q={0},{1},{2},Toast,dem1033";

            string fileName = Path.GetFileNameWithoutExtension(inputGrid);

            // Generate Thumbnail Images.
            Trace.TraceInformation("{0}: Building Thumbnail image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer tileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");

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

            // Create and save WTML file.
            string         textureTilePath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());
            var            inputBoundary   = new Boundary(datagridDetails.Boundary.Left, datagridDetails.Boundary.Top, datagridDetails.Boundary.Right, datagridDetails.Boundary.Bottom);
            WtmlCollection wtmlCollection  = new WtmlCollection(fileName, thumbnailFile, textureTilePath, maximumLevelsOfDetail, projection, inputBoundary);

            wtmlCollection.ZoomLevel        = 0.2;
            wtmlCollection.IsElevationModel = true;
            wtmlCollection.DemTilePath      = projection == ProjectionTypes.Mercator ? MercatorDemTilePath : ToastDemTilePath;
            string path = Path.Combine(outputDir, fileName + ".wtml");

            wtmlCollection.Save(path);
            Trace.TraceInformation("{0}: Collection successfully generated.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
        }