Exemplo n.º 1
0
        /// <summary>
        /// Calculates the absolute pixel position for a zoom level and tile size relative to origin
        /// </summary>
        /// <param name="Point"> </param>
        /// <param name="mapSize"> precomputed size of map. </param>
        /// <returns> the relative pixel position to the origin values (e.g. for a tile) </returns>
        public static Point GetPixelRelative(Point Point, long mapSize, double x, double y)
        {
            double pixelX = MercatorProjection.LongitudeToPixelX(Point.X, mapSize) - x;
            double pixelY = MercatorProjection.LatitudeToPixelY(Point.Y, mapSize) - y;

            return(new Point(pixelX, pixelY));
        }
Exemplo n.º 2
0
        public static Point GetPixel(Point Point, long mapSize)
        {
            double pixelX = MercatorProjection.LongitudeToPixelX(Point.X, mapSize);
            double pixelY = MercatorProjection.LatitudeToPixelY(Point.Y, mapSize);

            return(new Point(pixelX, pixelY));
        }
Exemplo n.º 3
0
        public static Point GetPixelWithScaleFactor(Point Point, double scaleFactor, int tileSize)
        {
            double pixelX = MercatorProjection.LongitudeToPixelXWithScaleFactor(Point.X, scaleFactor, tileSize);
            double pixelY = MercatorProjection.LatitudeToPixelYWithScaleFactor(Point.Y, scaleFactor, tileSize);

            return(new Point(pixelX, pixelY));
        }
        public static BoundingBox ToBoundingBox(this Tile tile)
        {
            sbyte level = (sbyte)tile.ZoomLevel;

            double minY = Math.Max(MercatorProjection.LATITUDE_MIN, MercatorProjection.TileYToLatitude(tile.Row + 1, level));
            double minX = Math.Max(-180, MercatorProjection.TileXToLongitude(tile.Col, level));
            double maxY = Math.Min(MercatorProjection.LATITUDE_MAX, MercatorProjection.TileYToLatitude(tile.Row, level));
            double maxX = Math.Min(180, MercatorProjection.TileXToLongitude(tile.Col + 1, level));

            if (maxX == -180)
            {
                // fix for dateline crossing, where the right tile starts at -180 and causes an invalid bbox
                maxX = 180;
            }

            return(new BoundingBox(minX, minY, maxX, maxY));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Converts meters to pixels at latitude for zoom-level.
 /// </summary>
 /// <param name="meters">
 ///            the meters to convert </param>
 /// <param name="latitude">
 ///            the latitude for the conversion. </param>
 /// <param name="mapSize">
 ///            precomputed size of map. </param>
 /// <returns> pixels that represent the meters at the given zoom-level and latitude. </returns>
 public static double MetersToPixels(float meters, double latitude, long mapSize)
 {
     return(meters / MercatorProjection.CalculateGroundResolution(latitude, mapSize));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Converts meters to pixels at latitude for zoom-level.
 /// </summary>
 /// <param name="meters">
 ///            the meters to convert </param>
 /// <param name="latitude">
 ///            the latitude for the conversion. </param>
 /// <param name="scaleFactor">
 ///            the scale factor for the conversion. </param>
 /// <returns> pixels that represent the meters at the given zoom-level and latitude. </returns>
 public static double MetersToPixelsWithScaleFactor(float meters, double latitude, double scaleFactor, int tileSize)
 {
     return(meters / MercatorProjection.CalculateGroundResolutionWithScaleFactor(latitude, scaleFactor, tileSize));
 }