adjust_lon.js 461 B

1234567891011
  1. var TWO_PI = Math.PI * 2;
  2. // SPI is slightly greater than Math.PI, so values that exceed the -180..180
  3. // degree range by a tiny amount don't get wrapped. This prevents points that
  4. // have drifted from their original location along the 180th meridian (due to
  5. // floating point error) from changing their sign.
  6. var SPI = 3.14159265359;
  7. var sign = require('./sign');
  8. module.exports = function(x) {
  9. return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));
  10. };