Keep longitude between -180 and 180

This commit is contained in:
Tim Schaub
2017-11-05 13:44:51 -07:00
parent 4a6317dde3
commit 42da3f18dd
2 changed files with 32 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.EPSG4326');
goog.require('ol.proj.Projection');
@@ -12,6 +11,30 @@ describe('ol.proj', function() {
ol.proj.addCommon();
});
describe('toLonLat()', function() {
var cases = [{
from: [0, 0],
to: [0, 0]
}, {
from: [-12356463.478053365, 5700582.732404122],
to: [-111, 45.5]
}, {
from: [2 * ol.proj.EPSG3857.HALF_SIZE - 12356463.478053365, 5700582.732404122],
to: [-111, 45.5]
}, {
from: [-4 * ol.proj.EPSG3857.HALF_SIZE - 12356463.478053365, 5700582.732404122],
to: [-111, 45.5]
}];
cases.forEach(function(c) {
it('works for ' + c.from.join(', '), function() {
var lonLat = ol.proj.toLonLat(c.from);
expect(lonLat[0]).to.roughlyEqual(c.to[0], 1e-9);
expect(lonLat[1]).to.roughlyEqual(c.to[1], 1e-9);
});
});
});
describe('projection equivalence', function() {
function _testAllEquivalent(codes) {