d3js-plugins-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/d3js-plugins-rails.gemspec +21 -0
- data/lib/d3js-plugins-rails/version.rb +7 -0
- data/lib/d3js-plugins-rails.rb +10 -0
- data/vendor/assets/javascripts/d3/plugins/.gitignore +1 -0
- data/vendor/assets/javascripts/d3/plugins/LICENSE +26 -0
- data/vendor/assets/javascripts/d3/plugins/Makefile +87 -0
- data/vendor/assets/javascripts/d3/plugins/README.md +19 -0
- data/vendor/assets/javascripts/d3/plugins/box/box.js +301 -0
- data/vendor/assets/javascripts/d3/plugins/bullet/README.md +14 -0
- data/vendor/assets/javascripts/d3/plugins/bullet/bullet.js +241 -0
- data/vendor/assets/javascripts/d3/plugins/chernoff/README.md +15 -0
- data/vendor/assets/javascripts/d3/plugins/chernoff/chernoff.js +176 -0
- data/vendor/assets/javascripts/d3/plugins/cie/README.md +54 -0
- data/vendor/assets/javascripts/d3/plugins/cie/cie.js +155 -0
- data/vendor/assets/javascripts/d3/plugins/fisheye/README.md +43 -0
- data/vendor/assets/javascripts/d3/plugins/fisheye/fisheye.js +85 -0
- data/vendor/assets/javascripts/d3/plugins/force_labels/README.md +29 -0
- data/vendor/assets/javascripts/d3/plugins/force_labels/force_labels.js +56 -0
- data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/README.md +7 -0
- data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/polyhedron.js +436 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/README.md +107 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/aitoff.js +40 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/armadillo.js +79 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/august.js +15 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/baker.js +28 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/berghaus.js +60 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/boggs.js +27 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/bonne.js +29 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/bromley.js +5 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/collignon.js +17 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js +29 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js +27 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/craig.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/craster.js +18 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/cylindrical-equal-area.js +23 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert1.js +18 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert2.js +17 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert3.js +17 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert4.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert5.js +17 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert6.js +22 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eisenlohr.js +16 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/end.js +1 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/gringorten.js +111 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/guyou.js +46 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer-retroazimuthal.js +75 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer.js +51 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/hatano.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/healpix.js +64 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/hill.js +64 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/homolosine.js +17 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/interrupt.js +111 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/kavrayskiy7.js +15 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/lagrange.js +27 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/larrivee.js +39 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/laskowski.js +31 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/littrow.js +21 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/loximuthal.js +29 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/miller.js +15 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/mollweide.js +35 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-parabolic.js +21 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-quartic.js +23 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-sinusoidal.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/natural-earth.js +22 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/nell-hammer.js +20 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel1.js +12 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel2.js +13 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/peirce-quincuncial.js +14 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/polyconic.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/projection.js +29 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/robinson.js +83 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/satellite.js +68 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/sinu-mollweide.js +19 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/sinusoidal.js +15 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/start.js +1 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/aitoff-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/armadillo-test.js +28 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/baker-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/boggs-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/bonne-test.js +45 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craig-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craster-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/env.js +32 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/equirectangular-test.js +97 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hammer-test.js +29 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hatano-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hill-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/larrivee-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/laskowski-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/littrow-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/loximuthal-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mollweide-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-parabolic-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-quartic-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-sinusoidal-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/natural-earth-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/quartic-authalic-test.js +0 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/robinson-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/wagner6-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/winkel3-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten.js +41 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten4.js +22 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner4.js +9 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner6.js +15 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner7.js +22 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/wiechel.js +14 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/winkel3.js +40 -0
- data/vendor/assets/javascripts/d3/plugins/geo/tile/README.md +6 -0
- data/vendor/assets/javascripts/d3/plugins/geo/tile/tile.js +53 -0
- data/vendor/assets/javascripts/d3/plugins/geodesic/README.md +3 -0
- data/vendor/assets/javascripts/d3/plugins/geodesic/geodesic.js +130 -0
- data/vendor/assets/javascripts/d3/plugins/geom/contour/README.md +5 -0
- data/vendor/assets/javascripts/d3/plugins/geom/contour/contour.js +72 -0
- data/vendor/assets/javascripts/d3/plugins/graph/README.md +148 -0
- data/vendor/assets/javascripts/d3/plugins/graph/data/cities-matrix.json +37 -0
- data/vendor/assets/javascripts/d3/plugins/graph/data/cities.csv +36 -0
- data/vendor/assets/javascripts/d3/plugins/graph/data/miserables.json +338 -0
- data/vendor/assets/javascripts/d3/plugins/graph/graph.js +161 -0
- data/vendor/assets/javascripts/d3/plugins/graph/index.html +37 -0
- data/vendor/assets/javascripts/d3/plugins/hexbin/README.md +58 -0
- data/vendor/assets/javascripts/d3/plugins/hexbin/hexbin.js +96 -0
- data/vendor/assets/javascripts/d3/plugins/hive/README.md +5 -0
- data/vendor/assets/javascripts/d3/plugins/hive/hive.js +80 -0
- data/vendor/assets/javascripts/d3/plugins/horizon/README.md +11 -0
- data/vendor/assets/javascripts/d3/plugins/horizon/horizon.js +192 -0
- data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/README.md +11 -0
- data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/interpolate-zoom.js +75 -0
- data/vendor/assets/javascripts/d3/plugins/jsonp/README.md +26 -0
- data/vendor/assets/javascripts/d3/plugins/jsonp/jsonp.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/keybinding/README.md +17 -0
- data/vendor/assets/javascripts/d3/plugins/keybinding/keybinding.js +120 -0
- data/vendor/assets/javascripts/d3/plugins/longscroll/README.md +10 -0
- data/vendor/assets/javascripts/d3/plugins/longscroll/longscroll.js +75 -0
- data/vendor/assets/javascripts/d3/plugins/package.json +20 -0
- data/vendor/assets/javascripts/d3/plugins/qq/README.md +3 -0
- data/vendor/assets/javascripts/d3/plugins/qq/qq.js +249 -0
- data/vendor/assets/javascripts/d3/plugins/rollup/README.md +5 -0
- data/vendor/assets/javascripts/d3/plugins/rollup/rollup.js +131 -0
- data/vendor/assets/javascripts/d3/plugins/sankey/README.md +17 -0
- data/vendor/assets/javascripts/d3/plugins/sankey/sankey.js +292 -0
- data/vendor/assets/javascripts/d3/plugins/simplify/README.md +6 -0
- data/vendor/assets/javascripts/d3/plugins/simplify/simplify-test.js +193 -0
- data/vendor/assets/javascripts/d3/plugins/simplify/simplify.js +446 -0
- data/vendor/assets/javascripts/d3/plugins/superformula/superformula.js +98 -0
- data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode-test.js +68 -0
- data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode.js +37 -0
- metadata +218 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
function littrow(λ, φ) {
|
2
|
+
return [
|
3
|
+
Math.sin(λ) / Math.cos(φ),
|
4
|
+
Math.tan(φ) * Math.cos(λ)
|
5
|
+
];
|
6
|
+
}
|
7
|
+
|
8
|
+
littrow.invert = function(x, y) {
|
9
|
+
var x2 = x * x,
|
10
|
+
y2 = y * y,
|
11
|
+
y2_1 = y2 + 1,
|
12
|
+
cosφ = x
|
13
|
+
? Math.SQRT1_2 * Math.sqrt((y2_1 - Math.sqrt(x2 * x2 + 2 * x2 * (y2 - 1) + y2_1 * y2_1)) / x2 + 1)
|
14
|
+
: 1 / Math.sqrt(y2_1);
|
15
|
+
return [
|
16
|
+
asin(x * cosφ),
|
17
|
+
sgn(y) * acos(cosφ)
|
18
|
+
];
|
19
|
+
};
|
20
|
+
|
21
|
+
(d3.geo.littrow = function() { return projection(littrow); }).raw = littrow;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// @import parallel1
|
2
|
+
|
3
|
+
function loximuthal(φ0) {
|
4
|
+
var cosφ0 = Math.cos(φ0),
|
5
|
+
tanφ0 = Math.tan(π / 4 + φ0 / 2);
|
6
|
+
|
7
|
+
function forward(λ, φ) {
|
8
|
+
var y = φ - φ0,
|
9
|
+
x = Math.abs(y) < ε ? λ * cosφ0
|
10
|
+
: Math.abs(x = π / 4 + φ / 2) < ε || Math.abs(Math.abs(x) - π / 2) < ε
|
11
|
+
? 0 : λ * y / Math.log(Math.tan(x) / tanφ0);
|
12
|
+
return [x, y];
|
13
|
+
}
|
14
|
+
|
15
|
+
forward.invert = function(x, y) {
|
16
|
+
var λ,
|
17
|
+
φ = y + φ0;
|
18
|
+
return [
|
19
|
+
Math.abs(y) < ε ? x / cosφ0
|
20
|
+
: (Math.abs(λ = π / 4 + φ / 2) < ε || Math.abs(Math.abs(λ) - π / 2) < ε) ? 0
|
21
|
+
: x * Math.log(Math.tan(λ) / tanφ0) / y,
|
22
|
+
φ
|
23
|
+
];
|
24
|
+
};
|
25
|
+
|
26
|
+
return forward;
|
27
|
+
}
|
28
|
+
|
29
|
+
(d3.geo.loximuthal = function() { return parallel1Projection(loximuthal).parallel(40); }).raw = loximuthal;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function miller(λ, φ) {
|
2
|
+
return [
|
3
|
+
λ,
|
4
|
+
1.25 * Math.log(Math.tan(π / 4 + .4 * φ))
|
5
|
+
];
|
6
|
+
}
|
7
|
+
|
8
|
+
miller.invert = function(x, y) {
|
9
|
+
return [
|
10
|
+
x,
|
11
|
+
2.5 * Math.atan(Math.exp(.8 * y)) - .625 * π
|
12
|
+
];
|
13
|
+
};
|
14
|
+
|
15
|
+
(d3.geo.miller = function() { return projection(miller); }).raw = miller;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
function mollweideBromleyθ(Cp) {
|
2
|
+
return function(θ) {
|
3
|
+
var Cpsinθ = Cp * Math.sin(θ),
|
4
|
+
i = 30, δ;
|
5
|
+
do θ -= δ = (θ + Math.sin(θ) - Cpsinθ) / (1 + Math.cos(θ));
|
6
|
+
while (Math.abs(δ) > ε && --i > 0);
|
7
|
+
return θ / 2;
|
8
|
+
};
|
9
|
+
}
|
10
|
+
|
11
|
+
function mollweideBromley(Cx, Cy, Cp) {
|
12
|
+
var θ = mollweideBromleyθ(Cp);
|
13
|
+
|
14
|
+
function forward(λ, φ) {
|
15
|
+
return [
|
16
|
+
Cx * λ * Math.cos(φ = θ(φ)),
|
17
|
+
Cy * Math.sin(φ)
|
18
|
+
];
|
19
|
+
}
|
20
|
+
|
21
|
+
forward.invert = function(x, y) {
|
22
|
+
var θ = asin(y / Cy);
|
23
|
+
return [
|
24
|
+
x / (Cx * Math.cos(θ)),
|
25
|
+
asin((2 * θ + Math.sin(2 * θ)) / Cp)
|
26
|
+
];
|
27
|
+
};
|
28
|
+
|
29
|
+
return forward;
|
30
|
+
}
|
31
|
+
|
32
|
+
var mollweideθ = mollweideBromleyθ(π),
|
33
|
+
mollweide = mollweideBromley(2 * Math.SQRT2 / π, Math.SQRT2, π);
|
34
|
+
|
35
|
+
(d3.geo.mollweide = function() { return projection(mollweide); }).raw = mollweide;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
function mtFlatPolarParabolic(λ, φ) {
|
2
|
+
var sqrt6 = Math.sqrt(6),
|
3
|
+
sqrt7 = Math.sqrt(7),
|
4
|
+
θ = Math.asin(7 * Math.sin(φ) / (3 * sqrt6));
|
5
|
+
return [
|
6
|
+
sqrt6 * λ * (2 * Math.cos(2 * θ / 3) - 1) / sqrt7,
|
7
|
+
9 * Math.sin(θ / 3) / sqrt7
|
8
|
+
];
|
9
|
+
}
|
10
|
+
|
11
|
+
mtFlatPolarParabolic.invert = function(x, y) {
|
12
|
+
var sqrt6 = Math.sqrt(6),
|
13
|
+
sqrt7 = Math.sqrt(7),
|
14
|
+
θ = 3 * asin(y * sqrt7 / 9);
|
15
|
+
return [
|
16
|
+
x * sqrt7 / (sqrt6 * (2 * Math.cos(2 * θ / 3) - 1)),
|
17
|
+
asin(Math.sin(θ) * 3 * sqrt6 / 7)
|
18
|
+
];
|
19
|
+
};
|
20
|
+
|
21
|
+
(d3.geo.mtFlatPolarParabolic = function() { return projection(mtFlatPolarParabolic); }).raw = mtFlatPolarParabolic;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
function mtFlatPolarQuartic(λ, φ) {
|
2
|
+
var k = (1 + Math.SQRT1_2) * Math.sin(φ),
|
3
|
+
θ = φ;
|
4
|
+
for (var i = 0, δ; i < 25; i++) {
|
5
|
+
θ -= δ = (Math.sin(θ / 2) + Math.sin(θ) - k) / (.5 * Math.cos(θ / 2) + Math.cos(θ));
|
6
|
+
if (Math.abs(δ) < ε) break;
|
7
|
+
}
|
8
|
+
return [
|
9
|
+
λ * (1 + 2 * Math.cos(θ) / Math.cos(θ / 2)) / (3 * Math.SQRT2),
|
10
|
+
2 * Math.sqrt(3) * Math.sin(θ / 2) / Math.sqrt(2 + Math.SQRT2)
|
11
|
+
];
|
12
|
+
}
|
13
|
+
|
14
|
+
mtFlatPolarQuartic.invert = function(x, y) {
|
15
|
+
var sinθ_2 = y * Math.sqrt(2 + Math.SQRT2) / (2 * Math.sqrt(3)),
|
16
|
+
θ = 2 * asin(sinθ_2);
|
17
|
+
return [
|
18
|
+
3 * Math.SQRT2 * x / (1 + 2 * Math.cos(θ) / Math.cos(θ / 2)),
|
19
|
+
asin((sinθ_2 + Math.sin(θ)) / (1 + Math.SQRT1_2))
|
20
|
+
];
|
21
|
+
};
|
22
|
+
|
23
|
+
(d3.geo.mtFlatPolarQuartic = function() { return projection(mtFlatPolarQuartic); }).raw = mtFlatPolarQuartic;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
function mtFlatPolarSinusoidal(λ, φ) {
|
2
|
+
var A = Math.sqrt(6 / (4 + π)),
|
3
|
+
k = (1 + π / 4) * Math.sin(φ),
|
4
|
+
θ = φ / 2;
|
5
|
+
for (var i = 0, δ; i < 25; i++) {
|
6
|
+
θ -= δ = (θ / 2 + Math.sin(θ) - k) / (.5 + Math.cos(θ));
|
7
|
+
if (Math.abs(δ) < ε) break;
|
8
|
+
}
|
9
|
+
return [
|
10
|
+
A * (.5 + Math.cos(θ)) * λ / 1.5,
|
11
|
+
A * θ
|
12
|
+
];
|
13
|
+
}
|
14
|
+
|
15
|
+
mtFlatPolarSinusoidal.invert = function(x, y) {
|
16
|
+
var A = Math.sqrt(6 / (4 + π)),
|
17
|
+
θ = y / A;
|
18
|
+
if (Math.abs(Math.abs(θ) - π / 2) < ε) θ = θ < 0 ? -π / 2 : π / 2;
|
19
|
+
return [
|
20
|
+
1.5 * x / (A * (.5 + Math.cos(θ))),
|
21
|
+
asin((θ / 2 + Math.sin(θ)) / (1 + π / 4))
|
22
|
+
];
|
23
|
+
};
|
24
|
+
|
25
|
+
(d3.geo.mtFlatPolarSinusoidal = function() { return projection(mtFlatPolarSinusoidal); }).raw = mtFlatPolarSinusoidal;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
function naturalEarth(λ, φ) {
|
2
|
+
var φ2 = φ * φ, φ4 = φ2 * φ2;
|
3
|
+
return [
|
4
|
+
λ * (.8707 - .131979 * φ2 + φ4 * (-.013791 + φ4 * (.003971 * φ2 - .001529 * φ4))),
|
5
|
+
φ * (1.007226 + φ2 * (.015085 + φ4 * (-.044475 + .028874 * φ2 - .005916 * φ4)))
|
6
|
+
];
|
7
|
+
}
|
8
|
+
|
9
|
+
naturalEarth.invert = function(x, y) {
|
10
|
+
var φ = y, i = 25, δ;
|
11
|
+
do {
|
12
|
+
var φ2 = φ * φ, φ4 = φ2 * φ2;
|
13
|
+
φ -= δ = (φ * (1.007226 + φ2 * (.015085 + φ4 * (-.044475 + .028874 * φ2 - .005916 * φ4))) - y) /
|
14
|
+
(1.007226 + φ2 * (.015085 * 3 + φ4 * (-.044475 * 7 + .028874 * 9 * φ2 - .005916 * 11 * φ4)));
|
15
|
+
} while (Math.abs(δ) > ε && --i > 0);
|
16
|
+
return [
|
17
|
+
x / (.8707 + (φ2 = φ * φ) * (-.131979 + φ2 * (-.013791 + φ2 * φ2 * φ2 * (.003971 - .001529 * φ2)))),
|
18
|
+
φ
|
19
|
+
];
|
20
|
+
};
|
21
|
+
|
22
|
+
(d3.geo.naturalEarth = function() { return projection(naturalEarth); }).raw = naturalEarth;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
function nellHammer(λ, φ) {
|
2
|
+
return [
|
3
|
+
λ * (1 + Math.cos(φ)) / 2,
|
4
|
+
2 * (φ - Math.tan(φ / 2))
|
5
|
+
];
|
6
|
+
}
|
7
|
+
|
8
|
+
nellHammer.invert = function(x, y) {
|
9
|
+
var p = y / 2;
|
10
|
+
for (var i = 0, δ = Infinity; i < 10 && Math.abs(δ) > ε; i++) {
|
11
|
+
var c = Math.cos(y / 2);
|
12
|
+
y -= δ = (y - Math.tan(y / 2) - p) / (1 - .5 / (c * c));
|
13
|
+
}
|
14
|
+
return [
|
15
|
+
2 * x / (1 + Math.cos(y)),
|
16
|
+
y
|
17
|
+
];
|
18
|
+
};
|
19
|
+
|
20
|
+
(d3.geo.nellHammer = function() { return projection(nellHammer); }).raw = nellHammer;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
function parallel2Projection(projectAt) {
|
2
|
+
var φ0 = 0,
|
3
|
+
φ1 = π / 3,
|
4
|
+
m = projectionMutator(projectAt),
|
5
|
+
p = m(φ0, φ1);
|
6
|
+
|
7
|
+
p.parallels = function(_) {
|
8
|
+
if (!arguments.length) return [φ0 / π * 180, φ1 / π * 180];
|
9
|
+
return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);
|
10
|
+
};
|
11
|
+
|
12
|
+
return p;
|
13
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// @import guyou
|
2
|
+
|
3
|
+
function peirceQuincuncial(λ, φ) {
|
4
|
+
var t = Math.abs(λ) < π / 2,
|
5
|
+
p = guyou(t ? λ : -sgn(λ) * (π - Math.abs(λ)), φ),
|
6
|
+
x = p[0] / Math.SQRT2 - p[1] / Math.SQRT2,
|
7
|
+
y = p[1] / Math.SQRT2 + p[0] / Math.SQRT2;
|
8
|
+
if (t) return [x, y];
|
9
|
+
var d = 2 * 1.311028777082283, // TODO unobfuscate
|
10
|
+
s = (x > 0) ^ (y > 0) ? -1 : 1;
|
11
|
+
return [s * x - sgn(y) * d, s * y - sgn(x) * d];
|
12
|
+
}
|
13
|
+
|
14
|
+
(d3.geo.peirceQuincuncial = function() { return projection(peirceQuincuncial).rotate([-90, -90, 45]).clipAngle(180 - 1e-6); }).raw = peirceQuincuncial;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
function polyconic(λ, φ) {
|
2
|
+
if (Math.abs(φ) < ε) return [λ, 0];
|
3
|
+
var tanφ = Math.tan(φ),
|
4
|
+
k = λ * Math.sin(φ);
|
5
|
+
return [
|
6
|
+
Math.sin(k) / tanφ,
|
7
|
+
φ + (1 - Math.cos(k)) / tanφ
|
8
|
+
];
|
9
|
+
}
|
10
|
+
|
11
|
+
polyconic.invert = function(x, y) {
|
12
|
+
if (Math.abs(y) < ε) return [x, 0];
|
13
|
+
var k = x * x + y * y,
|
14
|
+
φ = y;
|
15
|
+
for (var i = 0, δ = Infinity; i < 10 && Math.abs(δ) > ε; i++) {
|
16
|
+
var tanφ = Math.tan(φ);
|
17
|
+
φ -= δ = (y * (φ * tanφ + 1) - φ - .5 * (φ * φ + k) * tanφ) / ((φ - y) / tanφ - 1);
|
18
|
+
}
|
19
|
+
return [
|
20
|
+
asin(x * Math.tan(φ)) / Math.sin(φ),
|
21
|
+
φ
|
22
|
+
];
|
23
|
+
};
|
24
|
+
|
25
|
+
(d3.geo.polyconic = function() { return projection(polyconic); }).raw = polyconic;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
var ε = 1e-6,
|
2
|
+
ε2 = ε * ε,
|
3
|
+
π = Math.PI,
|
4
|
+
sqrtπ = Math.sqrt(π),
|
5
|
+
radians = π / 180,
|
6
|
+
degrees = 180 / π;
|
7
|
+
|
8
|
+
var projection = d3.geo.projection,
|
9
|
+
projectionMutator = d3.geo.projectionMutator;
|
10
|
+
|
11
|
+
function sinci(x) {
|
12
|
+
return x ? x / Math.sin(x) : 1;
|
13
|
+
}
|
14
|
+
|
15
|
+
function sgn(x) {
|
16
|
+
return x > 0 ? 1 : x < 0 ? -1 : 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
function asqrt(x) {
|
20
|
+
return x > 0 ? Math.sqrt(x) : 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
function asin(x) {
|
24
|
+
return x > 1 ? π / 2 : x < -1 ? -π / 2 : Math.asin(x);
|
25
|
+
}
|
26
|
+
|
27
|
+
function acos(x) {
|
28
|
+
return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
|
29
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
var robinsonConstants = [
|
2
|
+
[0.9986, -0.062],
|
3
|
+
[1.0000, 0.0000],
|
4
|
+
[0.9986, 0.0620],
|
5
|
+
[0.9954, 0.1240],
|
6
|
+
[0.9900, 0.1860],
|
7
|
+
[0.9822, 0.2480],
|
8
|
+
[0.9730, 0.3100],
|
9
|
+
[0.9600, 0.3720],
|
10
|
+
[0.9427, 0.4340],
|
11
|
+
[0.9216, 0.4958],
|
12
|
+
[0.8962, 0.5571],
|
13
|
+
[0.8679, 0.6176],
|
14
|
+
[0.8350, 0.6769],
|
15
|
+
[0.7986, 0.7346],
|
16
|
+
[0.7597, 0.7903],
|
17
|
+
[0.7186, 0.8435],
|
18
|
+
[0.6732, 0.8936],
|
19
|
+
[0.6213, 0.9394],
|
20
|
+
[0.5722, 0.9761],
|
21
|
+
[0.5322, 1.0000]
|
22
|
+
];
|
23
|
+
|
24
|
+
robinsonConstants.forEach(function(d) {
|
25
|
+
d[1] *= 1.0144;
|
26
|
+
});
|
27
|
+
|
28
|
+
function robinson(λ, φ) {
|
29
|
+
var i = Math.min(18, Math.abs(φ) * 36 / π),
|
30
|
+
i0 = Math.floor(i),
|
31
|
+
di = i - i0,
|
32
|
+
ax = (k = robinsonConstants[i0])[0],
|
33
|
+
ay = k[1],
|
34
|
+
bx = (k = robinsonConstants[++i0])[0],
|
35
|
+
by = k[1],
|
36
|
+
cx = (k = robinsonConstants[Math.min(19, ++i0)])[0],
|
37
|
+
cy = k[1],
|
38
|
+
k;
|
39
|
+
return [
|
40
|
+
λ * (bx + di * (cx - ax) / 2 + di * di * (cx - 2 * bx + ax) / 2),
|
41
|
+
(φ > 0 ? π : -π) / 2 * (by + di * (cy - ay) / 2 + di * di * (cy - 2 * by + ay) / 2)
|
42
|
+
];
|
43
|
+
}
|
44
|
+
|
45
|
+
robinson.invert = function(x, y) {
|
46
|
+
var yy = 2 * y / π,
|
47
|
+
φ = yy * 90,
|
48
|
+
i = Math.min(18, Math.abs(φ / 5)),
|
49
|
+
i0 = Math.max(0, Math.floor(i));
|
50
|
+
do {
|
51
|
+
var ay = robinsonConstants[i0][1],
|
52
|
+
by = robinsonConstants[i0 + 1][1],
|
53
|
+
cy = robinsonConstants[Math.min(19, i0 + 2)][1],
|
54
|
+
u = cy - ay,
|
55
|
+
v = cy - 2 * by + ay,
|
56
|
+
t = 2 * (Math.abs(yy) - by) / u,
|
57
|
+
c = v / u,
|
58
|
+
di = t * (1 - c * t * (1 - 2 * c * t));
|
59
|
+
if (di >= 0 || i0 === 1) {
|
60
|
+
φ = (y >= 0 ? 5 : -5) * (di + i);
|
61
|
+
var j = 50, δ;
|
62
|
+
do {
|
63
|
+
i = Math.min(18, Math.abs(φ) / 5);
|
64
|
+
i0 = Math.floor(i);
|
65
|
+
di = i - i0;
|
66
|
+
ay = robinsonConstants[i0][1];
|
67
|
+
by = robinsonConstants[i0 + 1][1];
|
68
|
+
cy = robinsonConstants[Math.min(19, i0 + 2)][1];
|
69
|
+
φ -= (δ = (y >= 0 ? π : -π) / 2 * (by + di * (cy - ay) / 2 + di * di * (cy - 2 * by + ay) / 2) - y) * degrees;
|
70
|
+
} while (Math.abs(δ) > ε2 && --j > 0);
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
} while (--i0 >= 0);
|
74
|
+
var ax = robinsonConstants[i0][0],
|
75
|
+
bx = robinsonConstants[i0 + 1][0],
|
76
|
+
cx = robinsonConstants[Math.min(19, i0 + 2)][0];
|
77
|
+
return [
|
78
|
+
x / (bx + di * (cx - ax) / 2 + di * di * (cx - 2 * bx + ax) / 2),
|
79
|
+
φ * radians
|
80
|
+
];
|
81
|
+
};
|
82
|
+
|
83
|
+
(d3.geo.robinson = function() { return projection(robinson); }).raw = robinson;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
function satelliteVertical(P) {
|
2
|
+
function forward(λ, φ) {
|
3
|
+
var cosφ = Math.cos(φ),
|
4
|
+
k = (P - 1) / (P - cosφ * Math.cos(λ));
|
5
|
+
return [
|
6
|
+
k * cosφ * Math.sin(λ),
|
7
|
+
k * Math.sin(φ)
|
8
|
+
];
|
9
|
+
}
|
10
|
+
|
11
|
+
forward.invert = function(x, y) {
|
12
|
+
var ρ2 = x * x + y * y,
|
13
|
+
ρ = Math.sqrt(ρ2),
|
14
|
+
sinc = (P - Math.sqrt(1 - ρ2 * (P + 1) / (P - 1))) / ((P - 1) / ρ + ρ / (P - 1));
|
15
|
+
return [
|
16
|
+
Math.atan2(x * sinc, ρ * Math.sqrt(1 - sinc * sinc)),
|
17
|
+
ρ ? asin(y * sinc / ρ) : 0
|
18
|
+
];
|
19
|
+
};
|
20
|
+
|
21
|
+
return forward;
|
22
|
+
}
|
23
|
+
|
24
|
+
function satellite(P, ω) {
|
25
|
+
var vertical = satelliteVertical(P);
|
26
|
+
if (!ω) return vertical;
|
27
|
+
var cosω = Math.cos(ω),
|
28
|
+
sinω = Math.sin(ω);
|
29
|
+
|
30
|
+
function forward(λ, φ) {
|
31
|
+
var coordinates = vertical(λ, φ),
|
32
|
+
y = coordinates[1],
|
33
|
+
A = y * sinω / (P - 1) + cosω;
|
34
|
+
return [
|
35
|
+
coordinates[0] * cosω / A,
|
36
|
+
y / A
|
37
|
+
];
|
38
|
+
}
|
39
|
+
|
40
|
+
forward.invert = function(x, y) {
|
41
|
+
var k = (P - 1) / (P - 1 - y * sinω);
|
42
|
+
return vertical.invert(k * x, k * y * cosω);
|
43
|
+
};
|
44
|
+
|
45
|
+
return forward;
|
46
|
+
}
|
47
|
+
|
48
|
+
function satelliteProjection() {
|
49
|
+
var P = 1.4,
|
50
|
+
ω = 0,
|
51
|
+
m = projectionMutator(satellite),
|
52
|
+
p = m(P, ω);
|
53
|
+
|
54
|
+
// As a multiple of radius.
|
55
|
+
p.distance = function(_) {
|
56
|
+
if (!arguments.length) return P;
|
57
|
+
return m(P = +_, ω);
|
58
|
+
};
|
59
|
+
|
60
|
+
p.tilt = function(_) {
|
61
|
+
if (!arguments.length) return ω * 180 / π;
|
62
|
+
return m(P, ω = _ * π / 180);
|
63
|
+
};
|
64
|
+
|
65
|
+
return p;
|
66
|
+
}
|
67
|
+
|
68
|
+
(d3.geo.satellite = satelliteProjection).raw = satellite;
|