public override void TileToCoordinates(double tx, double ty, int zoom, out double lng, out double lat) { double mapSize = OnlineMapsUtils.tileSize << zoom; lng = 360 * (OnlineMapsUtils.Repeat(tx * OnlineMapsUtils.tileSize, 0, mapSize - 1) / mapSize - 0.5); lat = 90 - 360 * Math.Atan(Math.Exp((OnlineMapsUtils.Clip(ty * OnlineMapsUtils.tileSize, 0, mapSize - 1) / mapSize - 0.5) * PI2)) / Math.PI; }
public override void CoordinatesToTile(double lng, double lat, int zoom, out double tx, out double ty) { lat = OnlineMapsUtils.Clip(lat, -85, 85); lng = OnlineMapsUtils.Repeat(lng, -180, 180); double rLon = lng * DEG2RAD; double rLat = lat * DEG2RAD; double a = 6378137; double k = 0.0818191908426; double z = Math.Tan(PID4 + rLat / 2) / Math.Pow(Math.Tan(PID4 + Math.Asin(k * Math.Sin(rLat)) / 2), k); double z1 = Math.Pow(2, 23 - zoom); tx = (20037508.342789 + a * rLon) * 53.5865938 / z1 / 256; ty = (20037508.342789 - a * Math.Log(z)) * 53.5865938 / z1 / 256; }