zoukankan      html  css  js  c++  java
  • 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法(android)

        final double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
        public GeoPoint bd_encrypt(GeoPoint point){
            double x = point.getLongitudeE6()/1E6;
            double y = point.getLatitudeE6()/1E6;
            
            double z = Math.sqrt(x*x+y*y)+0.00002*Math.sin(y*x_pi);
            double theta = Math.atan2(y, x)+0.000003*Math.cos(x*x_pi);
            
            GeoPoint bd_point = new GeoPoint((int) ((z*Math.sin(theta)+0.006)*1E6), (int) ((z*Math.cos(theta)+0.0065)*1E6));
            return bd_point;
        }
        
        public GeoPoint bd_decrypt(GeoPoint bd_point){
            double x = (double)bd_point.getLongitudeE6()/1E6 - 0.0065;
            double y = (double)bd_point.getLatitudeE6()/1E6 - 0.006;
            double z = Math.sqrt(x*x+y*y) - 0.00002*Math.sin(y*x_pi);
            double theta = Math.atan2(y, x) - 0.000003*Math.cos(x*x_pi);
            GeoPoint point = new GeoPoint((int)(z*Math.sin(theta)*1E6), (int)(z*Math.cos(theta)*1E6));
            return point;
        }
  • 相关阅读:
    UVA 1001 Say Cheese
    UVa 821 Page Hopping
    UVA 1569 Multiple
    UVA 1395 Slim Span
    UVA 12219 Common Subexpression Elimination
    UVA 246 10-20-30
    Mysql基本操作
    浅析关键字static
    面试回答技巧
    五个程序员好习惯
  • 原文地址:https://www.cnblogs.com/superping/p/3408295.html
Copyright © 2011-2022 走看看