diff options
author | Joar Wandborg <git@wandborg.com> | 2012-01-28 18:47:01 +0100 |
---|---|---|
committer | Joar Wandborg <git@wandborg.com> | 2012-01-28 18:47:01 +0100 |
commit | 3d0d3bc97270095fae5f9a2508068631c46a5e61 (patch) | |
tree | 76778fcacaae35fc5662f276dab512a07bcee186 /extlib/leaflet/spec/suites/geo/ProjectionSpec.js | |
parent | d7bec8577ea1b4d83df097f586324445fed1ef50 (diff) | |
parent | 9542a2ba076b7e00e79d7adb1a4e90a095427645 (diff) | |
download | mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.lz mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.xz mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.zip |
Merge remote-tracking branch 'joar/exif-rebase'
Diffstat (limited to 'extlib/leaflet/spec/suites/geo/ProjectionSpec.js')
-rw-r--r-- | extlib/leaflet/spec/suites/geo/ProjectionSpec.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/extlib/leaflet/spec/suites/geo/ProjectionSpec.js b/extlib/leaflet/spec/suites/geo/ProjectionSpec.js new file mode 100644 index 00000000..6b9c7b61 --- /dev/null +++ b/extlib/leaflet/spec/suites/geo/ProjectionSpec.js @@ -0,0 +1,42 @@ +describe("Projection.Mercator", function() {
+ var p = L.Projection.Mercator;
+
+ beforeEach(function() {
+ function almostEqual(a, b, p) {
+ return Math.abs(a - b) <= (p || 1.0E-12);
+ };
+ 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);
+ }
+ });
+ });
+
+
+ describe("#project", function() {
+ it("should do projection properly", function() {
+ //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));
+
+ expect(p.project(new L.LatLng(50, 30))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
+ });
+ });
+
+ describe("#unproject", function() {
+ it("should do unprojection properly", function() {
+ function pr(point) {
+ return p.project(p.unproject(point));
+ }
+
+ 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));
+
+ expect(pr(new L.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
+ });
+ });
+});
\ No newline at end of file |