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); } }
public virtual void LongitudeToPixelXTest() { foreach (int tileSize in TILE_SIZES) { for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { long mapSize = MercatorProjection.GetMapSize(zoomLevel, tileSize); double pixelX = MercatorProjection.LongitudeToPixelX(LatLongUtils.LONGITUDE_MIN, mapSize); Assert.AreEqual(0, pixelX, 0); pixelX = MercatorProjection.LongitudeToPixelXWithScaleFactor(LatLongUtils.LONGITUDE_MIN, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(0, pixelX, 0); pixelX = MercatorProjection.LongitudeToPixelX(0, mapSize); Assert.AreEqual((float)mapSize / 2, pixelX, 0); mapSize = MercatorProjection.GetMapSizeWithScaleFactor(MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); pixelX = MercatorProjection.LongitudeToPixelXWithScaleFactor(0, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual((float)mapSize / 2, pixelX, 0); pixelX = MercatorProjection.LongitudeToPixelX(LatLongUtils.LONGITUDE_MAX, mapSize); Assert.AreEqual(mapSize, pixelX, 0); pixelX = MercatorProjection.LongitudeToPixelXWithScaleFactor(LatLongUtils.LONGITUDE_MAX, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(mapSize, pixelX, 0); } } }
public virtual void GetMapSizeTest() { foreach (int tileSize in TILE_SIZES) { for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { long factor = (long)Math.Round(MercatorProjection.ZoomLevelToScaleFactor(zoomLevel)); Assert.AreEqual(tileSize * factor, MercatorProjection.GetMapSize(zoomLevel, tileSize)); Assert.AreEqual(MercatorProjection.GetMapSizeWithScaleFactor(MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize), MercatorProjection.GetMapSize(zoomLevel, tileSize)); } VerifyInvalidGetMapSize((sbyte)-1, tileSize); } }
public virtual void TileYToLatitudeTest() { foreach (int tileSize in TILE_SIZES) { for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { double latitude = MercatorProjection.TileYToLatitude(0, zoomLevel); Assert.AreEqual(MercatorProjection.LATITUDE_MAX, latitude, 0); latitude = MercatorProjection.TileYToLatitude(0, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel)); Assert.AreEqual(MercatorProjection.LATITUDE_MAX, latitude, 0); long tileY = MercatorProjection.GetMapSize(zoomLevel, tileSize) / tileSize; latitude = MercatorProjection.TileYToLatitude(tileY, zoomLevel); Assert.AreEqual(MercatorProjection.LATITUDE_MIN, latitude, 0); tileY = MercatorProjection.GetMapSizeWithScaleFactor(MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize) / tileSize; latitude = MercatorProjection.TileYToLatitude(tileY, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel)); Assert.AreEqual(MercatorProjection.LATITUDE_MIN, latitude, 0); } } }