Ejemplo n.º 1
0
        /// <inheritdoc cref="ToGeodeticCoordinates(Size, bool)"/>
        /// <param name="number"><see cref="Number"/> to convert</param>
        /// <param name="tileSize"></param>
        /// <param name="tmsCompatible"></param>
        public static (GeodeticCoordinate minCoordinate, GeodeticCoordinate maxCoordinate) ToGeodeticCoordinates(
            Number number, Size tileSize, bool tmsCompatible)
        {
            #region Preconditions checks

            if (number == null)
            {
                throw new ArgumentNullException(nameof(number));
            }
            if (tileSize == null)
            {
                throw new ArgumentNullException(nameof(tileSize));
            }

            #endregion

            if (!tmsCompatible)
            {
                number = Flip(number);
            }

            double resolution = GeodeticCoordinate.Resolution(number.Z, tileSize);

            GeodeticCoordinate minCoordinate = new GeodeticCoordinate(number.X * tileSize.Width * resolution - 180.0,
                                                                      number.Y * tileSize.Height * resolution - 90.0);
            GeodeticCoordinate maxCoordinate = new GeodeticCoordinate((number.X + 1) * tileSize.Width * resolution - 180.0,
                                                                      (number.Y + 1) * tileSize.Height * resolution - 90.0);

            return(minCoordinate, maxCoordinate);
        }
 public void ResolutionNotSquareTileSize() => Assert.Throws <ArgumentException>(() =>
 {
     Size size  = new Size(10, 20);
     double res = GeodeticCoordinate.Resolution(10, size);
 });
 public void ResolutionSmallZ() => Assert.Throws <ArgumentOutOfRangeException>(() =>
 {
     double res = GeodeticCoordinate.Resolution(-1, Tile.DefaultSize);
 });
 public void ResolutionNullTileSize() => Assert.Throws <ArgumentNullException>(() =>
 {
     double res = GeodeticCoordinate.Resolution(10, null);
 });
 public void ResolutionNormal() => Assert.DoesNotThrow(() =>
 {
     double res = GeodeticCoordinate.Resolution(10, Tile.DefaultSize);
 });