public static Point GetPixelWithScaleFactor(LatLong latLong, double scaleFactor, int tileSize) { double pixelX = MercatorProjection.LongitudeToPixelXWithScaleFactor(latLong.Longitude, scaleFactor, tileSize); double pixelY = MercatorProjection.LatitudeToPixelYWithScaleFactor(latLong.Latitude, scaleFactor, tileSize); return(new Point(pixelX, pixelY)); }
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); } } }