The coordinates obtained by the German SDK are converted to the GPS real coordinate method, the Java version

Source: Internet
Author: User

found that the high-German SDK does not provide the left turn GPS coordinates (gcj_02 to wgs_84), below is a copy of the Java version of the

/**************************** file name: Gcj2wgs.java creation time: Package: COM Author: Description: The Delta method of this class can convert the GPS latitude and longitude obtained by the German Map SDK to the true latitude and longitude degree. /package Com;import Java.util.hashmap;public class Gcj2wgs {public static void main (String [] args) {GCJ2WGS WG = new Gcj2wgs (); Hashmap<string, double> HM = Wg.delta (38.123456,114.654321); SYSTEM.OUT.PRINTLN (HM);} gcj_02_to_wgs_84double pi = 3.14159265358979324;/** * @author Author: * Method Description: Method can convert the GPS latitude and longitude obtained by the German Map SDK to the true latitude and longitude degree, Can be used to solve the problem of Android system using the high-de SDK to obtain latitude and longitude conversion. * @param the latitude and longitude required for conversion * @return latitude and longitude converted to true GPS coordinates * @throws < exception type > {@inheritDoc} exception description */public hashmap<string, DOUBLE&G T Delta (Double lat,double lon) {Double A = 6378245.0;double ee = 0.00669342162296594323;double Dlat = This.transformlat (lon -105.0, lat-35.0);d ouble Dlon = This.transformlon (lon-105.0, lat-35.0);d ouble Radlat = lat/180.0 * this.        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) * this.        PI); Dlon = (Dlon * 180.0)/(A/sqrtmagic * MATH.COS (Radlat) * this.                PI);        Hashmap<string, double> HM = new hashmap<string, double> ();        Hm.put ("lat", Lat-dlat);                Hm.put ("Lon", Lon-dlon);    return HM; }//convert longitude public 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 *) this. PI) + 20.0 * Math.sin (2.0 * x * this.        PI)) * 2.0/3.0; RET + = (20.0 * Math.sin (x * this). PI) + 40.0 * Math.sin (x/3.0 * this.        PI)) * 2.0/3.0; RET + = (150.0 * Math.sin (x/12.0 *). PI) + 300.0 * Math.sin (x/30.0 * this.        PI)) * 2.0/3.0;    return ret;  }//convert latitude public 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 *) this. PI) + 20.0 * MaTh.sin (2.0 * x * this.        PI)) * 2.0/3.0; RET + = (20.0 * Math.sin (Y * this). PI) + 40.0 * Math.sin (y/3.0 * this.        PI)) * 2.0/3.0; RET + = (160.0 * Math.sin (y/12.0 *). PI) + Math.sin * (Y * this.        pi/30.0)) * 2.0/3.0;    return ret; }}

  

The coordinates obtained by the German SDK are converted to the GPS real coordinate method, the Java version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.