Example #1
0
        /// <summary>
        /// Initializes a new instance of the TileChopper class
        /// </summary>
        /// <param name="fileName">
        /// Full path of the image.
        /// </param>
        /// <param name="serializer">
        /// Tile serializer.
        /// </param>
        /// <param name="projectionType">
        /// Projection type.
        /// </param>
        /// <param name="inputBoundary">
        /// Input boundary.
        /// </param>
        public TileChopper(string fileName, IImageTileSerializer serializer, ProjectionTypes projectionType, Boundary inputBoundary)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            try
            {
                this.TileSerializer = serializer;
                this.projectionType = projectionType;
                this.inputBoundary  = inputBoundary;

                // Create a bitmap object and read the color pixels into the grid.
                using (Bitmap inputImage = new Bitmap(fileName))
                {
                    this.Initialize(inputImage);
                }
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch
            {
                string message = "An error occurred while reading input image file. Check the path and try again.";
                throw new InvalidOperationException(message);
            }
        }
Example #2
0
        public WtmlCollection(string name, string thumbnailUrl, string textureTilePath, int numberOfLevels, ProjectionTypes type, Boundary inputBoundary)
        {
            this.Name = name;
            this.PlaceName = name;
            this.FolderName = name;
            this.TextureTilePath = textureTilePath;
            this.NumberOfLevels = numberOfLevels;
            this.ProjectionType = type;
            this.ThumbnailUrl = thumbnailUrl;

            // Assign default values.
            this.BaseDegreesPerTile = type == ProjectionTypes.Toast ? 90 : 360;
            this.BandPass = BandPasses.Visible;
            this.DataSetType = DataSetTypes.Earth;
            this.DemTilePath = string.Empty;
            this.FileType = ".png";
            this.QuadTreeMap = string.Empty;

            if (inputBoundary != null)
            {
                // Calculate average latitude and longitude.
                this.Latitude = (inputBoundary.Bottom + inputBoundary.Top) / 2;
                this.Longitude = (inputBoundary.Right + inputBoundary.Left) / 2;
            }
        }
Example #3
0
        private void OnProjection(object sender, EventArgs e)
        {
            m_projection = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
            int save = m_constructorComboBox.SelectedIndex;

            m_constructorComboBox.Items.Clear();
            if (m_projectionComboBox.SelectedIndex > 1) // TransverseMercator or TransverseMercatorExact
            {
                m_constructorComboBox.Items.Add("Default");
                m_constructorComboBox.Items.Add("Constructor #1");
            }
            else
            {
                m_constructorComboBox.Items.Add("Constructor #1");
                m_constructorComboBox.Items.Add("Constructor #2");
                m_constructorComboBox.Items.Add("Constructor #3");
                if (m_projection == ProjectionTypes.AlbersEqualArea)
                {
                    m_constructorComboBox.Items.Add("CylindricalEqualArea");
                    m_constructorComboBox.Items.Add("AzimuthalEqualAreaNorth");
                    m_constructorComboBox.Items.Add("AzimuthalEqualAreaSouth");
                }
            }
            // calls OnConstructor
            m_constructorComboBox.SelectedIndex = m_constructorComboBox.Items.Count > save ? save : 0;
        }
Example #4
0
        public static void CreateViewportAndProjection(ProjectionTypes projectionType, Rectangle clientRectangle, float near, float far)
        {
            if (clientRectangle.Width <= 0 || clientRectangle.Height <= 0)
            {
                return;
            }

            GL.Viewport(0, 0, clientRectangle.Width, clientRectangle.Height);

            Matrix4 projectionMatrix = Matrix4.Identity;

            switch (projectionType)
            {
            case ProjectionTypes.Perspective:
                double aspect = clientRectangle.Width / (double)clientRectangle.Height;
                projectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver3, (float)aspect, near, far);
                break;

            case ProjectionTypes.Orthographic:
                projectionMatrix = Matrix4.CreateOrthographicOffCenter(clientRectangle.Left, clientRectangle.Right, clientRectangle.Bottom, clientRectangle.Top, near, far);
                break;
            }

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.MultMatrix(ref projectionMatrix);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
        }
Example #5
0
        public static void TileChopperTestsInitialize(TestContext testContext)
        {
            string          fileName       = Path.Combine(TestDataPath, "Mercator.jpg");
            ProjectionTypes projectionType = ProjectionTypes.Mercator;

            serializer = new MockClasses.MockTileCreator();
            chopper    = new TileChopper(fileName, serializer, projectionType);
        }
Example #6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public CoordinateSystem()
 {
     szProjection = String.Empty;
     szDatum = String.Empty;
     szMethod = String.Empty;
     szUnits = String.Empty;
     szLocalDatum = String.Empty;
     szEsri = String.Empty;
     m_eProjectionType = ProjectionTypes.UNKNOWN;
 }
Example #7
0
 public Camera(ProjectionTypes Projection, float Width, float Height, float zNear, float zFar, float FOV = 90.0f)
 {
     projectionType = Projection;
     width          = Width;
     height         = Height;
     znear          = zNear;
     zfar           = zFar;
     fov            = FOV;
     SetProjectionMatrix();
 }
Example #8
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 public CoordinateSystem(CoordinateSystem hCS)
 {
     szProjection = hCS.Projection;
     szDatum = hCS.Datum;
     szMethod = hCS.Method;
     szUnits = hCS.Units;
     szLocalDatum = hCS.LocalDatum;
     szEsri = hCS.Esri;
     m_eProjectionType = hCS.ProjectionType;
 }
        /// <summary>
        /// Initializes a new instance of the MultiTileCreator class.
        /// </summary>
        /// <param name="creators">
        /// Collection of tile creator instances.
        /// </param>
        /// <param name="type">
        /// Desired projection type.
        /// </param>
        public MultiTileCreator(ICollection <ITileCreator> creators, ProjectionTypes type)
        {
            if (creators == null)
            {
                throw new ArgumentNullException("creators");
            }

            this.tileCreators   = creators;
            this.ProjectionType = type;
        }
Example #10
0
 public void SelectedOutputProjectionTypeTest()
 {
     using (TileGeneratorViewModel_Accessor target = new TileGeneratorViewModel_Accessor())
     {
         ProjectionTypes expected = ProjectionTypes.Mercator;
         ProjectionTypes actual;
         target.SelectedOutputProjectionType = expected;
         actual = target.SelectedOutputProjectionType;
         Assert.AreEqual(expected, actual);
     }
 }
Example #11
0
        public XCamera(ref XMain X, float nearplane, float farplane)
            : base(ref X)
        {
            ProjectionType = ProjectionTypes.Perspective;
            RenderType     = RenderTypes.Normal;
            NearPlane      = nearplane;
            FarPlane       = farplane;
            FOV            = MathHelper.PiOver4;
            GenerateProjection(ref X, this.FOV, this.ProjectionType, NearPlane, FarPlane);

            Base      = this;
            DrawOrder = 50000;
        }
Example #12
0
        public Matrix GenerateProjection(ref XMain X, float FoV, float AspectRatio, ProjectionTypes type, float nearplane, float farplane)
        {
            if (type == ProjectionTypes.Perspective)
            {
                return(Matrix.CreatePerspectiveFieldOfView(FoV, AspectRatio, nearplane, farplane));
            }
            else if (type == ProjectionTypes.Orthographic)
            {
                return(Matrix.CreateOrthographic(100, 100, nearplane, farplane));
            }

            return(Matrix.Identity);
        }
Example #13
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            IDemTileSerializer serializer = new DemTileSerializer(Path.Combine(path, @"Pyramid\{0}\{1}\DL{0}X{1}Y{2}.dem"));
            return CreateDemTileCreator(map, projectionType, serializer);
        }
Example #14
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            IDemTileSerializer serializer = new DemTileSerializer(Path.Combine(path, @"Pyramid\{0}\{1}\DL{0}X{1}Y{2}.dem"));

            return(CreateDemTileCreator(map, projectionType, serializer));
        }
Example #15
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Color map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateImageTileCreator(IColorMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            IImageTileSerializer serializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(path), ImageFormat.Png);

            return(CreateImageTileCreator(map, projectionType, serializer));
        }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the ShapeTileCreator class.
        /// </summary>
        /// <param name="serializer">Tile serializer to be used.</param>
        /// <param name="colorMap">Color map.</param>
        /// <param name="type">Desired projection type.</param>
        /// <param name="maximumLevel">Maximum level of the image pyramid.</param>
        public ShapeTileCreator(IImageTileSerializer serializer, IColorMap colorMap, ProjectionTypes type, int maximumLevel)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            if (colorMap == null)
            {
                throw new ArgumentNullException("colorMap");
            }

            this.tileSerializer = serializer;
            this.colorMap       = colorMap;
            this.ProjectionType = type;
            this.maximumLevel   = maximumLevel;
        }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the ShapeTileCreator class.
        /// </summary>
        /// <param name="serializer">Tile serializer to be used.</param>
        /// <param name="colorMap">Color map.</param>
        /// <param name="type">Desired projection type.</param>
        /// <param name="maximumLevel">Maximum level of the image pyramid.</param>
        public ShapeTileCreator(IImageTileSerializer serializer, IColorMap colorMap, ProjectionTypes type, int maximumLevel)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            if (colorMap == null)
            {
                throw new ArgumentNullException("colorMap");
            }

            this.tileSerializer = serializer;
            this.colorMap = colorMap;
            this.ProjectionType = type;
            this.maximumLevel = maximumLevel;
        }
Example #18
0
        private void OnProjectectionType(object sender, EventArgs e)
        {
            m_type = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
            switch (m_type)
            {
            case ProjectionTypes.AzimuthalEquidistant:
                m_azimuthal = new AzimuthalEquidistant(m_geodesic);
                break;

            case ProjectionTypes.CassiniSoldner:
                double lat0 = Double.Parse(m_lat0TextBox.Text);
                double lon0 = Double.Parse(m_lon0TextBox.Text);
                m_cassini = new CassiniSoldner(lat0, lon0, m_geodesic);
                break;

            case ProjectionTypes.Gnomonic:
                m_gnomonic = new Gnomonic(m_geodesic);
                break;
            }
        }
Example #19
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));
        }
Example #20
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="serializer">
        /// Tile serializer instance.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, IDemTileSerializer serializer)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            switch (projectionType)
            {
                case ProjectionTypes.Mercator:
                    return new MercatorDemTileCreator(map, serializer);

                default:
                    return new ToastDemTileCreator(map, serializer);
            }
        }
Example #21
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Elevation map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="serializer">
        /// Tile serializer instance.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateDemTileCreator(IElevationMap map, ProjectionTypes projectionType, IDemTileSerializer serializer)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            switch (projectionType)
            {
            case ProjectionTypes.Mercator:
                return(new MercatorDemTileCreator(map, serializer));

            default:
                return(new ToastDemTileCreator(map, serializer));
            }
        }
Example #22
0
        /// <summary>
        /// Processes a list of input image tiles and generates pyramid for level N.
        /// </summary>
        /// <param name="inputFilePath">Xml file with list of image tile information.</param>
        /// <param name="outputDir">Output directory where the image tiles of pyramid has to be stored.</param>
        /// <param name="projection">Projection to be used.</param>
        /// <param name="inputBoundary">Input image boundary.</param>
        private static void ProcessMultipartEquirectangularImage(string inputFilePath, string outputDir, ProjectionTypes projection, Boundary inputBoundary)
        {
            ImageFormat imageFormat = ImageFormat.Png;

            Trace.TraceInformation("{0}: Reading image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));

            // Get the list of equirectangular images input.
            string[,] imageTiles = Program.GetInputImageList(inputFilePath);

            // Check if the image is circular.
            double longitudeDelta = inputBoundary.Right - inputBoundary.Left;
            bool circular = (360.0 - longitudeDelta) < 0.000001;

            // Build an image grid using the input images
            var imageGrid = new ImageGrid(imageTiles, circular);

            // Build the grid map for equirectangular projection using the image grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(imageGrid, inputBoundary);

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

            var maximumLevelsOfDetail = TileHelper.CalculateMaximumLevel(imageGrid.Height, imageGrid.Width, inputBoundary);

            // Define ITileCreator instance for creating image tiles.
            ITileCreator tileCreator = TileCreatorFactory.CreateImageTileCreator(imageColorMap, projection, outputDir);

            // Define bounds of the image. Image is assumed to cover the entire world.
            // If not, change the coordinates accordingly.
            // For Mercator projection, longitude spans from -180 to +180 and latitude from 90 to -90.
            Boundary gridBoundary = new Boundary(inputBoundary.Left, inputBoundary.Top, inputBoundary.Right, inputBoundary.Bottom);
            if (projection == ProjectionTypes.Toast)
            {
                // For Toast projection, longitude spans from 0 to +360 and latitude from 90 to -90.
                gridBoundary.Left += 180;
                gridBoundary.Right += 180;
            }

            // Define plumbing for looping through all the tiles to be created for base image and pyramid.
            var tileGenerator = new TileGenerator(tileCreator);

            // Start building base image and the pyramid.
            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            tileGenerator.Generate(maximumLevelsOfDetail, gridBoundary);

            string fileName = Path.GetFileNameWithoutExtension(inputFilePath);

            // Generate Plate file.
            Trace.TraceInformation("{0}: Building Plate file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer pyramid = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            PlateFileGenerator plateGenerator = new PlateFileGenerator(
                Path.Combine(outputDir, fileName + ".plate"),
                maximumLevelsOfDetail,
                ImageFormat.Png);
            plateGenerator.CreateFromImageTile(pyramid);

            // Generate Thumbnail Images.
            Trace.TraceInformation("{0}: Building Thumbnail image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");
            TileHelper.GenerateThumbnail(pyramid.GetFileName(0, 0, 0), 96, 45, thumbnailFile, ImageFormat.Jpeg);

            // Get the path of image tiles created and save it in WTML file.
            Trace.TraceInformation("{0}: Building WTML file..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string pyramidPath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());

            // Create and save WTML collection file.
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, pyramidPath, maximumLevelsOfDetail, projection, inputBoundary);
            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));
        }
Example #23
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));
        }
Example #24
0
        /// <summary>
        /// Processes a list of input image tiles and generates pyramid for level N.
        /// </summary>
        /// <param name="inputFilePath">Xml file with list of image tile information.</param>
        /// <param name="outputDir">Output directory where the image tiles of pyramid has to be stored.</param>
        /// <param name="projection">Projection to be used.</param>
        private static void ProcessMultipartEquirectangularImage(string inputFilePath, string outputDir, ProjectionTypes projection)
        {
            ImageFormat imageFormat = ImageFormat.Png;

            Trace.TraceInformation("{0}: Reading image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));

            // Get the list of equirectangular images input.
            string[,] imageTiles = Program.GetInputImageList(inputFilePath);

            // Set the grid boundaries
            var imageBoundary = new Boundary(-180, -90, 180, 90);

            // Build an image grid using the input images
            var imageGrid = new ImageGrid(imageTiles, true);

            // Build the grid map for equirectangular projection using the image grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(imageGrid, imageBoundary);

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

            var maximumLevelsOfDetail = TileHelper.CalculateMaximumLevel(imageGrid.Height, imageGrid.Width, imageBoundary);

            // Define ITileCreator instance for creating image tiles.
            ITileCreator tileCreator = TileCreatorFactory.CreateImageTileCreator(imageColorMap, projection, outputDir);

            // Define plumbing for looping through all the tiles to be created for base image and pyramid.
            var tileGenerator = new TileGenerator(tileCreator);

            // Start building base image and the pyramid.
            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            tileGenerator.Generate(maximumLevelsOfDetail);

            string fileName = Path.GetFileNameWithoutExtension(inputFilePath);

            // Generate Plate file.
            Trace.TraceInformation("{0}: Building Plate file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer pyramid = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            PlateFileGenerator plateGenerator = new PlateFileGenerator(
                Path.Combine(outputDir, fileName + ".plate"),
                maximumLevelsOfDetail,
                ImageFormat.Png);
            plateGenerator.CreateFromImageTile(pyramid);

            // Generate Thumbnail Images.
            Trace.TraceInformation("{0}: Building Thumbnail image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string thumbnailFile = Path.Combine(outputDir, fileName + ".jpeg");
            TileHelper.GenerateThumbnail(pyramid.GetFileName(0, 0, 0), 96, 45, thumbnailFile, ImageFormat.Jpeg);

            // Get the path of image tiles created and save it in WTML file.
            Trace.TraceInformation("{0}: Building WTML file..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string pyramidPath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());

            // Create and save WTML collection file.
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, pyramidPath, maximumLevelsOfDetail, projection);
            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));
        }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the TileChopper class
 /// </summary>
 /// <param name="fileName">
 /// Full path of the image.
 /// </param>
 /// <param name="serializer">
 /// Tile serializer.
 /// </param>
 /// <param name="projectionType">
 /// Projection type.
 /// </param>
 public TileChopper(string fileName, IImageTileSerializer serializer, ProjectionTypes projectionType)
     : this(fileName, serializer, projectionType, new Boundary(-180, -90, 180, 90))
 {
 }
Example #26
0
        /// <summary>
        /// Creates a DEM tile creator instance for the specified projection type.
        /// </summary>
        /// <param name="map">
        /// Color map used.
        /// </param>
        /// <param name="projectionType">
        /// Projection type desired.
        /// </param>
        /// <param name="path">
        /// Location where the tiles should be serialized.
        /// </param>
        /// <returns>
        /// ITileCreator instance.
        /// </returns>
        public static ITileCreator CreateImageTileCreator(IColorMap map, ProjectionTypes projectionType, string path)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            IImageTileSerializer serializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(path), ImageFormat.Png);
            return CreateImageTileCreator(map, projectionType, serializer);
        }
Example #27
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));
        }
Example #28
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));
        }
Example #29
0
 public void GenerateProjection(ref XMain X, float FoV, ProjectionTypes type, float nearplane, float farplane)
 {
     AspectRatio = (float)X.GraphicsDevice.Viewport.Width / (float)X.GraphicsDevice.Viewport.Height;
     Projection  = GenerateProjection(ref X, FoV, AspectRatio, type, nearplane, farplane);
     Frustrum    = new BoundingFrustum(View * Projection);
 }
Example #30
0
        public WtmlCollection(string name, string thumbnailUrl, string textureTilePath, int numberOfLevels, ProjectionTypes type, Boundary inputBoundary)
        {
            this.Name            = name;
            this.PlaceName       = name;
            this.FolderName      = name;
            this.TextureTilePath = textureTilePath;
            this.NumberOfLevels  = numberOfLevels;
            this.ProjectionType  = type;
            this.ThumbnailUrl    = thumbnailUrl;

            // Assign default values.
            this.BaseDegreesPerTile = type == ProjectionTypes.Toast ? 90 : 360;
            this.BandPass           = BandPasses.Visible;
            this.DataSetType        = DataSetTypes.Earth;
            this.DemTilePath        = string.Empty;
            this.FileType           = ".png";
            this.QuadTreeMap        = string.Empty;

            if (inputBoundary != null)
            {
                // Calculate average latitude and longitude.
                this.Latitude  = (inputBoundary.Bottom + inputBoundary.Top) / 2;
                this.Longitude = (inputBoundary.Right + inputBoundary.Left) / 2;
            }
        }
Example #31
0
 public Camera(ProjectionTypes Projection)
 {
     projectionType = Projection;
     SetProjectionMatrix();
 }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the TileChopper class
 /// </summary>
 /// <param name="fileName">
 /// Full path of the image.
 /// </param>
 /// <param name="serializer">
 /// Tile serializer.
 /// </param>
 /// <param name="projectionType">
 /// Projection type.
 /// </param>
 public TileChopper(string fileName, IImageTileSerializer serializer, ProjectionTypes projectionType)
     : this(fileName, serializer, projectionType, new Boundary(-180, -90, 180, 90))
 {
 }
Example #33
0
 private void OnProjection(object sender, EventArgs e)
 {
     m_projection = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
     int save = m_constructorComboBox.SelectedIndex;
     m_constructorComboBox.Items.Clear();
     if (m_projectionComboBox.SelectedIndex > 1) // TransverseMercator or TransverseMercatorExact
     {
         m_constructorComboBox.Items.Add("Default");
         m_constructorComboBox.Items.Add("Constructor #1");
     }
     else
     {
         m_constructorComboBox.Items.Add("Constructor #1");
         m_constructorComboBox.Items.Add("Constructor #2");
         m_constructorComboBox.Items.Add("Constructor #3");
         if (m_projection == ProjectionTypes.AlbersEqualArea)
         {
             m_constructorComboBox.Items.Add("CylindricalEqualArea");
             m_constructorComboBox.Items.Add("AzimuthalEqualAreaNorth");
             m_constructorComboBox.Items.Add("AzimuthalEqualAreaSouth");
         }
     }
     // calls OnConstructor
     m_constructorComboBox.SelectedIndex = m_constructorComboBox.Items.Count > save ? save : 0;
 }
 static extern void Camera_SetProjectionType(IntPtr pointer, ProjectionTypes type);
Example #35
0
 private void OnProjectectionType(object sender, EventArgs e)
 {
     m_type = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
     switch (m_type)
     {
         case ProjectionTypes.AzimuthalEquidistant:
             m_azimuthal = new AzimuthalEquidistant(m_geodesic);
             break;
         case ProjectionTypes.CassiniSoldner:
             double lat0 = Double.Parse( m_lat0TextBox.Text );
             double lon0 = Double.Parse( m_lon0TextBox.Text );
             m_cassini = new CassiniSoldner(lat0, lon0, m_geodesic);
             break;
         case ProjectionTypes.Gnomonic:
             m_gnomonic = new Gnomonic(m_geodesic);
             break;
     }
 }
Example #36
0
 public WtmlCollection(string name, string thumbnailUrl, string textureTilePath, int numberOfLevels, ProjectionTypes type)
     : this(name, thumbnailUrl, textureTilePath, numberOfLevels, type, new Boundary(-180, -90, 180, 90))
 {
 }
Example #37
0
 public WtmlCollection(string name, string thumbnailUrl, string textureTilePath, int numberOfLevels, ProjectionTypes type)
     : this(name, thumbnailUrl, textureTilePath, numberOfLevels, type, new Boundary(-180, -90, 180, 90))
 {
 }
Example #38
0
        /// <summary>
        /// Initializes a new instance of the TileChopper class
        /// </summary>
        /// <param name="fileName">
        /// Full path of the image.
        /// </param>
        /// <param name="serializer">
        /// Tile serializer.
        /// </param>
        /// <param name="projectionType">
        /// Projection type.
        /// </param>
        /// <param name="inputBoundary">
        /// Input boundary.
        /// </param>
        public TileChopper(string fileName, IImageTileSerializer serializer, ProjectionTypes projectionType, Boundary inputBoundary)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            try
            {
                this.TileSerializer = serializer;
                this.projectionType = projectionType;
                this.inputBoundary = inputBoundary;

                // Create a bitmap object and read the color pixels into the grid.
                using (Bitmap inputImage = new Bitmap(fileName))
                {
                    this.Initialize(inputImage);
                }
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch
            {
                string message = "An error occurred while reading input image file. Check the path and try again.";
                throw new InvalidOperationException(message);
            }
        }
Example #39
0
        /// <summary>
        /// Processes a list of input image tiles and generates pyramid for level N.
        /// </summary>
        /// <param name="inputFilePath">Xml file with list of image tile information.</param>
        /// <param name="outputDir">Output directory where the image tiles of pyramid has to be stored.</param>
        /// <param name="projection">Projection to be used.</param>
        private static void ProcessMultipartEquirectangularImage(string inputFilePath, string outputDir, ProjectionTypes projection)
        {
            ImageFormat imageFormat = ImageFormat.Png;

            Trace.TraceInformation("{0}: Reading image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));

            // Get the list of equirectangular images input.
            string[,] imageTiles = Program.GetInputImageList(inputFilePath);

            // Set the grid boundaries
            var imageBoundary = new Boundary(-180, -90, 180, 90);

            // Build an image grid using the input images
            var imageGrid = new ImageGrid(imageTiles, true);

            // Build the grid map for equirectangular projection using the image grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(imageGrid, imageBoundary);

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

            var maximumLevelsOfDetail = TileHelper.CalculateMaximumLevel(imageGrid.Height, imageGrid.Width, imageBoundary);

            // Define ITileCreator instance for creating image tiles.
            ITileCreator tileCreator = TileCreatorFactory.CreateImageTileCreator(imageColorMap, projection, outputDir);

            // Define plumbing for looping through all the tiles to be created for base image and pyramid.
            var tileGenerator = new TileGenerator(tileCreator);

            // Start building base image and the pyramid.
            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            tileGenerator.Generate(maximumLevelsOfDetail);

            string fileName = Path.GetFileNameWithoutExtension(inputFilePath);

            // Generate Plate file.
            Trace.TraceInformation("{0}: Building Plate file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer pyramid        = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            PlateFileGenerator  plateGenerator = new PlateFileGenerator(
                Path.Combine(outputDir, fileName + ".plate"),
                maximumLevelsOfDetail,
                ImageFormat.Png);

            plateGenerator.CreateFromImageTile(pyramid);

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

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

            // Get the path of image tiles created and save it in WTML file.
            Trace.TraceInformation("{0}: Building WTML file..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string pyramidPath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());

            // Create and save WTML collection file.
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, pyramidPath, maximumLevelsOfDetail, projection);
            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));
        }
Example #40
0
        public static void CreateViewportAndProjection(ProjectionTypes projectionType, Rectangle clientRectangle, float near, float far)
        {
            if (clientRectangle.Width <= 0 || clientRectangle.Height <= 0) return;

            GL.Viewport(0, 0, clientRectangle.Width, clientRectangle.Height);

            Matrix4 projectionMatrix = Matrix4.Identity;

            switch (projectionType)
            {
                case ProjectionTypes.Perspective:
                    double aspect = clientRectangle.Width / (double)clientRectangle.Height;
                    projectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver3, (float)aspect, near, far);
                    break;

                case ProjectionTypes.Orthographic:
                    projectionMatrix = Matrix4.CreateOrthographicOffCenter(clientRectangle.Left, clientRectangle.Right, clientRectangle.Bottom, clientRectangle.Top, near, far);
                    break;
            }

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.MultMatrix(ref projectionMatrix);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
        }
Example #41
0
        /// <summary>
        /// Processes a list of input image tiles and generates pyramid for level N.
        /// </summary>
        /// <param name="inputFilePath">Xml file with list of image tile information.</param>
        /// <param name="outputDir">Output directory where the image tiles of pyramid has to be stored.</param>
        /// <param name="projection">Projection to be used.</param>
        /// <param name="inputBoundary">Input image boundary.</param>
        private static void ProcessMultipartEquirectangularImage(string inputFilePath, string outputDir, ProjectionTypes projection, Boundary inputBoundary)
        {
            ImageFormat imageFormat = ImageFormat.Png;

            Trace.TraceInformation("{0}: Reading image..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));

            // Get the list of equirectangular images input.
            string[,] imageTiles = Program.GetInputImageList(inputFilePath);

            // Check if the image is circular.
            double longitudeDelta = inputBoundary.Right - inputBoundary.Left;
            bool   circular       = (360.0 - longitudeDelta) < 0.000001;

            // Build an image grid using the input images
            var imageGrid = new ImageGrid(imageTiles, circular);

            // Build the grid map for equirectangular projection using the image grid and boundary co-ordinates
            var equirectangularGridMap = new EquirectangularGridMap(imageGrid, inputBoundary);

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

            var maximumLevelsOfDetail = TileHelper.CalculateMaximumLevel(imageGrid.Height, imageGrid.Width, inputBoundary);

            // Define ITileCreator instance for creating image tiles.
            ITileCreator tileCreator = TileCreatorFactory.CreateImageTileCreator(imageColorMap, projection, outputDir);

            // Define bounds of the image. Image is assumed to cover the entire world.
            // If not, change the coordinates accordingly.
            // For Mercator projection, longitude spans from -180 to +180 and latitude from 90 to -90.
            Boundary gridBoundary = new Boundary(inputBoundary.Left, inputBoundary.Top, inputBoundary.Right, inputBoundary.Bottom);

            if (projection == ProjectionTypes.Toast)
            {
                // For Toast projection, longitude spans from 0 to +360 and latitude from 90 to -90.
                gridBoundary.Left  += 180;
                gridBoundary.Right += 180;
            }

            // Define plumbing for looping through all the tiles to be created for base image and pyramid.
            var tileGenerator = new TileGenerator(tileCreator);

            // Start building base image and the pyramid.
            Trace.TraceInformation("{0}: Building base and parent levels...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            tileGenerator.Generate(maximumLevelsOfDetail, gridBoundary);

            string fileName = Path.GetFileNameWithoutExtension(inputFilePath);

            // Generate Plate file.
            Trace.TraceInformation("{0}: Building Plate file...", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            ImageTileSerializer pyramid        = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png);
            PlateFileGenerator  plateGenerator = new PlateFileGenerator(
                Path.Combine(outputDir, fileName + ".plate"),
                maximumLevelsOfDetail,
                ImageFormat.Png);

            plateGenerator.CreateFromImageTile(pyramid);

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

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

            // Get the path of image tiles created and save it in WTML file.
            Trace.TraceInformation("{0}: Building WTML file..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture));
            string pyramidPath = WtmlCollection.GetWtmlTextureTilePath(TileHelper.GetDefaultImageTilePathTemplate(outputDir), imageFormat.ToString());

            // Create and save WTML collection file.
            WtmlCollection wtmlCollection = new WtmlCollection(fileName, thumbnailFile, pyramidPath, maximumLevelsOfDetail, projection, inputBoundary);
            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));
        }