Exemplo n.º 1
0
        /// <summary>
        /// Check whether a given x,y tile coodinate belongs/overlap with the prefered regions' coordinates.
        /// </summary>
        /// <param name="preferredRegion">Region of preference.</param>
        /// <param name="level">Level at which the tile coordinate has to be examined.</param>
        /// <param name="tileX">Tile X coordinate.</param>
        /// <param name="tileY">Tile Y coordinate.</param>
        /// <returns>Boolean indicating the tile coordinates belongs/overlaps with the region of interest.</returns>
        private static bool IsDesiredTile(Boundary preferredRegion, int level, int tileX, int tileY)
        {
            OctTileMap octMap    = new OctTileMap(level, tileX, tileY);
            Boundary   tileBound = new Boundary(octMap.RaMin, octMap.DecMin, octMap.RaMax, octMap.DecMax);

            return(IsBoundOrOverlap(tileBound, preferredRegion));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the tile specified by level.
        /// </summary>
        /// <param name="level">
        /// Zoom level.
        /// </param>
        /// <param name="tileX">
        /// X tile coordinate.
        /// </param>
        /// <param name="tileY">
        /// Y tile coordinate.
        /// </param>
        public void Create(int level, int tileX, int tileY)
        {
            // Pick the set of vertices where elevation will be computed.
            int[] verticesX = backslashVerticesX;
            int[] verticesY = backslashVerticesY;
            if (IsSlashQuadrant(level, tileX, tileY))
            {
                verticesX = slashVerticesX;
                verticesY = slashVerticesY;
            }

            // Compute required elevations.
            short[]    h       = new short[verticesX.Length];
            Vector2d   pt      = new Vector2d();
            OctTileMap tileMap = new OctTileMap(level, tileX, tileY);

            for (int i = 0; i < verticesX.Length; i++)
            {
                pt.X = ((double)verticesX[i]) / VertexInterval;
                pt.Y = ((double)verticesY[i]) / VertexInterval;
                Vector2d v = tileMap.PointToRaDec(pt);
                h[i] = this.elevationMap.GetElevation(v.X - 180.0, v.Y);
            }

            // Save elevations.
            this.tileSerializer.Serialize(h, level, tileX, tileY);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the tile specified by level.
        /// </summary>
        /// <param name="level">
        /// Zoom level.
        /// </param>
        /// <param name="tileX">
        /// X tile coordinate.
        /// </param>
        /// <param name="tileY">
        /// Y tile coordinate.
        /// </param>
        public void Create(int level, int tileX, int tileY)
        {
            // Map to convert from pixel position to global (longitude, latitude).
            OctTileMap tileMap = new OctTileMap(level, tileX, tileY);

            int[] colors   = new int[Constants.TileSize * Constants.TileSize];
            bool  hasData  = false;
            int   position = -1;

            for (int pixelY = 0; pixelY < Constants.TileSize; pixelY++)
            {
                for (int pixelX = 0; pixelX < Constants.TileSize; pixelX++)
                {
                    // Map pixel (u, v) position to (longitude, latitude).
                    double   u         = (0.5 + pixelX) / ((double)Constants.TileSize);
                    double   v         = (0.5 + pixelY) / ((double)Constants.TileSize);
                    Vector2d location  = tileMap.PointToRaDec(new Vector2d(u, v));
                    double   latitude  = location.Y;
                    double   longitude = location.X;

                    // For Toast projection, Longitude spans from 0 to +360 and latitude from +90 to -90.
                    // So we need to convert from -180 to +180 => 0 to +360.
                    longitude -= 180.0;

                    // Map geo location to an ARGB value.
                    Color color = this.ColorMap.GetColor(longitude, latitude);

                    // Store and update bit indicating whether actual data is present or not.
                    position++;
                    colors[position] = color.ToArgb();
                    if (hasData == false)
                    {
                        hasData = (color != Color.Transparent);
                    }
                }
            }

            if (hasData)
            {
                TileHelper.ToBitmap(level, tileX, tileY, colors, this.TileSerializer);
            }

            colors = null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates image tile specified by level.
        /// </summary>
        /// <param name="level">
        /// Zoom level.
        /// </param>
        /// <param name="tileX">
        /// X tile coordinate.
        /// </param>
        /// <param name="tileY">
        /// Y tile coordinate.
        /// </param>
        public void Create(int level, int tileX, int tileY)
        {
            OctTileMap tileMap = new OctTileMap(level, tileX, tileY);
            bool hasData;

            List<Color> colors = this.MapToColors(tileMap, out hasData);
            if (hasData)
            {
                this.ToBitmap(level, tileX, tileY, colors);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Maps image pixels to lat-long values.
        /// </summary>
        /// <param name="tileMap">Tile mapper.</param>
        /// <param name="hasData">Boolean indicates whether the coordinates maps to valid color.</param>
        /// <returns>List of color values.</returns>
        private List<Color> MapToColors(OctTileMap tileMap, out bool hasData)
        {
            List<Color> colors = new List<Color>(Constants.TileSize * Constants.TileSize);
            Vector2d point = new Vector2d();
            hasData = false;

            for (int pixelY = 0; pixelY < Constants.TileSize; pixelY++)
            {
                point.Y = ((double)pixelY + 0.5) / Constants.TileSize;
                for (int pixelX = 0; pixelX < Constants.TileSize; pixelX++)
                {
                    point.X = ((double)pixelX + 0.5) / Constants.TileSize;
                    var v = tileMap.PointToRaDec(point);
                    Color color = (this.colorMap.GetColor(v.X, v.Y));
                    if (color != Color.Transparent)
                    {
                        hasData = true;
                    }

                    colors.Add(color);
                }
            }

            return colors;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Check whether a given x,y tile coodinate belongs/overlap with the prefered regions' coordinates.
 /// </summary>
 /// <param name="preferredRegion">Region of preference.</param>
 /// <param name="level">Level at which the tile coordinate has to be examined.</param>
 /// <param name="tileX">Tile X coordinate.</param>
 /// <param name="tileY">Tile Y coordinate.</param>
 /// <returns>Boolean indicating the tile coordinates belongs/overlaps with the region of interest.</returns>
 private static bool IsDesiredTile(Boundary preferredRegion, int level, int tileX, int tileY)
 {
     OctTileMap octMap = new OctTileMap(level, tileX, tileY);
     Boundary tileBound = new Boundary(octMap.RaMin, octMap.DecMin, octMap.RaMax, octMap.DecMax);
     return IsBoundOrOverlap(tileBound, preferredRegion);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Creates the tile specified by level.
        /// </summary>
        /// <param name="level">
        /// Zoom level.
        /// </param>
        /// <param name="tileX">
        /// X tile coordinate.
        /// </param>
        /// <param name="tileY">
        /// Y tile coordinate.
        /// </param>
        public void Create(int level, int tileX, int tileY)
        {
            // Pick the set of vertices where elevation will be computed.
            int[] verticesX = backslashVerticesX;
            int[] verticesY = backslashVerticesY;
            if (IsSlashQuadrant(level, tileX, tileY))
            {
                verticesX = slashVerticesX;
                verticesY = slashVerticesY;
            }

            // Compute required elevations.
            short[] h = new short[verticesX.Length];
            Vector2d pt = new Vector2d();
            OctTileMap tileMap = new OctTileMap(level, tileX, tileY);
            for (int i = 0; i < verticesX.Length; i++)
            {
                pt.X = ((double)verticesX[i]) / VertexInterval;
                pt.Y = ((double)verticesY[i]) / VertexInterval;
                Vector2d v = tileMap.PointToRaDec(pt);
                h[i] = this.elevationMap.GetElevation(v.X - 180.0, v.Y);
            }

            // Save elevations.
            this.tileSerializer.Serialize(h, level, tileX, tileY);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates the tile specified by level.
        /// </summary>
        /// <param name="level">
        /// Zoom level.
        /// </param>
        /// <param name="tileX">
        /// X tile coordinate.
        /// </param>
        /// <param name="tileY">
        /// Y tile coordinate.
        /// </param>
        public void Create(int level, int tileX, int tileY)
        {
            // Map to convert from pixel position to global (longitude, latitude).
            OctTileMap tileMap = new OctTileMap(level, tileX, tileY);

            int[] colors = new int[Constants.TileSize * Constants.TileSize];
            bool hasData = false;
            int position = -1;
            for (int pixelY = 0; pixelY < Constants.TileSize; pixelY++)
            {
                for (int pixelX = 0; pixelX < Constants.TileSize; pixelX++)
                {
                    // Map pixel (u, v) position to (longitude, latitude).
                    double u = (0.5 + pixelX) / ((double)Constants.TileSize);
                    double v = (0.5 + pixelY) / ((double)Constants.TileSize);
                    Vector2d location = tileMap.PointToRaDec(new Vector2d(u, v));
                    double latitude = location.Y;
                    double longitude = location.X;
                    if (this.LookAtOutsideSurface)
                    {
                        longitude -= 180.0;
                    }

                    // Map geo location to an ARGB value.
                    Color color = this.ColorMap.GetColor(longitude, latitude);

                    // Store and update bit indicating whether actual data is present or not.
                    position++;
                    colors[position] = color.ToArgb();
                    if (hasData == false)
                    {
                        hasData = (color != Color.Transparent);
                    }
                }
            }

            if (hasData)
            {
                TileHelper.ToBitmap(level, tileX, tileY, colors, this.TileSerializer, this.ReferenceTileSerializer);
            }
        }