public virtual void PixelYToLatitudeTest() { foreach (int tileSize in TILE_SIZES) { for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { long mapSize = MercatorProjection.GetMapSize(zoomLevel, tileSize); double latitude = MercatorProjection.PixelYToLatitude(0, mapSize); Assert.AreEqual(MercatorProjection.LATITUDE_MAX, latitude, 0); latitude = MercatorProjection.PixelYToLatitudeWithScaleFactor(0, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(MercatorProjection.LATITUDE_MAX, latitude, 0); latitude = MercatorProjection.PixelYToLatitude((float)mapSize / 2, mapSize); Assert.AreEqual(0, latitude, 0); mapSize = MercatorProjection.GetMapSizeWithScaleFactor(MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); latitude = MercatorProjection.PixelYToLatitudeWithScaleFactor((float)mapSize / 2, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(0, latitude, 0); latitude = MercatorProjection.PixelYToLatitude(mapSize, mapSize); Assert.AreEqual(MercatorProjection.LATITUDE_MIN, latitude, 0); latitude = MercatorProjection.PixelYToLatitudeWithScaleFactor(mapSize, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(MercatorProjection.LATITUDE_MIN, latitude, 0); } VerifyInvalidPixelYToLatitude(-1, (sbyte)0, tileSize); VerifyInvalidPixelYToLatitude(tileSize + 1, (sbyte)0, tileSize); } }