/// <summary> /// Converts a grid column to Longitude /// </summary> /// <param name="x"></param> /// <param name="zoom"></param> /// <returns></returns> public static double XToLongitudeAtZoom(int x, int zoom) { double arc = EarthCircumference / ((1 << zoom) * 256); double metersX = (x * arc) - HalfEarthCircumference; double result = GISHelper.RadToDeg(metersX / 6378137); return(result); }
/// <summary> /// Converts a grid row to Latitude /// </summary> /// <param name="y"></param> /// <param name="zoom"></param> /// <returns></returns> public static double YToLatitudeAtZoom(int y, int zoom) { double arc = EarthCircumference / ((1 << zoom) * 256); double metersY = HalfEarthCircumference - (y * arc); double a = Math.Exp(metersY * 2 / 6378137); double result = GISHelper.RadToDeg(Math.Asin((a - 1) / (a + 1))); return(result); }
/// <summary> /// Converts Globe Point to Lat Long. /// </summary> /// <param name="point"></param> /// <returns></returns> LatLong PointToLatLong(Point3D point) { Point3D pointd = ViewPointToSpherePoint(point); double d = Math.Asin(pointd.Y); double radians = Math.Acos(-pointd.X / Math.Cos(d)); d = GISHelper.RadToDeg(d); radians = GISHelper.RadToDeg(radians); if (pointd.Z < 0.0) { radians = 180.0 + (180.0 - radians); } radians = (radians + 270.0) % 360.0; return(new LatLong(d, radians - 180.0)); }
/// <summary> /// /// </summary> /// <returns></returns> double GetPhiStart() { if (double.IsNaN(this.phiStart)) { double num = 7.1288559127654789; double num3 = (GISHelper.LatitudeToMercatorY(GISHelper.DegToRad(45.0)) * num) / 2.0; double num4 = -num3; double num5 = num3 - num4; double num6 = ((double)this.Row) / ((double)ZoomManager.ZoomLevelRows(this.ZoomLevel)); double num1 = (this.Row + 1.0) / ((double)ZoomManager.ZoomLevelRows(this.ZoomLevel)); GISHelper.RadToDeg(GISHelper.MercatorYToLatitude(1.0)); ZoomManager.ZoomLevelRows(this.ZoomLevel); double y = (num6 - 0.5) * num5; this.phiStart = GISHelper.RadToDeg(GISHelper.MercatorYToLatitude(y)) + 90.0; } return(this.phiStart); }