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,51 @@
1
+ var hammerAzimuthalEqualArea = d3.geo.azimuthalEqualArea.raw;
2
+
3
+ function hammer(A, B) {
4
+ if (arguments.length < 2) B = A;
5
+ if (B === 1) return hammerAzimuthalEqualArea;
6
+ if (B === Infinity) return hammerQuarticAuthalic;
7
+
8
+ function forward(λ, φ) {
9
+ var coordinates = hammerAzimuthalEqualArea(λ / B, φ);
10
+ coordinates[0] *= A;
11
+ return coordinates;
12
+ }
13
+
14
+ forward.invert = function(x, y) {
15
+ var coordinates = hammerAzimuthalEqualArea.invert(x / A, y);
16
+ coordinates[0] *= B;
17
+ return coordinates;
18
+ };
19
+
20
+ return forward;
21
+ }
22
+
23
+ function hammerProjection() {
24
+ var B = 2,
25
+ m = projectionMutator(hammer),
26
+ p = m(B);
27
+
28
+ p.coefficient = function(_) {
29
+ if (!arguments.length) return B;
30
+ return m(B = +_);
31
+ };
32
+
33
+ return p;
34
+ }
35
+
36
+ function hammerQuarticAuthalic(λ, φ) {
37
+ return [
38
+ λ * Math.cos(φ) / Math.cos(φ /= 2),
39
+ 2 * Math.sin(φ)
40
+ ];
41
+ }
42
+
43
+ hammerQuarticAuthalic.invert = function(x, y) {
44
+ var φ = 2 * asin(y / 2);
45
+ return [
46
+ x * Math.cos(φ / 2) / Math.cos(φ),
47
+ φ
48
+ ];
49
+ };
50
+
51
+ (d3.geo.hammer = hammerProjection).raw = hammer;
@@ -0,0 +1,25 @@
1
+ function hatano(λ, φ) {
2
+ var c = Math.sin(φ) * (φ < 0 ? 2.43763 : 2.67595);
3
+ for (var i = 0, δ; i < 20; i++) {
4
+ φ -= δ = (φ + Math.sin(φ) - c) / (1 + Math.cos(φ));
5
+ if (Math.abs(δ) < ε) break;
6
+ }
7
+ return [
8
+ .85 * λ * Math.cos(φ *= .5),
9
+ Math.sin(φ) * (φ < 0 ? 1.93052 : 1.75859)
10
+ ];
11
+ }
12
+
13
+ hatano.invert = function(x, y) {
14
+ var θ = Math.abs(θ = y * (y < 0 ? .51799515156538134803 : .56863737426006061674)) > 1 - ε
15
+ ? θ > 0 ? π / 2 : -π / 2
16
+ : asin(θ);
17
+ return [
18
+ 1.17647058823529411764 * x / Math.cos(θ),
19
+ Math.abs(θ = ((θ += θ) + Math.sin(θ)) * (y < 0 ? .41023453108141924738 : .37369906014686373063)) > 1 - ε
20
+ ? θ > 0 ? π / 2 : -π / 2
21
+ : asin(θ)
22
+ ];
23
+ };
24
+
25
+ (d3.geo.hatano = function() { return projection(hatano); }).raw = hatano;
@@ -0,0 +1,64 @@
1
+ var healpixParallel = 41 + 48 / 36 + 37 / 3600; // TODO automate
2
+
3
+ function healpix(h) {
4
+ var lambert = d3.geo.cylindricalEqualArea.raw(0),
5
+ φ0 = healpixParallel * π / 180,
6
+ dx0 = lambert(π, 0)[0] - lambert(-π, 0)[0],
7
+ dx1 = d3.geo.collignon.raw(π, φ0)[0] - d3.geo.collignon.raw(-π, φ0)[0],
8
+ y0 = lambert(0, φ0)[1],
9
+ y1 = d3.geo.collignon.raw(0, φ0)[1],
10
+ dy1 = d3.geo.collignon.raw(0, π / 2)[1] - y1,
11
+ k = 2 * π / h;
12
+
13
+ return function(λ, φ) {
14
+ var point;
15
+ if (Math.abs(φ) > φ0) {
16
+ var i = Math.min(h - 1, Math.max(0, Math.floor((λ + π) / k)));
17
+ λ = λ + π * (h - 1) / h - i * k;
18
+ point = d3.geo.collignon.raw(λ, Math.abs(φ));
19
+ point[0] = point[0] * dx0 / dx1 - dx0 * (h - 1) / (2 * h) + i * dx0 / h;
20
+ point[1] = y0 + (point[1] - y1) * 4 * dy1 / dx0;
21
+ if (φ < 0) point[1] = -point[1];
22
+ } else {
23
+ point = lambert(λ, φ);
24
+ }
25
+ point[0] /= 2;
26
+ return point;
27
+ };
28
+ }
29
+
30
+ function healpixProjection() {
31
+ var n = 2,
32
+ m = projectionMutator(healpix),
33
+ p = m(n),
34
+ stream_ = p.stream;
35
+
36
+ p.lobes = function(_) {
37
+ if (!arguments.length) return n;
38
+ return m(n = +_);
39
+ };
40
+
41
+ p.stream = function(stream) {
42
+ var rotate = p.rotate(),
43
+ rotateStream = stream_(stream),
44
+ sphereStream = (p.rotate([0, 0]), stream_(stream));
45
+ p.rotate(rotate);
46
+ rotateStream.sphere = function() { d3.geo.stream(sphere(), sphereStream); };
47
+ return rotateStream;
48
+ };
49
+
50
+ function sphere() {
51
+ var step = 180 / n;
52
+ return {
53
+ type: "Polygon",
54
+ coordinates: [
55
+ d3.range(-180, 180 + step / 2, step).map(function(x, i) { return [x, i & 1 ? 90 - 1e-6 : healpixParallel]; })
56
+ .concat(d3.range(180, -180 - step / 2, -step).map(function(x, i) { return [x, i & 1 ? -90 + 1e-6 : -healpixParallel]; }))
57
+ ]
58
+ };
59
+ }
60
+
61
+ return p;
62
+ }
63
+
64
+ (d3.geo.healpix = healpixProjection).raw = healpix;
@@ -0,0 +1,64 @@
1
+ function hill(K) {
2
+ var L = 1 + K,
3
+ sinβ = Math.sin(1 / L),
4
+ β = asin(sinβ),
5
+ A = 2 * Math.sqrt(π / (B = π + 4 * β * L)),
6
+ B,
7
+ ρ0 = .5 * A * (L + Math.sqrt(K * (2 + K))),
8
+ K2 = K * K,
9
+ L2 = L * L;
10
+
11
+ function forward(λ, φ) {
12
+ var t = 1 - Math.sin(φ),
13
+ ρ,
14
+ ω;
15
+ if (t && t < 2) {
16
+ var θ = π / 2 - φ, i = 25, δ;
17
+ do {
18
+ var sinθ = Math.sin(θ),
19
+ cosθ = Math.cos(θ),
20
+ β_β1 = β + Math.atan2(sinθ, L - cosθ),
21
+ C = 1 + L2 - 2 * L * cosθ;
22
+ θ -= δ = (θ - K2 * β - L * sinθ + C * β_β1 - .5 * t * B) / (2 * L * sinθ * β_β1);
23
+ } while (Math.abs(δ) > ε2 && --i > 0);
24
+ ρ = A * Math.sqrt(C);
25
+ ω = λ * β_β1 / π;
26
+ } else {
27
+ ρ = A * (K + t);
28
+ ω = λ * β / π;
29
+ }
30
+ return [
31
+ ρ * Math.sin(ω),
32
+ ρ0 - ρ * Math.cos(ω)
33
+ ];
34
+ };
35
+
36
+ forward.invert = function(x, y) {
37
+ var ρ2 = x * x + (y -= ρ0) * y,
38
+ cosθ = (1 + L2 - ρ2 / (A * A)) / (2 * L),
39
+ θ = acos(cosθ),
40
+ sinθ = Math.sin(θ),
41
+ β_β1 = β + Math.atan2(sinθ, L - cosθ);
42
+ return [
43
+ asin(x / Math.sqrt(ρ2)) * π / β_β1,
44
+ asin(1 - 2 * (θ - K2 * β - L * sinθ + (1 + L2 - 2 * L * cosθ) * β_β1) / B)
45
+ ];
46
+ };
47
+
48
+ return forward;
49
+ }
50
+
51
+ function hillProjection() {
52
+ var K = 1,
53
+ m = projectionMutator(hill),
54
+ p = m(K);
55
+
56
+ p.ratio = function(_) {
57
+ if (!arguments.length) return K;
58
+ return m(K = +_);
59
+ };
60
+
61
+ return p;
62
+ }
63
+
64
+ (d3.geo.hill = hillProjection).raw = hill;
@@ -0,0 +1,17 @@
1
+ // @import mollweide
2
+ // @import sinusoidal
3
+ // @import sinu-mollweide
4
+
5
+ function homolosine(λ, φ) {
6
+ return Math.abs(φ) > sinuMollweideφ
7
+ ? (λ = mollweide(λ, φ), λ[1] -= φ > 0 ? sinuMollweideY : -sinuMollweideY, λ)
8
+ : sinusoidal(λ, φ);
9
+ }
10
+
11
+ homolosine.invert = function(x, y) {
12
+ return Math.abs(y) > sinuMollweideφ
13
+ ? mollweide.invert(x, y + (y > 0 ? sinuMollweideY : -sinuMollweideY))
14
+ : sinusoidal.invert(x, y);
15
+ };
16
+
17
+ (d3.geo.homolosine = function() { return projection(homolosine); }).raw = homolosine;
@@ -0,0 +1,111 @@
1
+ d3.geo.interrupt = function(project) {
2
+ var lobes = [
3
+ [[[-π, 0], [0, π / 2], [π, 0]]],
4
+ [[[-π, 0], [0, -π / 2], [π, 0]]]
5
+ ];
6
+
7
+ var projection = d3.geo.projection(function(λ, φ) {
8
+ var sign = φ < 0 ? -1 : +1,
9
+ hemilobes = lobes[+(φ < 0)];
10
+ for (var i = 0, n = hemilobes.length - 1; i < n && λ > hemilobes[i][2][0]; ++i);
11
+ var coordinates = project(λ - hemilobes[i][1][0], φ);
12
+ coordinates[0] += project(hemilobes[i][1][0], sign * φ > sign * hemilobes[i][0][1] ? hemilobes[i][0][1] : φ)[0];
13
+ return coordinates;
14
+ });
15
+
16
+ var stream_ = projection.stream;
17
+
18
+ projection.stream = function(stream) {
19
+ var rotate = projection.rotate(),
20
+ rotateStream = stream_(stream),
21
+ sphereStream = (projection.rotate([0, 0]), stream_(stream));
22
+ projection.rotate(rotate);
23
+ rotateStream.sphere = function() { d3.geo.stream(sphere(), sphereStream); };
24
+ return rotateStream;
25
+ };
26
+
27
+ projection.lobes = function(_) {
28
+ if (!arguments.length) return lobes.map(function(lobes) {
29
+ return lobes.map(function(lobe) {
30
+ return [
31
+ [lobe[0][0] * 180 / π, lobe[0][1] * 180 / π],
32
+ [lobe[1][0] * 180 / π, lobe[1][1] * 180 / π],
33
+ [lobe[2][0] * 180 / π, lobe[2][1] * 180 / π],
34
+ ];
35
+ });
36
+ });
37
+ lobes = _.map(function(lobes) {
38
+ return lobes.map(function(lobe) {
39
+ return [
40
+ [lobe[0][0] * π / 180, lobe[0][1] * π / 180],
41
+ [lobe[1][0] * π / 180, lobe[1][1] * π / 180],
42
+ [lobe[2][0] * π / 180, lobe[2][1] * π / 180]
43
+ ];
44
+ });
45
+ });
46
+ return projection;
47
+ };
48
+
49
+ function sphere() {
50
+ var ε = 1e-6,
51
+ coordinates = [];
52
+
53
+ // Northern Hemisphere
54
+ for (var i = 0, n = lobes[0].length; i < n; ++i) {
55
+ var lobe = lobes[0][i],
56
+ λ0 = lobe[0][0] * 180 / π,
57
+ φ0 = lobe[0][1] * 180 / π,
58
+ φ1 = lobe[1][1] * 180 / π,
59
+ λ2 = lobe[2][0] * 180 / π,
60
+ φ2 = lobe[2][1] * 180 / π;
61
+ coordinates.push(resample([
62
+ [λ0 + ε, φ0 + ε],
63
+ [λ0 + ε, φ1 - ε],
64
+ [λ2 - ε, φ1 - ε],
65
+ [λ2 - ε, φ2 + ε]
66
+ ], 30));
67
+ }
68
+
69
+ // Southern Hemisphere
70
+ for (var i = lobes[1].length - 1; i >= 0; --i) {
71
+ var lobe = lobes[1][i],
72
+ λ0 = lobe[0][0] * 180 / π,
73
+ φ0 = lobe[0][1] * 180 / π,
74
+ φ1 = lobe[1][1] * 180 / π,
75
+ λ2 = lobe[2][0] * 180 / π,
76
+ φ2 = lobe[2][1] * 180 / π;
77
+ coordinates.push(resample([
78
+ [λ2 - ε, φ2 - ε],
79
+ [λ2 - ε, φ1 + ε],
80
+ [λ0 + ε, φ1 + ε],
81
+ [λ0 + ε, φ0 - ε]
82
+ ], 30));
83
+ }
84
+
85
+ return {
86
+ type: "Polygon",
87
+ coordinates: [d3.merge(coordinates)]
88
+ };
89
+ }
90
+
91
+ function resample(coordinates, m) {
92
+ var i = -1,
93
+ n = coordinates.length,
94
+ p0 = coordinates[0],
95
+ p1,
96
+ dx,
97
+ dy,
98
+ resampled = [];
99
+ while (++i < n) {
100
+ p1 = coordinates[i];
101
+ dx = (p1[0] - p0[0]) / m;
102
+ dy = (p1[1] - p0[1]) / m;
103
+ for (var j = 0; j < m; ++j) resampled.push([p0[0] + j * dx, p0[1] + j * dy]);
104
+ p0 = p1;
105
+ }
106
+ resampled.push(p1);
107
+ return resampled;
108
+ }
109
+
110
+ return projection;
111
+ };
@@ -0,0 +1,15 @@
1
+ function kavrayskiy7(λ, φ) {
2
+ return [
3
+ 3 * λ / (2 * π) * Math.sqrt(π * π / 3 - φ * φ),
4
+ φ
5
+ ];
6
+ }
7
+
8
+ kavrayskiy7.invert = function(x, y) {
9
+ return [
10
+ 2 / 3 * π * x / Math.sqrt(π * π / 3 - y * y),
11
+ y
12
+ ];
13
+ };
14
+
15
+ (d3.geo.kavrayskiy7 = function() { return projection(kavrayskiy7); }).raw = kavrayskiy7;
@@ -0,0 +1,27 @@
1
+ function lagrange(n) {
2
+ return function(λ, φ) {
3
+ if (Math.abs(Math.abs(φ) - π / 2) < ε) return [0, φ < 0 ? -2 : 2];
4
+ var sinφ = Math.sin(φ),
5
+ v = Math.pow((1 + sinφ) / (1 - sinφ), n / 2),
6
+ c = .5 * (v + 1 / v) + Math.cos(λ *= n);
7
+ return [
8
+ 2 * Math.sin(λ) / c,
9
+ (v - 1 / v) / c
10
+ ];
11
+ };
12
+ }
13
+
14
+ function lagrangeProjection() {
15
+ var n = .5,
16
+ m = projectionMutator(lagrange),
17
+ p = m(n);
18
+
19
+ p.spacing = function(_) {
20
+ if (!arguments.length) return n;
21
+ return m(n = +_);
22
+ };
23
+
24
+ return p;
25
+ }
26
+
27
+ (d3.geo.lagrange = lagrangeProjection).raw = lagrange;
@@ -0,0 +1,39 @@
1
+ function larrivee(λ, φ) {
2
+ return [
3
+ λ * (1 + Math.sqrt(Math.cos(φ))) / 2,
4
+ φ / (Math.cos(φ / 2) * Math.cos(λ / 6))
5
+ ];
6
+ }
7
+
8
+ larrivee.invert = function(x, y) {
9
+ var x0 = Math.abs(x),
10
+ y0 = Math.abs(y),
11
+ π_sqrt2 = π / Math.SQRT2,
12
+ λ = ε,
13
+ φ = π / 2;
14
+ if (y0 < π_sqrt2) φ *= y0 / π_sqrt2;
15
+ else λ += 6 * acos(π_sqrt2 / y0);
16
+ for (var i = 0; i < 25; i++) {
17
+ var sinφ = Math.sin(φ),
18
+ sqrtcosφ = asqrt(Math.cos(φ)),
19
+ sinφ_2 = Math.sin(φ / 2),
20
+ cosφ_2 = Math.cos(φ / 2),
21
+ sinλ_6 = Math.sin(λ / 6),
22
+ cosλ_6 = Math.cos(λ / 6),
23
+ f0 = .5 * λ * (1 + sqrtcosφ) - x0,
24
+ f1 = φ / (cosφ_2 * cosλ_6) - y0,
25
+ df0dφ = sqrtcosφ ? -.25 * λ * sinφ / sqrtcosφ : 0,
26
+ df0dλ = .5 * (1 + sqrtcosφ),
27
+ df1dφ = (1 + .5 * φ * sinφ_2 / cosφ_2) / (cosφ_2 * cosλ_6),
28
+ df1dλ = (φ / cosφ_2) * (sinλ_6 / 6) / (cosλ_6 * cosλ_6),
29
+ denom = df0dφ * df1dλ - df1dφ * df0dλ,
30
+ dφ = (f0 * df1dλ - f1 * df0dλ) / denom,
31
+ dλ = (f1 * df0dφ - f0 * df1dφ) / denom;
32
+ φ -= dφ;
33
+ λ -= dλ;
34
+ if (Math.abs(dφ) < ε && Math.abs(dλ) < ε) break;
35
+ }
36
+ return [x < 0 ? -λ : λ, y < 0 ? -φ : φ];
37
+ };
38
+
39
+ (d3.geo.larrivee = function() { return projection(larrivee); }).raw = larrivee;
@@ -0,0 +1,31 @@
1
+ function laskowski(λ, φ) {
2
+ var λ2 = λ * λ, φ2 = φ * φ;
3
+ return [
4
+ λ * (.975534 + φ2 * (-.119161 + λ2 * -.0143059 + φ2 * -.0547009)),
5
+ φ * (1.00384 + λ2 * (.0802894 + φ2 * -.02855 + λ2 * .000199025) + φ2 * (.0998909 + φ2 * -.0491032))
6
+ ];
7
+ }
8
+
9
+ laskowski.invert = function(x, y) {
10
+ var λ = x,
11
+ φ = y,
12
+ i = 50;
13
+ do {
14
+ var λ2 = λ * λ,
15
+ φ2 = φ * φ,
16
+ λφ = λ * φ,
17
+ fx = λ * (.975534 + φ2 * (-.119161 + λ2 * -.0143059 + φ2 * -.0547009)) - x,
18
+ fy = φ * (1.00384 + λ2 * (.0802894 + φ2 * -.02855 + λ2 * .000199025) + φ2 * (.0998909 + φ2 * -.0491032)) - y,
19
+ δxδλ = .975534 - φ2 * (.119161 + 3 * λ2 * .0143059 + φ2 * .0547009),
20
+ δxδφ = -λφ * (2 * .119161 + 4 * .0547009 * φ2 + 2 * .0143059 * λ2),
21
+ δyδλ = λφ * (2 * .0802894 + 4 * .000199025 * λ2 + 2 * -.02855 * φ2),
22
+ δyδφ = 1.00384 + λ2 * (.0802894 + .000199025 * λ2) + φ2 * (3 * (.0998909 - .02855 * λ2) - 5 * .0491032 * φ2),
23
+ denominator = δxδφ * δyδλ - δyδφ * δxδλ,
24
+ δλ = (fy * δxδφ - fx * δyδφ) / denominator,
25
+ δφ = (fx * δyδλ - fy * δxδλ) / denominator;
26
+ λ -= δλ, φ -= δφ;
27
+ } while ((Math.abs(δλ) > ε || Math.abs(δφ) > ε) && --i > 0);
28
+ return [λ, φ];
29
+ };
30
+
31
+ (d3.geo.laskowski = function() { return projection(laskowski); }).raw = laskowski;