Script and makefile adjustments for updating extlib
[larjonas-mediagoblin.git] / extlib / leaflet / spec / suites / geo / ProjectionSpec.js
blob6b9c7b6123fd41e95ee78b121f673595cef4aeaf
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);
7 };
8 this.addMatchers({
9 toAlmostEqual: function(expected, margin) {
10 var p1 = this.actual,
11 p2 = expected;
12 return almostEqual(p1.x, p2.x, margin) && almostEqual(p1.y, p2.y, margin);
14 });
15 });
18 describe("#project", function() {
19 it("should do projection properly", function() {
20 //edge cases
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));
26 });
27 });
29 describe("#unproject", function() {
30 it("should do unprojection properly", function() {
31 function pr(point) {
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));
40 });
41 });
42 });