iqsfnz.js 909 B

1234567891011121314151617181920212223242526272829303132
  1. import {HALF_PI} from '../constants/values';
  2. export default function(eccent, q) {
  3. var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));
  4. if (Math.abs(Math.abs(q) - temp) < 1.0E-6) {
  5. if (q < 0) {
  6. return (-1 * HALF_PI);
  7. }
  8. else {
  9. return HALF_PI;
  10. }
  11. }
  12. //var phi = 0.5* q/(1-eccent*eccent);
  13. var phi = Math.asin(0.5 * q);
  14. var dphi;
  15. var sin_phi;
  16. var cos_phi;
  17. var con;
  18. for (var i = 0; i < 30; i++) {
  19. sin_phi = Math.sin(phi);
  20. cos_phi = Math.cos(phi);
  21. con = eccent * sin_phi;
  22. dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
  23. phi += dphi;
  24. if (Math.abs(dphi) <= 0.0000000001) {
  25. return phi;
  26. }
  27. }
  28. //console.log("IQSFN-CONV:Latitude failed to converge after 30 iterations");
  29. return NaN;
  30. }