d3js-plugins-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +1 -0
  6. data/d3js-plugins-rails.gemspec +21 -0
  7. data/lib/d3js-plugins-rails/version.rb +7 -0
  8. data/lib/d3js-plugins-rails.rb +10 -0
  9. data/vendor/assets/javascripts/d3/plugins/.gitignore +1 -0
  10. data/vendor/assets/javascripts/d3/plugins/LICENSE +26 -0
  11. data/vendor/assets/javascripts/d3/plugins/Makefile +87 -0
  12. data/vendor/assets/javascripts/d3/plugins/README.md +19 -0
  13. data/vendor/assets/javascripts/d3/plugins/box/box.js +301 -0
  14. data/vendor/assets/javascripts/d3/plugins/bullet/README.md +14 -0
  15. data/vendor/assets/javascripts/d3/plugins/bullet/bullet.js +241 -0
  16. data/vendor/assets/javascripts/d3/plugins/chernoff/README.md +15 -0
  17. data/vendor/assets/javascripts/d3/plugins/chernoff/chernoff.js +176 -0
  18. data/vendor/assets/javascripts/d3/plugins/cie/README.md +54 -0
  19. data/vendor/assets/javascripts/d3/plugins/cie/cie.js +155 -0
  20. data/vendor/assets/javascripts/d3/plugins/fisheye/README.md +43 -0
  21. data/vendor/assets/javascripts/d3/plugins/fisheye/fisheye.js +85 -0
  22. data/vendor/assets/javascripts/d3/plugins/force_labels/README.md +29 -0
  23. data/vendor/assets/javascripts/d3/plugins/force_labels/force_labels.js +56 -0
  24. data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/README.md +7 -0
  25. data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/polyhedron.js +436 -0
  26. data/vendor/assets/javascripts/d3/plugins/geo/projection/README.md +107 -0
  27. data/vendor/assets/javascripts/d3/plugins/geo/projection/aitoff.js +40 -0
  28. data/vendor/assets/javascripts/d3/plugins/geo/projection/armadillo.js +79 -0
  29. data/vendor/assets/javascripts/d3/plugins/geo/projection/august.js +15 -0
  30. data/vendor/assets/javascripts/d3/plugins/geo/projection/baker.js +28 -0
  31. data/vendor/assets/javascripts/d3/plugins/geo/projection/berghaus.js +60 -0
  32. data/vendor/assets/javascripts/d3/plugins/geo/projection/boggs.js +27 -0
  33. data/vendor/assets/javascripts/d3/plugins/geo/projection/bonne.js +29 -0
  34. data/vendor/assets/javascripts/d3/plugins/geo/projection/bromley.js +5 -0
  35. data/vendor/assets/javascripts/d3/plugins/geo/projection/collignon.js +17 -0
  36. data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js +29 -0
  37. data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js +27 -0
  38. data/vendor/assets/javascripts/d3/plugins/geo/projection/craig.js +24 -0
  39. data/vendor/assets/javascripts/d3/plugins/geo/projection/craster.js +18 -0
  40. data/vendor/assets/javascripts/d3/plugins/geo/projection/cylindrical-equal-area.js +23 -0
  41. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert1.js +18 -0
  42. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert2.js +17 -0
  43. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert3.js +17 -0
  44. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert4.js +24 -0
  45. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert5.js +17 -0
  46. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert6.js +22 -0
  47. data/vendor/assets/javascripts/d3/plugins/geo/projection/eisenlohr.js +16 -0
  48. data/vendor/assets/javascripts/d3/plugins/geo/projection/end.js +1 -0
  49. data/vendor/assets/javascripts/d3/plugins/geo/projection/gringorten.js +111 -0
  50. data/vendor/assets/javascripts/d3/plugins/geo/projection/guyou.js +46 -0
  51. data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer-retroazimuthal.js +75 -0
  52. data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer.js +51 -0
  53. data/vendor/assets/javascripts/d3/plugins/geo/projection/hatano.js +25 -0
  54. data/vendor/assets/javascripts/d3/plugins/geo/projection/healpix.js +64 -0
  55. data/vendor/assets/javascripts/d3/plugins/geo/projection/hill.js +64 -0
  56. data/vendor/assets/javascripts/d3/plugins/geo/projection/homolosine.js +17 -0
  57. data/vendor/assets/javascripts/d3/plugins/geo/projection/interrupt.js +111 -0
  58. data/vendor/assets/javascripts/d3/plugins/geo/projection/kavrayskiy7.js +15 -0
  59. data/vendor/assets/javascripts/d3/plugins/geo/projection/lagrange.js +27 -0
  60. data/vendor/assets/javascripts/d3/plugins/geo/projection/larrivee.js +39 -0
  61. data/vendor/assets/javascripts/d3/plugins/geo/projection/laskowski.js +31 -0
  62. data/vendor/assets/javascripts/d3/plugins/geo/projection/littrow.js +21 -0
  63. data/vendor/assets/javascripts/d3/plugins/geo/projection/loximuthal.js +29 -0
  64. data/vendor/assets/javascripts/d3/plugins/geo/projection/miller.js +15 -0
  65. data/vendor/assets/javascripts/d3/plugins/geo/projection/mollweide.js +35 -0
  66. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-parabolic.js +21 -0
  67. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-quartic.js +23 -0
  68. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-sinusoidal.js +25 -0
  69. data/vendor/assets/javascripts/d3/plugins/geo/projection/natural-earth.js +22 -0
  70. data/vendor/assets/javascripts/d3/plugins/geo/projection/nell-hammer.js +20 -0
  71. data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel1.js +12 -0
  72. data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel2.js +13 -0
  73. data/vendor/assets/javascripts/d3/plugins/geo/projection/peirce-quincuncial.js +14 -0
  74. data/vendor/assets/javascripts/d3/plugins/geo/projection/polyconic.js +25 -0
  75. data/vendor/assets/javascripts/d3/plugins/geo/projection/projection.js +29 -0
  76. data/vendor/assets/javascripts/d3/plugins/geo/projection/robinson.js +83 -0
  77. data/vendor/assets/javascripts/d3/plugins/geo/projection/satellite.js +68 -0
  78. data/vendor/assets/javascripts/d3/plugins/geo/projection/sinu-mollweide.js +19 -0
  79. data/vendor/assets/javascripts/d3/plugins/geo/projection/sinusoidal.js +15 -0
  80. data/vendor/assets/javascripts/d3/plugins/geo/projection/start.js +1 -0
  81. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/aitoff-test.js +26 -0
  82. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/armadillo-test.js +28 -0
  83. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/baker-test.js +26 -0
  84. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/boggs-test.js +26 -0
  85. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/bonne-test.js +45 -0
  86. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craig-test.js +25 -0
  87. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craster-test.js +25 -0
  88. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/env.js +32 -0
  89. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/equirectangular-test.js +97 -0
  90. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hammer-test.js +29 -0
  91. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hatano-test.js +25 -0
  92. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hill-test.js +26 -0
  93. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/larrivee-test.js +25 -0
  94. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/laskowski-test.js +26 -0
  95. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/littrow-test.js +24 -0
  96. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/loximuthal-test.js +25 -0
  97. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mollweide-test.js +26 -0
  98. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-parabolic-test.js +25 -0
  99. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-quartic-test.js +25 -0
  100. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-sinusoidal-test.js +25 -0
  101. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/natural-earth-test.js +26 -0
  102. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/quartic-authalic-test.js +0 -0
  103. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/robinson-test.js +26 -0
  104. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/wagner6-test.js +25 -0
  105. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/winkel3-test.js +26 -0
  106. data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten.js +41 -0
  107. data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten4.js +22 -0
  108. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner4.js +9 -0
  109. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner6.js +15 -0
  110. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner7.js +22 -0
  111. data/vendor/assets/javascripts/d3/plugins/geo/projection/wiechel.js +14 -0
  112. data/vendor/assets/javascripts/d3/plugins/geo/projection/winkel3.js +40 -0
  113. data/vendor/assets/javascripts/d3/plugins/geo/tile/README.md +6 -0
  114. data/vendor/assets/javascripts/d3/plugins/geo/tile/tile.js +53 -0
  115. data/vendor/assets/javascripts/d3/plugins/geodesic/README.md +3 -0
  116. data/vendor/assets/javascripts/d3/plugins/geodesic/geodesic.js +130 -0
  117. data/vendor/assets/javascripts/d3/plugins/geom/contour/README.md +5 -0
  118. data/vendor/assets/javascripts/d3/plugins/geom/contour/contour.js +72 -0
  119. data/vendor/assets/javascripts/d3/plugins/graph/README.md +148 -0
  120. data/vendor/assets/javascripts/d3/plugins/graph/data/cities-matrix.json +37 -0
  121. data/vendor/assets/javascripts/d3/plugins/graph/data/cities.csv +36 -0
  122. data/vendor/assets/javascripts/d3/plugins/graph/data/miserables.json +338 -0
  123. data/vendor/assets/javascripts/d3/plugins/graph/graph.js +161 -0
  124. data/vendor/assets/javascripts/d3/plugins/graph/index.html +37 -0
  125. data/vendor/assets/javascripts/d3/plugins/hexbin/README.md +58 -0
  126. data/vendor/assets/javascripts/d3/plugins/hexbin/hexbin.js +96 -0
  127. data/vendor/assets/javascripts/d3/plugins/hive/README.md +5 -0
  128. data/vendor/assets/javascripts/d3/plugins/hive/hive.js +80 -0
  129. data/vendor/assets/javascripts/d3/plugins/horizon/README.md +11 -0
  130. data/vendor/assets/javascripts/d3/plugins/horizon/horizon.js +192 -0
  131. data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/README.md +11 -0
  132. data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/interpolate-zoom.js +75 -0
  133. data/vendor/assets/javascripts/d3/plugins/jsonp/README.md +26 -0
  134. data/vendor/assets/javascripts/d3/plugins/jsonp/jsonp.js +25 -0
  135. data/vendor/assets/javascripts/d3/plugins/keybinding/README.md +17 -0
  136. data/vendor/assets/javascripts/d3/plugins/keybinding/keybinding.js +120 -0
  137. data/vendor/assets/javascripts/d3/plugins/longscroll/README.md +10 -0
  138. data/vendor/assets/javascripts/d3/plugins/longscroll/longscroll.js +75 -0
  139. data/vendor/assets/javascripts/d3/plugins/package.json +20 -0
  140. data/vendor/assets/javascripts/d3/plugins/qq/README.md +3 -0
  141. data/vendor/assets/javascripts/d3/plugins/qq/qq.js +249 -0
  142. data/vendor/assets/javascripts/d3/plugins/rollup/README.md +5 -0
  143. data/vendor/assets/javascripts/d3/plugins/rollup/rollup.js +131 -0
  144. data/vendor/assets/javascripts/d3/plugins/sankey/README.md +17 -0
  145. data/vendor/assets/javascripts/d3/plugins/sankey/sankey.js +292 -0
  146. data/vendor/assets/javascripts/d3/plugins/simplify/README.md +6 -0
  147. data/vendor/assets/javascripts/d3/plugins/simplify/simplify-test.js +193 -0
  148. data/vendor/assets/javascripts/d3/plugins/simplify/simplify.js +446 -0
  149. data/vendor/assets/javascripts/d3/plugins/superformula/superformula.js +98 -0
  150. data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode-test.js +68 -0
  151. data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode.js +37 -0
  152. metadata +218 -0
@@ -0,0 +1,19 @@
1
+ // @import mollweide
2
+ // @import sinusoidal
3
+
4
+ var sinuMollweideφ = .7109889596207567,
5
+ sinuMollweideY = .0528035274542;
6
+
7
+ function sinuMollweide(λ, φ) {
8
+ return φ > -sinuMollweideφ
9
+ ? (λ = mollweide(λ, φ), λ[1] += sinuMollweideY, λ)
10
+ : sinusoidal(λ, φ);
11
+ }
12
+
13
+ sinuMollweide.invert = function(x, y) {
14
+ return y > -sinuMollweideφ
15
+ ? mollweide.invert(x, y - sinuMollweideY)
16
+ : sinusoidal.invert(x, y);
17
+ };
18
+
19
+ (d3.geo.sinuMollweide = function() { return projection(sinuMollweide).rotate([-20, -55]); }).raw = sinuMollweide;
@@ -0,0 +1,15 @@
1
+ function sinusoidal(λ, φ) {
2
+ return [
3
+ λ * Math.cos(φ),
4
+ φ
5
+ ];
6
+ }
7
+
8
+ sinusoidal.invert = function(x, y) {
9
+ return [
10
+ x / Math.cos(y),
11
+ y
12
+ ];
13
+ };
14
+
15
+ (d3.geo.sinusoidal = function() { return projection(sinusoidal); }).raw = sinusoidal;
@@ -0,0 +1,26 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.aitoff");
7
+
8
+ suite.addBatch({
9
+ "aitoff": {
10
+ topic: d3.geo.aitoff,
11
+ "projections and inverse projections": function(aitoff) {
12
+ assert.equalInverse(aitoff, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(aitoff, [ 0, -90], [480, 485.619449]);
14
+ assert.equalInverse(aitoff, [ 0, 90], [480, 14.380550]);
15
+ assert.equalInverse(aitoff, [ 0, -45], [480, 367.809724]);
16
+ assert.equalInverse(aitoff, [ 0, 45], [480, 132.190275]);
17
+ assert.equalInverse(aitoff, [-180, 0], [ 8.761101, 250]);
18
+ assert.equalInverse(aitoff, [ 180, 0], [951.238898, 250]);
19
+ assert.equalInverse(aitoff, [-179, 15], [ 27.261952, 189.342293]);
20
+ assert.equalInverse(aitoff, [ 1, 1], [482.617728, 247.381972]);
21
+ assert.equalInverse(aitoff, [ 45, 87], [489.158099, 21.6821110]);
22
+ }
23
+ }
24
+ });
25
+
26
+ suite.export(module);
@@ -0,0 +1,28 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.armadillo");
7
+
8
+ suite.addBatch({
9
+ "armadillo": {
10
+ topic: d3.geo.armadillo,
11
+ "projections and inverse projections": function(armadillo) {
12
+ assert.equalInverse(armadillo, [ 0, 0], [480, 250]);
13
+ // TODO: needs D3 core support
14
+ // assert.isNaN(armadillo([0, -90])[0]);
15
+ assert.equalInverse(armadillo, [ 0, 90], [480, 57.743085]);
16
+ assert.equalInverse(armadillo, [ 0, -45], [480, 334.643146]);
17
+ assert.equalInverse(armadillo, [ 0, 45], [480, 135.304239]);
18
+ // TODO figure out why the inverse doesn't match exactly.
19
+ // assert.equalInverse(armadillo, [-180, 0], [180, 147.393957]);
20
+ // assert.equalInverse(armadillo, [ 180, 0], [780, 147.393957]);
21
+ assert.equalInverse(armadillo, [-179, 15], [185.122354, 111.792545]);
22
+ assert.equalInverse(armadillo, [ 1, 1], [482.617761, 247.528295]);
23
+ assert.equalInverse(armadillo, [ 45, 87], [540.406730, 56.511657]);
24
+ }
25
+ }
26
+ });
27
+
28
+ suite.export(module);
@@ -0,0 +1,26 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.baker");
7
+
8
+ suite.addBatch({
9
+ "baker": {
10
+ topic: d3.geo.baker,
11
+ "projections and inverse projections": function(baker) {
12
+ assert.equalInverse(baker, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(baker, [ 0, -90], [480, 583.216220]);
14
+ assert.equalInverse(baker, [ 0, 90], [480, -83.216220]);
15
+ assert.equalInverse(baker, [ 0, -45], [480, 382.206038]);
16
+ assert.equalInverse(baker, [ 0, 45], [480, 117.793961]);
17
+ assert.equalInverse(baker, [-180, 0], [ 8.761101, 250]);
18
+ assert.equalInverse(baker, [ 180, 0], [951.238898, 250]);
19
+ assert.equalInverse(baker, [-179, 15], [ 11.379095, 210.273662]);
20
+ assert.equalInverse(baker, [ 1, 1], [482.617993, 247.381873]);
21
+ assert.equalInverse(baker, [ 45, 87], [491.265043, -68.859378]);
22
+ }
23
+ }
24
+ });
25
+
26
+ suite.export(module);
@@ -0,0 +1,26 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.boggs");
7
+
8
+ suite.addBatch({
9
+ "boggs": {
10
+ topic: d3.geo.boggs,
11
+ "projections and inverse projections": function(boggs) {
12
+ assert.equalInverse(boggs, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(boggs, [ 0, -90], [480, 473.567218]);
14
+ assert.equalInverse(boggs, [ 0, 90], [480, 26.432781]);
15
+ assert.equalInverse(boggs, [ 0, -45], [480, 371.532657]);
16
+ assert.equalInverse(boggs, [ 0, 45], [480, 128.467342]);
17
+ assert.equalInverse(boggs, [-180, 0], [ 32.864228, 250]);
18
+ assert.equalInverse(boggs, [ 180, 0], [927.135771, 250]);
19
+ assert.equalInverse(boggs, [-179, 15], [ 47.500957, 208.708722]);
20
+ assert.equalInverse(boggs, [ 1, 1], [482.483785, 247.240908]);
21
+ assert.equalInverse(boggs, [ 45, 87], [488.857270, 31.512628]);
22
+ }
23
+ }
24
+ });
25
+
26
+ suite.export(module);
@@ -0,0 +1,45 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.bonne");
7
+
8
+ suite.addBatch({
9
+ "bonne": {
10
+ "40° parallel": {
11
+ topic: function() {
12
+ return d3.geo.bonne().parallel(40);
13
+ },
14
+ "projections and inverse projections": function(bonne) {
15
+ assert.equalInverse(bonne, [ 0, 0], [480, 250]);
16
+ assert.equalInverse(bonne, [ 0, -90], [480, 485.619449]);
17
+ assert.equalInverse(bonne, [ 0, 90], [480, 14.380550]);
18
+ assert.equalInverse(bonne, [ 0, -45], [480, 367.809724]);
19
+ assert.equalInverse(bonne, [ 0, 45], [480, 132.190275]);
20
+ assert.equalInverse(bonne, [-180, 0], [197.703665, -59.391754]);
21
+ assert.equalInverse(bonne, [ 180, 0], [762.296334, -59.391754]);
22
+ assert.equalInverse(bonne, [-179, 15], [245.482446, -101.610988]);
23
+ assert.equalInverse(bonne, [ 1, 1], [482.617557, 247.369808]);
24
+ }
25
+ },
26
+ "90° parallel (Werner)": {
27
+ topic: function() {
28
+ return d3.geo.bonne().parallel(90);
29
+ },
30
+ "projections and inverse projections": function(bonne) {
31
+ assert.equalInverse(bonne, [0, 0], [480, 250]);
32
+ }
33
+ },
34
+ "0° parallel (sinusoidal)": {
35
+ topic: function() {
36
+ return d3.geo.bonne().parallel(0);
37
+ },
38
+ "projections and inverse projections": function(bonne) {
39
+ assert.equalInverse(bonne, [0, 0], [480, 250]);
40
+ }
41
+ }
42
+ }
43
+ });
44
+
45
+ suite.export(module);
@@ -0,0 +1,25 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.craig");
7
+
8
+ suite.addBatch({
9
+ "craig": {
10
+ topic: d3.geo.craig,
11
+ "projections and inverse projections": function(craig) {
12
+ assert.inDelta(craig([ 0, 0]), [480, 250], 1e-6);
13
+ assert.inDelta(craig([ 0, -90]), [480, 400], 1e-6);
14
+ assert.inDelta(craig([ 0, 90]), [480, 100], 1e-6);
15
+ assert.inDelta(craig([ 0, -45]), [480, 356.066017], 1e-6);
16
+ assert.inDelta(craig([ 0, 45]), [480, 143.933982], 1e-6);
17
+ assert.inDelta(craig([-180, 0]), [ 8.761101, 250], 1e-6);
18
+ assert.inDelta(craig([ 180, 0]), [951.238898, 250], 1e-6);
19
+ assert.inDelta(craig([-179, 15]), [ 11.3790958, 7198.585721], 1e-6);
20
+ assert.inDelta(craig([ 1, 1]), [482.617993, 247.382404], 1e-6);
21
+ }
22
+ }
23
+ });
24
+
25
+ suite.export(module);
@@ -0,0 +1,25 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.craster");
7
+
8
+ suite.addBatch({
9
+ "craster": {
10
+ topic: d3.geo.craster,
11
+ "projections and inverse projections": function(craster) {
12
+ assert.equalInverse(craster, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(craster, [ 0, -90], [480, 480.248509]);
14
+ assert.equalInverse(craster, [ 0, 90], [480, 19.751490]);
15
+ assert.equalInverse(craster, [ 0, -45], [480, 369.185398]);
16
+ assert.equalInverse(craster, [ 0, 45], [480, 130.814601]);
17
+ assert.equalInverse(craster, [-180, 0], [ 19.502981, 250]);
18
+ assert.equalInverse(craster, [ 180, 0], [940.497018, 250]);
19
+ assert.equalInverse(craster, [-179, 15], [ 35.975533, 209.865040]);
20
+ assert.equalInverse(craster, [ 1, 1], [482.557970, 247.320952]);
21
+ }
22
+ }
23
+ });
24
+
25
+ suite.export(module);
@@ -0,0 +1,32 @@
1
+ require("d3");
2
+ require("../../../d3.geo.projection");
3
+
4
+ var assert = require("assert");
5
+
6
+ assert.inDelta = function(actual, expected, delta, message) {
7
+ if (!inDelta(actual, expected, delta)) {
8
+ assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta + "* of {expected}", null, assert.inDelta);
9
+ }
10
+ };
11
+
12
+ assert.equalInverse = function(projection, location, point) {
13
+ var projected;
14
+ assert.inDelta(projected = projection(location), point, 1e-6);
15
+ assert.inDelta(projection.invert(projected), location, 1e-6);
16
+ assert.inDelta(projection(projection.invert(point)), point, 1e-6);
17
+ };
18
+
19
+ function inDelta(actual, expected, delta) {
20
+ return (Array.isArray(expected) ? inDeltaArray : inDeltaNumber)(actual, expected, delta);
21
+ }
22
+
23
+ function inDeltaArray(actual, expected, delta) {
24
+ var n = expected.length, i = -1;
25
+ if (actual.length !== n) return false;
26
+ while (++i < n) if (!inDelta(actual[i], expected[i], delta)) return false;
27
+ return true;
28
+ }
29
+
30
+ function inDeltaNumber(actual, expected, delta) {
31
+ return actual >= expected - delta && actual <= expected + delta;
32
+ }
@@ -0,0 +1,97 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.equirectangular");
7
+
8
+ var π = Math.PI;
9
+
10
+ suite.addBatch({
11
+ "equirectangular": {
12
+ "rotate": {
13
+ "identity": {
14
+ topic: function() {
15
+ return d3.geo.equirectangular().rotate([0, 0]).translate([0, 0]).scale(1);
16
+ },
17
+ "projections and inverse projections": function(projection) {
18
+ assert.equalInverse(projection, [ 0, 0], [ 0, 0]);
19
+ assert.equalInverse(projection, [-180, 0], [-π, 0]);
20
+ assert.equalInverse(projection, [ 180, 0], [ π, 0]);
21
+ assert.equalInverse(projection, [ 0, 30], [ 0, -π / 6]);
22
+ assert.equalInverse(projection, [ 0, -30], [ 0, π / 6]);
23
+ assert.equalInverse(projection, [ 30, 30], [ π / 6, -π / 6]);
24
+ assert.equalInverse(projection, [ 30, -30], [ π / 6, π / 6]);
25
+ assert.equalInverse(projection, [ -30, 30], [-π / 6, -π / 6]);
26
+ assert.equalInverse(projection, [ -30, -30], [-π / 6, π / 6]);
27
+ }
28
+ },
29
+ "[30, 0]": {
30
+ topic: function() {
31
+ return d3.geo.equirectangular().rotate([30, 0]).translate([0, 0]).scale(1);
32
+ },
33
+ "projections and inverse projections": function(projection) {
34
+ assert.equalInverse(projection, [ 0, 0], [ π / 6, 0]);
35
+ assert.equalInverse(projection, [-180, 0], [-5 / 6 * π, 0]);
36
+ assert.inDelta( projection( [ 180, 0]),[-5 / 6 * π, 0], 1e-6); // inverse is [-180, 0]
37
+ assert.equalInverse(projection, [ 0, 30], [ π / 6, -π / 6]);
38
+ assert.equalInverse(projection, [ 0, -30], [ π / 6, π / 6]);
39
+ assert.equalInverse(projection, [ 30, 30], [ π / 3, -π / 6]);
40
+ assert.equalInverse(projection, [ 30, -30], [ π / 3, π / 6]);
41
+ assert.equalInverse(projection, [ -30, 30], [ 0 , -π / 6]);
42
+ assert.equalInverse(projection, [ -30, -30], [ 0 , π / 6]);
43
+ }
44
+ },
45
+ "[30, 30]": {
46
+ topic: function() {
47
+ return d3.geo.equirectangular().rotate([30, 30]).translate([0, 0]).scale(1);
48
+ },
49
+ "projections and inverse projections": function(projection) {
50
+ assert.equalInverse(projection, [ 0, 0], [ 0.5880026035475674, -0.44783239692893245]);
51
+ assert.equalInverse(projection, [-180, 0], [-2.5535900500422257, 0.44783239692893245]);
52
+ assert.inDelta( projection( [ 180, 0]),[-2.5535900500422257, 0.44783239692893245], 1e-6); // inverse is [-180, 0]
53
+ assert.equalInverse(projection, [ 0, 30], [ 0.8256075561643480, -0.94077119517052080]);
54
+ assert.equalInverse(projection, [ 0, -30], [ 0.4486429615608479, 0.05804529130778048]);
55
+ assert.equalInverse(projection, [ 30, 30], [ 1.4056476493802694, -0.70695172788721770]);
56
+ assert.equalInverse(projection, [ 30, -30], [ 0.8760580505981933, 0.21823451436745955]);
57
+ assert.equalInverse(projection, [ -30, 30], [ 0, -1.04719755119659760]);
58
+ assert.equalInverse(projection, [ -30, -30], [ 0, 0]);
59
+ }
60
+ },
61
+ "[0, 0, 30]": {
62
+ topic: function() {
63
+ return d3.geo.equirectangular().rotate([0, 0, 30]).translate([0, 0]).scale(1);
64
+ },
65
+ "projections and inverse projections": function(projection) {
66
+ assert.equalInverse(projection, [ 0, 0], [ 0, 0]);
67
+ assert.equalInverse(projection, [-180, 0], [-π, 0]);
68
+ assert.equalInverse(projection, [ 180, 0], [ π, 0]);
69
+ assert.equalInverse(projection, [ 0, 30], [-0.2810349015028135, -0.44783239692893245]);
70
+ assert.equalInverse(projection, [ 0, -30], [ 0.2810349015028135, 0.44783239692893245]);
71
+ assert.equalInverse(projection, [ 30, 30], [ 0.1651486774146268, -0.70695172788721760]);
72
+ assert.equalInverse(projection, [ 30, -30], [ 0.6947382761967031, 0.21823451436745964]);
73
+ assert.equalInverse(projection, [ -30, 30], [-0.6947382761967031, -0.21823451436745964]);
74
+ assert.equalInverse(projection, [ -30, -30], [-0.1651486774146268, 0.70695172788721760]);
75
+ }
76
+ },
77
+ "[30, 30, 30]": {
78
+ topic: function() {
79
+ return d3.geo.equirectangular().rotate([30, 30, 30]).translate([0, 0]).scale(1);
80
+ },
81
+ "projections and inverse projections": function(projection) {
82
+ assert.equalInverse(projection, [ 0, 0], [ 0.2810349015028135, -0.67513153293703170]);
83
+ assert.equalInverse(projection, [-180, 0], [-2.8605577520869800, 0.67513153293703170]);
84
+ assert.inDelta( projection( [ 180, 0]),[-2.8605577520869800, 0.67513153293703170], 1e-6); // inverse is [-180, 0]
85
+ assert.equalInverse(projection, [ 0, 30], [-0.0724760059270816, -1.15865677086597720]);
86
+ assert.equalInverse(projection, [ 0, -30], [ 0.4221351552567053, -0.16704161863132252]);
87
+ assert.equalInverse(projection, [ 30, 30], [ 1.2033744221750944, -1.21537512510467320]);
88
+ assert.equalInverse(projection, [ 30, -30], [ 0.8811235701944905, -0.18861638617540410]);
89
+ assert.equalInverse(projection, [ -30, 30], [-0.7137243789447654, -0.84806207898148100]);
90
+ assert.equalInverse(projection, [ -30, -30], [ 0, 0]);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ });
96
+
97
+ suite.export(module);
@@ -0,0 +1,29 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.hammer");
7
+
8
+ suite.addBatch({
9
+ "hammer": {
10
+ "quarticAuthalic": {
11
+ topic: function() {
12
+ return d3.geo.hammer().coefficient(Infinity);
13
+ },
14
+ "projections and inverse projections": function(quarticAuthalic) {
15
+ assert.equalInverse(quarticAuthalic, [ 0, 0], [480, 250]);
16
+ assert.equalInverse(quarticAuthalic, [ 0, -90], [480, 462.132034]);
17
+ assert.equalInverse(quarticAuthalic, [ 0, 90], [480, 37.867965]);
18
+ assert.equalInverse(quarticAuthalic, [ 0, -45], [480, 364.805029]);
19
+ assert.equalInverse(quarticAuthalic, [ 0, 45], [480, 135.194970]);
20
+ assert.equalInverse(quarticAuthalic, [-180, 0], [ 8.761101, 250]);
21
+ assert.equalInverse(quarticAuthalic, [ 180, 0], [951.238898, 250]);
22
+ assert.equalInverse(quarticAuthalic, [-179, 15], [ 23.441040, 210.842142]);
23
+ assert.equalInverse(quarticAuthalic, [ 1, 1], [482.617694, 247.382039]);
24
+ }
25
+ }
26
+ }
27
+ });
28
+
29
+ suite.export(module);
@@ -0,0 +1,25 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.hatano");
7
+
8
+ suite.addBatch({
9
+ "hatano": {
10
+ topic: d3.geo.hatano,
11
+ "projections and inverse projections": function(hatano) {
12
+ assert.equalInverse(hatano, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(hatano, [ 0, -90], [480, 441.538303]);
14
+ assert.equalInverse(hatano, [ 0, 90], [480, 53.383198]);
15
+ assert.equalInverse(hatano, [ 0, -45], [480, 379.209449]);
16
+ assert.equalInverse(hatano, [ 0, 45], [480, 119.704758]);
17
+ assert.equalInverse(hatano, [-180, 0], [ 79.446936, 250]);
18
+ assert.equalInverse(hatano, [ 180, 0], [880.553063, 250]);
19
+ assert.equalInverse(hatano, [-179, 15], [87.7505160, 204.093101]);
20
+ assert.equalInverse(hatano, [ 1, 1], [482.225143, 246.920082]);
21
+ }
22
+ }
23
+ });
24
+
25
+ suite.export(module);
@@ -0,0 +1,26 @@
1
+ require("./env");
2
+
3
+ var vows = require("vows"),
4
+ assert = require("assert");
5
+
6
+ var suite = vows.describe("d3.geo.hill");
7
+
8
+ suite.addBatch({
9
+ "hill": {
10
+ topic: d3.geo.hill,
11
+ "projections and inverse projections": function(hill) {
12
+ assert.equalInverse(hill, [ 0, 0], [480, 250]);
13
+ assert.equalInverse(hill, [ 0, -90], [480, 416.823782]);
14
+ assert.equalInverse(hill, [ 0, 90], [480, 18.873653]);
15
+ assert.equalInverse(hill, [ 0, -45], [480, 364.499449]);
16
+ assert.equalInverse(hill, [ 0, 45], [480, 113.253357]);
17
+ assert.equalInverse(hill, [-180, 0], [122.993559, 59.760268]);
18
+ assert.equalInverse(hill, [ 180, 0], [837.006440, 59.760268]);
19
+ assert.equalInverse(hill, [-179, 15], [154.461200, 25.636205]);
20
+ assert.equalInverse(hill, [ 1, 1], [482.330467, 247.058682]);
21
+ assert.equalInverse(hill, [ 45, 87], [508.223694, 17.762871]);
22
+ }
23
+ }
24
+ });
25
+
26
+ suite.export(module);