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 LatitudeToPixelYTest() { foreach (int tileSize in TILE_SIZES) { for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { long mapSize = MercatorProjection.GetMapSize(zoomLevel, tileSize); double pixelY = MercatorProjection.LatitudeToPixelY(MercatorProjection.LATITUDE_MAX, mapSize); Assert.AreEqual(0, pixelY, 0); pixelY = MercatorProjection.LatitudeToPixelYWithScaleFactor(MercatorProjection.LATITUDE_MAX, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(0, pixelY, 0); pixelY = MercatorProjection.LatitudeToPixelY(0, mapSize); Assert.AreEqual((float)mapSize / 2, pixelY, 0); pixelY = MercatorProjection.LatitudeToPixelYWithScaleFactor(0, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual((float)mapSize / 2, pixelY, 0); pixelY = MercatorProjection.LatitudeToPixelY(MercatorProjection.LATITUDE_MIN, mapSize); Assert.AreEqual(mapSize, pixelY, 0); pixelY = MercatorProjection.LatitudeToPixelYWithScaleFactor(MercatorProjection.LATITUDE_MIN, MercatorProjection.ZoomLevelToScaleFactor(zoomLevel), tileSize); Assert.AreEqual(mapSize, pixelY, 0); } } }