2011-07-12 20:32:22 +08:00
|
|
|
xdescribe("Projection.Mercator", function() {
|
2010-09-07 16:59:58 +08:00
|
|
|
var p = L.Projection.Mercator;
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2010-09-07 16:59:58 +08:00
|
|
|
beforeEach(function() {
|
|
|
|
function almostEqual(a, b, p) {
|
|
|
|
return Math.abs(a - b) <= (p || 1.0E-12);
|
2013-02-20 00:18:15 +08:00
|
|
|
}
|
2010-09-07 16:59:58 +08:00
|
|
|
this.addMatchers({
|
|
|
|
toAlmostEqual: function(expected, margin) {
|
|
|
|
var p1 = this.actual,
|
|
|
|
p2 = expected;
|
|
|
|
return almostEqual(p1.x, p2.x, margin) && almostEqual(p1.y, p2.y, margin);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2010-09-07 16:59:58 +08:00
|
|
|
|
|
|
|
describe("#project", function() {
|
2013-02-20 04:41:48 +08:00
|
|
|
it("projects", function() {
|
2010-09-07 16:59:58 +08:00
|
|
|
//edge cases
|
|
|
|
expect(p.project(new L.LatLng(0, 0))).toAlmostEqual(new L.Point(0, 0));
|
|
|
|
expect(p.project(new L.LatLng(90, 180))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
|
|
|
|
expect(p.project(new L.LatLng(-90, -180))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2010-09-07 16:59:58 +08:00
|
|
|
expect(p.project(new L.LatLng(50, 30))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#unproject", function() {
|
2013-02-20 04:41:48 +08:00
|
|
|
it("unprojects", function() {
|
2010-09-07 16:59:58 +08:00
|
|
|
function pr(point) {
|
|
|
|
return p.project(p.unproject(point));
|
|
|
|
}
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2010-09-07 16:59:58 +08:00
|
|
|
expect(pr(new L.Point(0, 0))).toAlmostEqual(new L.Point(0, 0));
|
|
|
|
expect(pr(new L.Point(-Math.PI, Math.PI))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
|
|
|
|
expect(pr(new L.Point(-Math.PI, -Math.PI))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2010-09-07 16:59:58 +08:00
|
|
|
expect(pr(new L.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
|
|
|
|
});
|
2010-09-07 00:17:27 +08:00
|
|
|
});
|
2013-02-20 00:18:15 +08:00
|
|
|
});
|