Commit 8f2ae3a5 authored by Matthew Bloch's avatar Matthew Bloch Committed by Calvin Metcalf
Browse files

Prevent 180 and -180 degrees lon from wrapping and explain the rounded PI value in adjust_lon.js

parent 6937e2ca
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
var TWO_PI = Math.PI * 2;
// SPI is slightly greater than Math.PI, so values that exceed the -180..180
// degree range by a tiny amount don't get wrapped. This prevents points that
// have drifted from their original location along the 180th meridian (due to
// floating point error) from changing their sign.
var SPI = 3.14159265359;
var sign = require('./sign');

module.exports = function(x) {
  return (Math.abs(x) < Math.PI) ? x : (x - (sign(x) * TWO_PI));
  return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));
};
 No newline at end of file
+13 −2
Original line number Diff line number Diff line
@@ -284,6 +284,17 @@ var testPoints = [
    code:"+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56",
    ll: [12.806988, 49.452262],
    xy: [-868208.61, -1095793.64]
  },
  // check that coordinates at 180 and -180 deg. longitude don't wrap around
  {
    code: 'EPSG:3857',
    ll: [-180, 0],
    xy: [-20037508.342789, 0]
  },
  {
    code: 'EPSG:3857',
    ll: [180, 0],
    xy: [20037508.342789, 0]
  }
];
if(typeof module !== 'undefined'){