/** * GPS correction algorithm for Google, the map of the German system * @author Administrator */class Function_gpscorrect {public stat IC double pi = 3.14159265358979324; public static Double A = 6378245.0; public static Double ee = 0.00669342162296594323; public static double[] transform (double Wglat, double Wglon) {double[] latlng = new double[2]; if (Outofchina (Wglat, Wglon)) {latlng[0] = Wglat; LATLNG[1] = Wglon; return null; } Double Dlat = Transformlat (wgLon-105.0, wgLat-35.0); Double Dlon = Transformlon (wgLon-105.0, wgLat-35.0); Double Radlat = wglat/180.0 * PI; Double magic = Math.sin (Radlat); Magic = 1-ee * Magic * MAGIC; Double sqrtmagic = math.sqrt (Magic); Dlat = (Dlat * 180.0)/((A * (1-ee))/(Magic * sqrtmagic) * pi); Dlon = (Dlon * 180.0)/(A/sqrtmagic * math.coS (radlat) * pi); Latlng[0] = Wglat + Dlat; LATLNG[1] = Wglon + Dlon; return latlng; } private static bool Outofchina (double lat, double lon) {if (Lon < 72.004 | | Lon > 137.83 ) return true; if (Lat < 0.8293 | | lat > 55.8271) return true; return false; } private static Double Transformlat (double x, double y) {double ret = -100.0 + 2.0 * x + 3.0 * Y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt (Math.Abs (x)); RET + = (20.0 * Math.sin (6.0 * x * pi) + 20.0 * Math.sin (2.0 * x * pi)) * 2.0/3.0; RET + = (20.0 * Math.sin (y * pi) + 40.0 * Math.sin (y/3.0 * pi)) * 2.0/3.0; RET + = (160.0 * Math.sin (y/12.0 * pi) + * * Math.sin (Y * pi/30.0)) * 2.0/3.0; return ret; } private static Double Transformlon (double x, double y) {double ret = 300.0 + x + 2.0 *Y + 0.1 * x * x + 0.1 * x * y + 0.1 * MATH.SQRT (Math.Abs (x)); RET + = (20.0 * Math.sin (6.0 * x * pi) + 20.0 * Math.sin (2.0 * x * pi)) * 2.0/3.0; RET + = (20.0 * Math.sin (x * pi) + 40.0 * Math.sin (x/3.0 * pi)) * 2.0/3.0; RET + = (150.0 * Math.sin (x/12.0 * pi) + 300.0 * Math.sin (x/30.0 * pi)) * 2.0/3.0; return ret; } }
Originated from http://blog.csdn.net/junfeng120125/article/details/9966857
Gmap Google Maps for the correction of the security algorithm