struct GeoPoint { double lon; double lat; }; double m_R; //计算海图的基准维度,一般取30° void getR(double lat) { lat = lat*PI / 180; double N = 6378137 / sqrt(1 - 0.08189*0.08189*sin(lat)*sin(lat)); m_R = N*cos(lat); } //将墨卡托海图经纬度坐标转换为平面坐标,单位 :米 void getMokato(GeoPoint *point) { point->lon = point->lon / m_icoord*PI / 180; point->lat = point->lat / m_icoord*PI / 180; double Q = log(tan(0.785398163375 + point->lat / 2)) - 0.040945*log((1 + 0.08189*sin(point->lat)) / (1 - 0.08189*sin(point->lat))); point->lon = point->lon*m_R ; point->lat = m_R*Q ; } double getLat(double pointx, double x) { double d_e = 0.08189; double G = d_e / 2 * log((1 + d_e *sin(x)) / (1 - d_e * sin(x))) + pointx / m_R; return 2 * atan(exp(G)) - PI / 2; } //将屏幕坐标转换为墨卡托海图坐标,进行多次迭代计算, void getLatlon(GeoPoint *point) { point->lat = point->lat; double d_x = 0.0; d_x = getLat(point->lat, d_x); d_x = getLat(point->lat, d_x); d_x = getLat(point->lat, d_x); d_x = getLat(point->lat, d_x); point->lat= d_x * 180 / PI; point->lon = point->lon / m_R * 180 / PI; }
参考文章:电子海图开发,web电子海图开发,电子海图二次开发
原文链接: https://www.cnblogs.com/ecdis/p/13361724.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/369607
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!