首页 > 代码库 > WGS84经纬度坐标与web墨卡托之间的转换

WGS84经纬度坐标与web墨卡托之间的转换

//经纬度转Web墨卡托dvec3 CMathEngine::lonLat2WebMercator(dvec3  lonLat){    dvec3  mercator;    double x = lonLat.x *20037508.34/180;    double y = log(tan((90+lonLat.y)*PI/360))/(PI/180);    y = y *20037508.34/180;    mercator.x = x;    mercator.y = y;    return mercator;}//Web墨卡托转经纬度dvec3 CMathEngine::WebMercator2lonLat( dvec3   mercator ){    dvec3 lonLat;    double x = mercator.x/20037508.34*180;    double y = mercator.y/20037508.34*180;    y= 180/PI*(2*atan(exp(y*PI/180))-PI/2);    lonLat.x = x;    lonLat.y = y;    return lonLat;}

 

WGS84经纬度坐标与web墨卡托之间的转换