JS algorithm to convert GPS international coordinates into High German Mars coordinates __

Source: Internet
Author: User
Tags abs sin

German API coordinate conversion: http://lbs.amap.com/api/webservice/guide/api/convert/ Algorithm Advantages

The German API has its own coordinate conversion method, each conversion requires a request, the efficiency is too low. Using this algorithm, you will have unexpected performance improvements when you need to bulk convert GPS international coordinates into a German Mars coordinate. How to use

Gps.gcj_encrypt ("Latitude", "longitude"); function returns the converted German coordinates
Code Implementation
var GPS = {pi:3.14159265358979324, x_pi:3.14159265358979324 * 3000.0/180.0, delta:function (lat, lon) {//Krasovsky 1940///A = 6378245.0, 1/f = 298.3//b = A * (1-f)//EE = (
        a^2-b^2)/a^2; var a = 6378245.0;
        A: The projection factor of the satellite ellipsoid coordinate projection to the plane map coordinate system. var ee = 0.00669342162296594323;
        EE: The eccentricity of the ellipsoid.
        var Dlat = This.transformlat (lon-105.0, lat-35.0);
        var Dlon = This.transformlon (lon-105.0, lat-35.0); var Radlat = lat/180.0 * this.
        PI;
        var magic = Math.sin (Radlat);
        Magic = 1-ee * Magic * MAGIC;
        var 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);
    return {' lat ': Dlat, ' lon ': Dlon};
            //gps---Gould gcj_encrypt:function (Wgslat, Wgslon) {if (This.outofchina (Wgslat)) ReTurn {' lat ': Wgslat, ' lon ': Wgslon};
        var d = This.delta (Wgslat, Wgslon);
    return {' lat ': Wgslat + D.lat, ' lon ': Wgslon + D.lon};
        }, Outofchina:function (lat, lon) {if (Lon < 72.004 | | lon > 137.8347) return true;
        if (Lat < 0.8293 | | | lat > 55.8271) return true;
    return false; }, Transformlat:function (x, y) {var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * M
        Ath.sqrt (Math.Abs (x)); RET = (20.0 * Math.sin (6.0 * x *). 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 * this. PI) + Math.sin * (Y * this.
        pi/30.0)) * 2.0/3.0;
    return ret; }, Transformlon:function (x, y) {var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqr
        T (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 * this. PI) + 300.0 * Math.sin (x/30.0 * this.
        PI)) * 2.0/3.0;
    return ret; }
};

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.