Posted By

renjicode on 11/10/13


Tagged

algorithm


Versions (?)

Convert between GCJ-02 and BD-09 Geodetic System


 / Published in: Java
 

bdencrypt 将 GCJ-02 坐标转换成 BD-09 坐标, bddecrypt 反之

  1. const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  2.  
  3. void bd_encrypt(double gg_lat, double gg_lon, double &bd_lat, double &bd_lon)
  4. {
  5. double x = gg_lon, y = gg_lat;
  6. double z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi);
  7. double theta = atan2(y, x) + 0.000003 * cos(x * x_pi);
  8. bd_lon = z * cos(theta) + 0.0065;
  9. bd_lat = z * sin(theta) + 0.006;
  10. }
  11.  
  12. void bd_decrypt(double bd_lat, double bd_lon, double &gg_lat, double &gg_lon)
  13. {
  14. double x = bd_lon - 0.0065, y = bd_lat - 0.006;
  15. double z = sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi);
  16. double theta = atan2(y, x) - 0.000003 * cos(x * x_pi);
  17. gg_lon = z * cos(theta);
  18. gg_lat = z * sin(theta);
  19. }

Report this snippet  

You need to login to post a comment.