java 80转84_Web墨卡托坐标与WGS84经纬度互转 java代码

Web墨卡托坐标与WGS84经纬度互转 java代码

时间:5年前

浏览:2305

[网络转载]

package com.util;

public class Coordinate {

static double M_PI = Math.PI;

// 经纬度转墨卡托

// 经度(lon),纬度(lat)

public static double[] lonLat2Mercator(double lon, double lat) {

double[] xy = new double[2];

double x = lon * 20037508.342789 / 180;

double y = Math.log(Math.tan((90 + lat) * M_PI / 360)) / (M_PI / 180);

y = y * 20037508.34789 / 180;

xy[0] = x;

xy[1] = y;

return xy;

}

// 墨卡托转经纬度

public static double[] Mercator2lonLat(double mercatorX, double mercatorY) {

double[] xy = new double[2];

double x = mercatorX / 20037508.34 * 180;

double y = mercatorY / 20037508.34 * 180;

y = 180 / M_PI * (2 * Math.atan(Math.exp(y * M_PI / 180)) - M_PI / 2);

xy[0] = x;

xy[1] = y;

return xy;

}

public static void main(String[] args) {

// num;

double[] num = lonLat2Mercator(120.385222, 36.061416);

System.err.println(num[0]+" "+num[1]);

//for (int i = 0; i < num.length; i++) {

//System.out.println(num[0]+" "+num[1]);

//}

// num = Mercator2lonLat(13401221.612075035,4309075.414032666);

// for(int i=0;i

// {

// System.out.println(num[i]);

// }

}

}

内容均为作者独立观点,不代表八零IT人立场,如涉及侵权,请及时告知。

本站文章除注明转载外,均为本站原创,欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创和谐网络社区。

转载请注明:文章转载自-八零IT人 [http://www.80iter.com]

本文标题:Web墨卡托坐标与WGS84经纬度互转 java代码

本文地址:http://www.80iter.com/blog/1450232766946422

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值