1 describe("Projection.Mercator", function() {
2 var p
= L
.Projection
.Mercator
;
4 beforeEach(function() {
5 function almostEqual(a
, b
, p
) {
6 return Math
.abs(a
- b
) <= (p
|| 1.0E-12);
9 toAlmostEqual: function(expected
, margin
) {
12 return almostEqual(p1
.x
, p2
.x
, margin
) && almostEqual(p1
.y
, p2
.y
, margin
);
18 describe("#project", function() {
19 it("should do projection properly", function() {
21 expect(p
.project(new L
.LatLng(0, 0))).toAlmostEqual(new L
.Point(0, 0));
22 expect(p
.project(new L
.LatLng(90, 180))).toAlmostEqual(new L
.Point(-Math
.PI
, Math
.PI
));
23 expect(p
.project(new L
.LatLng(-90, -180))).toAlmostEqual(new L
.Point(-Math
.PI
, -Math
.PI
));
25 expect(p
.project(new L
.LatLng(50, 30))).toAlmostEqual(new L
.Point(0.523598775598, 1.010683188683));
29 describe("#unproject", function() {
30 it("should do unprojection properly", function() {
32 return p
.project(p
.unproject(point
));
35 expect(pr(new L
.Point(0, 0))).toAlmostEqual(new L
.Point(0, 0));
36 expect(pr(new L
.Point(-Math
.PI
, Math
.PI
))).toAlmostEqual(new L
.Point(-Math
.PI
, Math
.PI
));
37 expect(pr(new L
.Point(-Math
.PI
, -Math
.PI
))).toAlmostEqual(new L
.Point(-Math
.PI
, -Math
.PI
));
39 expect(pr(new L
.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L
.Point(0.523598775598, 1.010683188683));