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,107 @@
|
|
1
|
+
# Extended Geographic Projections
|
2
|
+
|
3
|
+
Projections:
|
4
|
+
|
5
|
+
* d3.geo.aitoff - [Aitoff](http://bl.ocks.org/3682698)
|
6
|
+
* d3.geo.albers - [Albers equal-area conic](http://bl.ocks.org/3734308)
|
7
|
+
* d3.geo.armadillo - [Armadillo](http://bl.ocks.org/4463127)
|
8
|
+
* d3.geo.august - [August conformal](http://bl.ocks.org/3797581)
|
9
|
+
* d3.geo.azimuthalEqualArea - [Lambert azimuthal equal-area](http://bl.ocks.org/3757101)
|
10
|
+
* d3.geo.azimuthalEquidistant - [azimuthal equidistant](http://bl.ocks.org/3757110)
|
11
|
+
* d3.geo.baker - [Baker Dinomic](http://bl.ocks.org/4476279)
|
12
|
+
* d3.geo.berghaus - [Berghaus Star](http://bl.ocks.org/4463049)
|
13
|
+
* d3.geo.boggs - [Boggs eumorphic](http://bl.ocks.org/4481220)
|
14
|
+
* d3.geo.bonne - [Bonne](http://bl.ocks.org/3734313)
|
15
|
+
* d3.geo.bromley - [Bromley](http://bl.ocks.org/4487695)
|
16
|
+
* d3.geo.collignon - [Collignon](http://bl.ocks.org/3734316)
|
17
|
+
* d3.geo.conicConformal - [Lambert conformal conic](http://bl.ocks.org/3734321)
|
18
|
+
* d3.geo.conicEquidistant - [conic equidistant](http://bl.ocks.org/3734317)
|
19
|
+
* d3.geo.craig - [Craig retroazimuthal](http://bl.ocks.org/4459466)
|
20
|
+
* d3.geo.craster - [Craster parabolic](http://bl.ocks.org/4465118)
|
21
|
+
* d3.geo.cylindricalEqualArea - [cylindrical equal-area](http://bl.ocks.org/3712408), [Gall–Peters](http://bl.ocks.org/3946824), [Hobo–Dyer](http://bl.ocks.org/4476487), [Tobler world-in-a-square](http://bl.ocks.org/4476496)
|
22
|
+
* d3.geo.eckert1 - [Eckert I](http://bl.ocks.org/3734322)
|
23
|
+
* d3.geo.eckert2 - [Eckert II](http://bl.ocks.org/3734324)
|
24
|
+
* d3.geo.eckert3 - [Eckert III](http://bl.ocks.org/3734325)
|
25
|
+
* d3.geo.eckert4 - [Eckert IV](http://bl.ocks.org/3734327)
|
26
|
+
* d3.geo.eckert5 - [Eckert V](http://bl.ocks.org/3734328)
|
27
|
+
* d3.geo.eckert6 - [Eckert VI](http://bl.ocks.org/3734329)
|
28
|
+
* d3.geo.eisenlohr - [Eisenlohr conformal](http://bl.ocks.org/3797585)
|
29
|
+
* d3.geo.equirectangular - [Equirectangular (Plate Carrée)](http://bl.ocks.org/3757119)
|
30
|
+
* d3.geo.gnomonic - [gnomonic](http://bl.ocks.org/3757349)
|
31
|
+
* d3.geo.gringorten - [Gringorten](http://bl.ocks.org/3796882)
|
32
|
+
* d3.geo.guyou - [Guyou hemisphere-in-a-square](http://bl.ocks.org/3763867)
|
33
|
+
* d3.geo.hammer - [Hammer](http://bl.ocks.org/3712397), [Eckert–Greifendorff](http://bl.ocks.org/4496212), [quartic authalic](http://bl.ocks.org/4463175), [Briesemeister](http://bl.ocks.org/4519926)
|
34
|
+
* d3.geo.hammerRetroazimuthal - [Hammer retroazimuthal](http://bl.ocks.org/4459130)
|
35
|
+
* d3.geo.healpix - [HEALPix](http://bl.ocks.org/4463237)
|
36
|
+
* d3.geo.hill - [Hill eucyclic](http://bl.ocks.org/4479513), [Maurer No. 73](http://bl.ocks.org/4479547)
|
37
|
+
* d3.geo.homolosine - [Goode homolosine](http://bl.ocks.org/3734330)
|
38
|
+
* d3.geo.kavrayskiy7 - [Kavrayskiy VII](http://bl.ocks.org/3710082)
|
39
|
+
* d3.geo.lagrange - [Lagrange conformal](http://bl.ocks.org/3797591)
|
40
|
+
* d3.geo.larrivee - [Larrivée](http://bl.ocks.org/3719042)
|
41
|
+
* d3.geo.laskowski - [Laskowski tri-optimal](http://bl.ocks.org/4489342)
|
42
|
+
* d3.geo.littrow - [Littrow](http://bl.ocks.org/4459071)
|
43
|
+
* d3.geo.loximuthal - [loximuthal](http://bl.ocks.org/3867220)
|
44
|
+
* d3.geo.mercator - [Mercator](http://bl.ocks.org/3757132)
|
45
|
+
* d3.geo.miller - [Miller](http://bl.ocks.org/3734333)
|
46
|
+
* d3.geo.mollweide - [Mollweide](http://bl.ocks.org/3734336), [Atlantis](http://bl.ocks.org/4519975)
|
47
|
+
* d3.geo.mtFlatPolarParabolic - [McBryde–Thomas flat-polar parabolic](http://bl.ocks.org/4465130)
|
48
|
+
* d3.geo.mtFlatPolarQuartic - [McBryde–Thomas flat-polar quartic](http://bl.ocks.org/4465137)
|
49
|
+
* d3.geo.mtFlatPolarSinusoidal - [McBryde–Thomas flat-polar sinusoidal](http://bl.ocks.org/4465140)
|
50
|
+
* d3.geo.naturalEarth - [Natural Earth](http://bl.ocks.org/4479477)
|
51
|
+
* d3.geo.nellHammer - [Nell–Hammer](http://bl.ocks.org/3734342)
|
52
|
+
* d3.geo.orthographic - [orthographic](http://bl.ocks.org/3757125)
|
53
|
+
* d3.geo.peirceQuincuncial - [Pierce quincuncial](http://bl.ocks.org/4310087)
|
54
|
+
* d3.geo.polyconic - [Polyconic](http://bl.ocks.org/3734343)
|
55
|
+
* d3.geo.robinson - [Robinson](http://bl.ocks.org/3710566)
|
56
|
+
* d3.geo.satellite - [satellite (tilted perpsective)](http://bl.ocks.org/3790444)
|
57
|
+
* d3.geo.sinusoidal - [sinusoidal](http://bl.ocks.org/3712399)
|
58
|
+
* d3.geo.sinuMollweide - [Sinu-Mollweide](http://bl.ocks.org/4319903)
|
59
|
+
* d3.geo.stereographic - [stereographic](http://bl.ocks.org/3757137)
|
60
|
+
* d3.geo.vanDerGrinten - [Van der Grinten](http://bl.ocks.org/3796831)
|
61
|
+
* d3.geo.vanDerGrinten4 - [Van der Grinten IV](http://bl.ocks.org/4489365)
|
62
|
+
* d3.geo.wagner4 - [Wagner IV, Putniṇš P2´](http://bl.ocks.org/4487674)
|
63
|
+
* d3.geo.wagner6 - [Wagner VI](http://bl.ocks.org/3710148)
|
64
|
+
* d3.geo.wagner7 - [Wagner VII](http://bl.ocks.org/4465109)
|
65
|
+
* d3.geo.wiechel - [Wiechel](http://bl.ocks.org/4463155)
|
66
|
+
* d3.geo.winkel3 - [Winkel Tripel](http://bl.ocks.org/3682676)
|
67
|
+
|
68
|
+
This plugin also provides d3.geo.interrupt, which can be used to create arbitrary interrupted projections from a given raw projection. For example, see [Philbrick’s interrupted Sinu-Mollweide](http://bl.ocks.org/4481520).
|
69
|
+
|
70
|
+
This plugin requires [D3 3.0](https://github.com/mbostock/d3/wiki/Upgrading-to-3.0) or greater. To use the official hosted version, include the projection plugin after including D3:
|
71
|
+
|
72
|
+
```html
|
73
|
+
<script src="http://d3js.org/d3.v3.min.js"></script>
|
74
|
+
<script src="http://d3js.org/d3.geo.projection.v0.min.js"></script>
|
75
|
+
```
|
76
|
+
|
77
|
+
Alternatively, you can clone this repo, [download the zipball](http://github.com/d3/d3-plugins/zipball/master), or right-click [d3.geo.projection.v0.min.js](http://d3js.org/d3.geo.projection.v0.min.js) and save.
|
78
|
+
|
79
|
+
## Defining a New Projection
|
80
|
+
|
81
|
+
First define your raw projection function:
|
82
|
+
|
83
|
+
```js
|
84
|
+
function cosinusoidal(λ, φ) {
|
85
|
+
return [λ * Math.sin(φ), φ];
|
86
|
+
}
|
87
|
+
|
88
|
+
cosinusoidal.invert = function(x, y) {
|
89
|
+
return [x / Math.sin(y), y];
|
90
|
+
};
|
91
|
+
```
|
92
|
+
|
93
|
+
Then create a constructor using d3.geo.projection:
|
94
|
+
|
95
|
+
```js
|
96
|
+
d3.geo.cosinusoidal = function() {
|
97
|
+
return d3.geo.projection(cosinusoidal);
|
98
|
+
};
|
99
|
+
```
|
100
|
+
|
101
|
+
You can optionally expose the raw projection to facilitate composite projections:
|
102
|
+
|
103
|
+
```js
|
104
|
+
(d3.geo.cosinusoidal = function() {
|
105
|
+
return d3.geo.projection(cosinusoidal);
|
106
|
+
}).raw = cosinusoidal;
|
107
|
+
```
|
@@ -0,0 +1,40 @@
|
|
1
|
+
function aitoff(λ, φ) {
|
2
|
+
var cosφ = Math.cos(φ),
|
3
|
+
sinciα = sinci(acos(cosφ * Math.cos(λ /= 2)));
|
4
|
+
return [
|
5
|
+
2 * cosφ * Math.sin(λ) * sinciα,
|
6
|
+
Math.sin(φ) * sinciα
|
7
|
+
];
|
8
|
+
}
|
9
|
+
|
10
|
+
aitoff.invert = function(x, y) {
|
11
|
+
var λ = x, φ = y, i = 25;
|
12
|
+
do {
|
13
|
+
var sinλ = Math.sin(λ),
|
14
|
+
sinλ_2 = Math.sin(λ / 2),
|
15
|
+
cosλ_2 = Math.cos(λ / 2),
|
16
|
+
sinφ = Math.sin(φ),
|
17
|
+
cosφ = Math.cos(φ),
|
18
|
+
sin_2φ = Math.sin(2 * φ),
|
19
|
+
sin2φ = sinφ * sinφ,
|
20
|
+
cos2φ = cosφ * cosφ,
|
21
|
+
sin2λ_2 = sinλ_2 * sinλ_2,
|
22
|
+
C = 1 - cos2φ * cosλ_2 * cosλ_2,
|
23
|
+
E = C ? acos(cosφ * cosλ_2) * Math.sqrt(F = 1 / C) : F = 0,
|
24
|
+
F,
|
25
|
+
fx = 2 * E * cosφ * sinλ_2 - x,
|
26
|
+
fy = E * sinφ - y,
|
27
|
+
δxδλ = F * (cos2φ * sin2λ_2 + E * cosφ * cosλ_2 * sin2φ),
|
28
|
+
δxδφ = F * (.5 * sinλ * sin_2φ - E * 2 * sinφ * sinλ_2),
|
29
|
+
δyδλ = F * .25 * (sin_2φ * sinλ_2 - E * sinφ * cos2φ * sinλ),
|
30
|
+
δyδφ = F * (sin2φ * cosλ_2 + E * sin2λ_2 * cosφ),
|
31
|
+
denominator = δxδφ * δyδλ - δyδφ * δxδλ;
|
32
|
+
if (!denominator) break;
|
33
|
+
var δλ = (fy * δxδφ - fx * δyδφ) / denominator,
|
34
|
+
δφ = (fx * δyδλ - fy * δxδλ) / denominator;
|
35
|
+
λ -= δλ, φ -= δφ;
|
36
|
+
} while ((Math.abs(δλ) > ε || Math.abs(δφ) > ε) && --i > 0);
|
37
|
+
return [λ, φ];
|
38
|
+
};
|
39
|
+
|
40
|
+
(d3.geo.aitoff = function() { return projection(aitoff); }).raw = aitoff;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
function armadillo(φ0) {
|
2
|
+
var sinφ0 = Math.sin(φ0),
|
3
|
+
cosφ0 = Math.cos(φ0),
|
4
|
+
sφ0 = φ0 > 0 ? 1 : -1,
|
5
|
+
tanφ0 = Math.tan(sφ0 * φ0),
|
6
|
+
k = (1 + sinφ0 - cosφ0) / 2;
|
7
|
+
|
8
|
+
function forward(λ, φ) {
|
9
|
+
var cosφ = Math.cos(φ),
|
10
|
+
cosλ = Math.cos(λ /= 2);
|
11
|
+
return [
|
12
|
+
(1 + cosφ) * Math.sin(λ),
|
13
|
+
// TODO D3 core should allow null or [NaN, NaN] to be returned.
|
14
|
+
(sφ0 * φ > -Math.atan2(cosλ, tanφ0) - 1e-3 ? 0 : -sφ0 * 10) +
|
15
|
+
k + Math.sin(φ) * cosφ0 - (1 + cosφ) * sinφ0 * cosλ
|
16
|
+
];
|
17
|
+
}
|
18
|
+
|
19
|
+
forward.invert = function(x, y) {
|
20
|
+
var λ = 0,
|
21
|
+
φ = 0,
|
22
|
+
i = 50;
|
23
|
+
do {
|
24
|
+
var cosλ = Math.cos(λ),
|
25
|
+
sinλ = Math.sin(λ),
|
26
|
+
cosφ = Math.cos(φ),
|
27
|
+
sinφ = Math.sin(φ),
|
28
|
+
A = 1 + cosφ,
|
29
|
+
fx = A * sinλ - x,
|
30
|
+
fy = k + sinφ * cosφ0 - A * sinφ0 * cosλ - y,
|
31
|
+
δxδλ = .5 * A * cosλ,
|
32
|
+
δxδφ = -sinλ * sinφ,
|
33
|
+
δyδλ = .5 * sinφ0 * A * sinλ,
|
34
|
+
δyδφ = cosφ0 * cosφ + sinφ0 * cosλ * sinφ,
|
35
|
+
denominator = δxδφ * δyδλ - δyδφ * δxδλ,
|
36
|
+
δλ = .5 * (fy * δxδφ - fx * δyδφ) / denominator,
|
37
|
+
δφ = (fx * δyδλ - fy * δxδλ) / denominator;
|
38
|
+
λ -= δλ, φ -= δφ;
|
39
|
+
} while ((Math.abs(δλ) > ε || Math.abs(δφ) > ε) && --i > 0);
|
40
|
+
return sφ0 * φ > -Math.atan2(Math.cos(λ), tanφ0) - 1e-3 ? [λ * 2, φ] : null;
|
41
|
+
};
|
42
|
+
|
43
|
+
return forward;
|
44
|
+
}
|
45
|
+
|
46
|
+
function armadilloProjection() {
|
47
|
+
var φ0 = π / 9, // 20°
|
48
|
+
sφ0 = φ0 > 0 ? 1 : -1,
|
49
|
+
tanφ0 = Math.tan(sφ0 * φ0),
|
50
|
+
m = projectionMutator(armadillo),
|
51
|
+
p = m(φ0),
|
52
|
+
stream_ = p.stream;
|
53
|
+
|
54
|
+
p.parallel = function(_) {
|
55
|
+
if (!arguments.length) return φ0 / π * 180;
|
56
|
+
tanφ0 = Math.tan((sφ0 = (φ0 = _ * π / 180) > 0 ? 1 : -1) * φ0);
|
57
|
+
return m(φ0);
|
58
|
+
};
|
59
|
+
|
60
|
+
p.stream = function(stream) {
|
61
|
+
var rotate = p.rotate(),
|
62
|
+
rotateStream = stream_(stream),
|
63
|
+
sphereStream = (p.rotate([0, 0]), stream_(stream));
|
64
|
+
p.rotate(rotate);
|
65
|
+
rotateStream.sphere = function() {
|
66
|
+
sphereStream.polygonStart(), sphereStream.lineStart();
|
67
|
+
for (var λ = sφ0 * -180; sφ0 * λ < 180; λ += sφ0 * 90) sphereStream.point(λ, sφ0 * 90);
|
68
|
+
while (sφ0 * (λ -= φ0) >= -180) { // TODO precision?
|
69
|
+
sphereStream.point(λ, sφ0 * -Math.atan2(Math.cos(λ * radians / 2), tanφ0) * degrees);
|
70
|
+
}
|
71
|
+
sphereStream.lineEnd(), sphereStream.polygonEnd();
|
72
|
+
};
|
73
|
+
return rotateStream;
|
74
|
+
};
|
75
|
+
|
76
|
+
return p;
|
77
|
+
}
|
78
|
+
|
79
|
+
(d3.geo.armadillo = armadilloProjection).raw = armadillo;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function august(λ, φ) {
|
2
|
+
var tanφ = Math.tan(φ / 2),
|
3
|
+
k = 1 - tanφ * tanφ,
|
4
|
+
c = 1 + k * Math.cos(λ /= 2),
|
5
|
+
x = Math.sin(λ) * k / c,
|
6
|
+
y = tanφ / c,
|
7
|
+
x2 = x * x,
|
8
|
+
y2 = y * y;
|
9
|
+
return [
|
10
|
+
4 / 3 * x * (3 + x2 - 3 * y2),
|
11
|
+
4 / 3 * y * (3 + 3 * x2 - y2)
|
12
|
+
];
|
13
|
+
}
|
14
|
+
|
15
|
+
(d3.geo.august = function() { return projection(august); }).raw = august;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
var bakerφ = Math.log(1 + Math.SQRT2);
|
2
|
+
|
3
|
+
function baker(λ, φ) {
|
4
|
+
var φ0 = Math.abs(φ);
|
5
|
+
return φ0 < π / 4
|
6
|
+
? [λ, Math.log(Math.tan(π / 4 + φ / 2))]
|
7
|
+
: [
|
8
|
+
λ * Math.cos(φ0) * (2 * Math.SQRT2 - 1 / Math.sin(φ0)),
|
9
|
+
sgn(φ) * (2 * Math.SQRT2 * (φ0 - π / 4) - Math.log(Math.tan(φ0 / 2)))
|
10
|
+
];
|
11
|
+
}
|
12
|
+
|
13
|
+
baker.invert = function(x, y) {
|
14
|
+
if ((y0 = Math.abs(y)) < bakerφ) return [x, 2 * Math.atan(Math.exp(y)) - π / 2];
|
15
|
+
var sqrt8 = Math.sqrt(8),
|
16
|
+
φ = π / 4, i = 25, δ, y0;
|
17
|
+
do {
|
18
|
+
var cosφ_2 = Math.cos(φ / 2),
|
19
|
+
tanφ_2 = Math.tan(φ / 2);
|
20
|
+
φ -= δ = (sqrt8 * (φ - π / 4) - Math.log(tanφ_2) - y0) / (sqrt8 - .5 * cosφ_2 * cosφ_2 / tanφ_2);
|
21
|
+
} while (Math.abs(δ) > ε2 && --i > 0);
|
22
|
+
return [
|
23
|
+
x / (Math.cos(φ) * (sqrt8 - 1 / Math.sin(φ))),
|
24
|
+
sgn(y) * φ
|
25
|
+
];
|
26
|
+
};
|
27
|
+
|
28
|
+
(d3.geo.baker = function() { return projection(baker); }).raw = baker;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var berghausAzimuthalEquidistant = d3.geo.azimuthalEquidistant.raw;
|
2
|
+
|
3
|
+
function berghaus(n) {
|
4
|
+
var k = 2 * π / n;
|
5
|
+
|
6
|
+
function forward(λ, φ) {
|
7
|
+
var p = berghausAzimuthalEquidistant(λ, φ);
|
8
|
+
if (Math.abs(λ) > π / 2) { // back hemisphere
|
9
|
+
var θ = Math.atan2(p[1], p[0]),
|
10
|
+
r = Math.sqrt(p[0] * p[0] + p[1] * p[1]),
|
11
|
+
θ0 = k * Math.round((θ - π / 2) / k) + π / 2,
|
12
|
+
α = Math.atan2(Math.sin(θ -= θ0), 2 - Math.cos(θ)); // angle relative to lobe end
|
13
|
+
θ = θ0 + asin(π / r * Math.sin(α)) - α;
|
14
|
+
p[0] = r * Math.cos(θ);
|
15
|
+
p[1] = r * Math.sin(θ);
|
16
|
+
}
|
17
|
+
return p;
|
18
|
+
}
|
19
|
+
|
20
|
+
return forward;
|
21
|
+
}
|
22
|
+
|
23
|
+
function berghausProjection() {
|
24
|
+
var n = 5,
|
25
|
+
m = projectionMutator(berghaus),
|
26
|
+
p = m(n),
|
27
|
+
stream_ = p.stream;
|
28
|
+
|
29
|
+
p.lobes = function(_) {
|
30
|
+
if (!arguments.length) return n;
|
31
|
+
return m(n = +_);
|
32
|
+
};
|
33
|
+
|
34
|
+
p.stream = function(stream) {
|
35
|
+
var rotate = p.rotate(),
|
36
|
+
rotateStream = stream_(stream),
|
37
|
+
sphereStream = (p.rotate([0, 0]), stream_(stream));
|
38
|
+
p.rotate(rotate);
|
39
|
+
rotateStream.sphere = function() {
|
40
|
+
sphereStream.polygonStart(), sphereStream.lineStart();
|
41
|
+
var ε = 1e-4;
|
42
|
+
for (var i = 0, δ = 360 / n, φ = 90 - 180 / n; i < n; ++i, φ -= δ) {
|
43
|
+
sphereStream.point(180, 0);
|
44
|
+
if (φ < -90) {
|
45
|
+
sphereStream.point(-90, 180 - φ - ε);
|
46
|
+
sphereStream.point(-90, 180 - φ + ε);
|
47
|
+
} else {
|
48
|
+
sphereStream.point(90, φ + ε);
|
49
|
+
sphereStream.point(90, φ - ε);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
sphereStream.lineEnd(), sphereStream.polygonEnd();
|
53
|
+
};
|
54
|
+
return rotateStream;
|
55
|
+
};
|
56
|
+
|
57
|
+
return p;
|
58
|
+
}
|
59
|
+
|
60
|
+
(d3.geo.berghaus = berghausProjection).raw = berghaus;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// @import mollweide
|
2
|
+
|
3
|
+
function boggs(λ, φ) {
|
4
|
+
var k = 2.00276,
|
5
|
+
θ = mollweideθ(φ);
|
6
|
+
return [
|
7
|
+
k * λ / (1 / Math.cos(φ) + 1.11072 / Math.cos(θ)),
|
8
|
+
(φ + Math.SQRT2 * Math.sin(θ)) / k
|
9
|
+
];
|
10
|
+
}
|
11
|
+
|
12
|
+
boggs.invert = function(x, y) {
|
13
|
+
var k = 2.00276,
|
14
|
+
ky = k * y,
|
15
|
+
θ = y < 0 ? -π / 4 : π / 4, i = 25, δ, φ;
|
16
|
+
do {
|
17
|
+
φ = ky - Math.SQRT2 * Math.sin(θ);
|
18
|
+
θ -= δ = (Math.sin(2 * θ) + 2 * θ - π * Math.sin(φ)) / (2 * Math.cos(2 * θ) + 2 + π * Math.cos(φ) * Math.SQRT2 * Math.cos(θ));
|
19
|
+
} while (Math.abs(δ) > ε && --i > 0);
|
20
|
+
φ = ky - Math.SQRT2 * Math.sin(θ);
|
21
|
+
return [
|
22
|
+
x * (1 / Math.cos(φ) + 1.11072 / Math.cos(θ)) / k,
|
23
|
+
φ
|
24
|
+
];
|
25
|
+
};
|
26
|
+
|
27
|
+
(d3.geo.boggs = function() { return projection(boggs); }).raw = boggs;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// @import parallel1
|
2
|
+
// @import sinusoidal
|
3
|
+
|
4
|
+
function bonne(φ0) {
|
5
|
+
if (!φ0) return sinusoidal;
|
6
|
+
var cotφ0 = 1 / Math.tan(φ0);
|
7
|
+
|
8
|
+
function forward(λ, φ) {
|
9
|
+
var ρ = cotφ0 + φ0 - φ,
|
10
|
+
E = λ * Math.cos(φ) / ρ;
|
11
|
+
return [
|
12
|
+
ρ * Math.sin(E),
|
13
|
+
cotφ0 - ρ * Math.cos(E)
|
14
|
+
];
|
15
|
+
}
|
16
|
+
|
17
|
+
forward.invert = function(x, y) {
|
18
|
+
var ρ = Math.sqrt(x * x + (y = cotφ0 - y) * y),
|
19
|
+
φ = cotφ0 + φ0 - ρ;
|
20
|
+
return [
|
21
|
+
ρ / Math.cos(φ) * Math.atan2(x, y),
|
22
|
+
φ
|
23
|
+
];
|
24
|
+
};
|
25
|
+
|
26
|
+
return forward;
|
27
|
+
}
|
28
|
+
|
29
|
+
(d3.geo.bonne = function() { return parallel1Projection(bonne).parallel(45); }).raw = bonne;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
function collignon(λ, φ) {
|
2
|
+
var α = asqrt(1 - Math.sin(φ));
|
3
|
+
return [
|
4
|
+
(2 / sqrtπ) * λ * α,
|
5
|
+
sqrtπ * (1 - α)
|
6
|
+
];
|
7
|
+
}
|
8
|
+
|
9
|
+
collignon.invert = function(x, y) {
|
10
|
+
var λ = (λ = y / sqrtπ - 1) * λ;
|
11
|
+
return [
|
12
|
+
λ > 0 ? x * Math.sqrt(π / λ) / 2 : 0,
|
13
|
+
asin(1 - λ)
|
14
|
+
];
|
15
|
+
};
|
16
|
+
|
17
|
+
(d3.geo.collignon = function() { return projection(collignon); }).raw = collignon;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// @import parallel2
|
2
|
+
|
3
|
+
function conicConformal(φ0, φ1) {
|
4
|
+
var cosφ0 = Math.cos(φ0),
|
5
|
+
t = function(φ) { return Math.tan(π / 4 + φ / 2); },
|
6
|
+
n = Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)),
|
7
|
+
F = cosφ0 * Math.pow(t(φ0), n) / n;
|
8
|
+
|
9
|
+
function forward(λ, φ) {
|
10
|
+
var ρ = Math.abs(Math.abs(φ) - π / 2) < ε ? 0 : F / Math.pow(t(φ), n);
|
11
|
+
return [
|
12
|
+
ρ * Math.sin(n * λ),
|
13
|
+
F - ρ * Math.cos(n * λ)
|
14
|
+
];
|
15
|
+
}
|
16
|
+
|
17
|
+
forward.invert = function(x, y) {
|
18
|
+
var ρ0_y = F - y,
|
19
|
+
ρ = sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);
|
20
|
+
return [
|
21
|
+
Math.atan2(x, ρ0_y) / n,
|
22
|
+
2 * Math.atan(Math.pow(F / ρ, 1 / n)) - π / 2
|
23
|
+
];
|
24
|
+
};
|
25
|
+
|
26
|
+
return forward;
|
27
|
+
}
|
28
|
+
|
29
|
+
(d3.geo.conicConformal = function() { return parallel2Projection(conicConformal); }).raw = conicConformal;
|