美文网首页
经纬度与墨卡托互相转换

经纬度与墨卡托互相转换

作者: J大空 | 来源:发表于2019-10-20 21:12 被阅读0次

    //经纬度转墨卡托
    public Vector2D lonLat2Mercator(Vector2D lonLat)
    {
    Vector2D mercator = new Vector2D();
    double x = lonLat.X * 20037508.34 / 180;
    double y = Math.Log(Math.Tan((90 + lonLat.Y) * Math.PI / 360)) / (Math.PI / 180);
    y = y * 20037508.34 / 180;
    mercator.X = x;
    mercator.Y = y;
    return mercator;
    }
    //墨卡托转经纬度
    public Vector2D Mercator2lonLat(Vector2D mercator)
    {
    Vector2D lonLat = new Vector2D();
    double x = mercator.X / 20037508.34 * 180;
    double y = mercator.Y / 20037508.34 * 180;
    y = 180 / Math.PI * (2 * Math.Atan(Math.Exp(y * Math.PI / 180)) - Math.PI / 2);
    lonLat.X = x;
    lonLat.Y = y;
    return lonLat;
    }

    相关文章

      网友评论

          本文标题:经纬度与墨卡托互相转换

          本文链接:https://www.haomeiwen.com/subject/bmgamctx.html