d3js-plugins-rails 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/d3js-plugins-rails/version.rb +2 -2
- data/vendor/assets/javascripts/d3/plugins/Makefile +1 -3
- data/vendor/assets/javascripts/d3/plugins/box/box.js +2 -2
- data/vendor/assets/javascripts/d3/plugins/force_labels/force_labels.js +32 -31
- data/vendor/assets/javascripts/d3/plugins/geo/projection/README.md +11 -10
- data/vendor/assets/javascripts/d3/plugins/geo/projection/berghaus.js +2 -2
- data/vendor/assets/javascripts/d3/plugins/geo/projection/gall-stereographic.js +19 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/gringorten.js +1 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/index.js +1 -4
- data/vendor/assets/javascripts/d3/plugins/geo/projection/interrupt.js +1 -1
- data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/README.md +2 -2
- data/vendor/assets/javascripts/d3/plugins/package.json +1 -1
- data/vendor/assets/javascripts/d3/plugins/simplify/README.md +1 -4
- data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode-test.js +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -9
- metadata.gz.sig +0 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js +0 -40
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equal-area.js +0 -29
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js +0 -30
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/transverse-mercator-test.js +0 -29
- data/vendor/assets/javascripts/d3/plugins/geo/projection/transverse-mercator.js +0 -19
- data/vendor/assets/javascripts/d3/plugins/simplify/simplify-test.js +0 -193
- data/vendor/assets/javascripts/d3/plugins/simplify/simplify.js +0 -446
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e01f5b6f83287492b9f81ae4857a2f30fffff20e
|
4
|
+
data.tar.gz: c5bd529307c3c163f761097655e900c2e6f1cb66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a7b3894a68fc08512e09a59671eb33bfb000e95c1b8ef14be165544f02b5d5b41756def0f3756e42ac6122166207bc0a6faca9a3aa04dfae442caf6e94889c0
|
7
|
+
data.tar.gz: 393da2cb39599c594090a70320ece141421fc25b9bdcd9d5347f7f913e55d0d828fc326d2830391058d578a9e6670aa308f888f4cc016307f9577375007670e9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -4,9 +4,7 @@ all: \
|
|
4
4
|
|
5
5
|
d3.geo.projection.js: $(shell node_modules/.bin/smash --list geo/projection/index.js)
|
6
6
|
@rm -f $@
|
7
|
-
node_modules/.bin/smash geo/projection/index.js
|
8
|
-
node_modules/.bin/uglifyjs $@.tmp -b indent-level=2 -o $@
|
9
|
-
@rm $@.tmp
|
7
|
+
node_modules/.bin/smash geo/projection/index.js | node_modules/.bin/uglifyjs - -b indent-level=2 -o $@
|
10
8
|
@chmod a-w $@
|
11
9
|
|
12
10
|
d3.geo.projection.min.js: d3.geo.projection.js
|
@@ -187,8 +187,8 @@ d3.box = function() {
|
|
187
187
|
boxTick.enter().append("text")
|
188
188
|
.attr("class", "box")
|
189
189
|
.attr("dy", ".3em")
|
190
|
-
.attr("dx", function(d, i) { return i & 1 ? 6 : -6 })
|
191
|
-
.attr("x", function(d, i) { return i & 1 ? width : 0 })
|
190
|
+
.attr("dx", function(d, i) { return i & 1 ? 6 : -6; })
|
191
|
+
.attr("x", function(d, i) { return i & 1 ? width : 0; })
|
192
192
|
.attr("y", x0)
|
193
193
|
.attr("text-anchor", function(d, i) { return i & 1 ? "start" : "end"; })
|
194
194
|
.text(format)
|
@@ -1,56 +1,57 @@
|
|
1
1
|
(function() {
|
2
2
|
d3.force_labels = function force_labels() {
|
3
|
-
var labels = d3.layout.force()
|
3
|
+
var labels = d3.layout.force();
|
4
4
|
|
5
5
|
// Update the position of the anchor based on the center of bounding box
|
6
6
|
function updateAnchor() {
|
7
|
-
if (!labels.selection) return
|
7
|
+
if (!labels.selection) return;
|
8
8
|
labels.selection.each(function(d) {
|
9
9
|
var bbox = this.getBBox(),
|
10
|
-
x=bbox.x+bbox.width/2,
|
11
|
-
y=bbox.y+bbox.height/2
|
10
|
+
x = bbox.x + bbox.width / 2,
|
11
|
+
y = bbox.y + bbox.height / 2;
|
12
12
|
|
13
|
-
d.anchorPos.x=x
|
14
|
-
d.anchorPos.y=y
|
13
|
+
d.anchorPos.x = x;
|
14
|
+
d.anchorPos.y = y;
|
15
15
|
|
16
16
|
// If a label position does not exist, set it to be the anchor position
|
17
|
-
if (d.labelPos.x==null) {
|
18
|
-
d.labelPos.x=x
|
19
|
-
d.labelPos.y=y
|
17
|
+
if (d.labelPos.x == null) {
|
18
|
+
d.labelPos.x = x;
|
19
|
+
d.labelPos.y = y;
|
20
20
|
}
|
21
|
-
})
|
21
|
+
});
|
22
22
|
}
|
23
23
|
|
24
24
|
//The anchor position should be updated on each tick
|
25
|
-
labels.on("tick.labels",updateAnchor)
|
25
|
+
labels.on("tick.labels", updateAnchor);
|
26
26
|
|
27
27
|
// This updates all nodes/links - retaining any previous labelPos on updated nodes
|
28
28
|
labels.update = function(selection) {
|
29
|
-
labels.selection = selection
|
30
|
-
var nodes=[],links=[];
|
29
|
+
labels.selection = selection;
|
30
|
+
var nodes = [], links = [];
|
31
31
|
selection[0].forEach(function(d) {
|
32
32
|
if(d && d.__data__) {
|
33
|
-
var data = d.__data__
|
33
|
+
var data = d.__data__;
|
34
34
|
|
35
|
-
if (!d.labelPos) d.labelPos =
|
36
|
-
if (!d.anchorPos) d.anchorPos = {fixed:true}
|
35
|
+
if (!d.labelPos) d.labelPos = {fixed: false};
|
36
|
+
if (!d.anchorPos) d.anchorPos = {fixed: true};
|
37
37
|
|
38
38
|
// Place position objects in __data__ to make them available through
|
39
39
|
// d.labelPos/d.anchorPos for different elements
|
40
|
-
data.labelPos = d.labelPos
|
41
|
-
data.anchorPos = d.anchorPos
|
40
|
+
data.labelPos = d.labelPos;
|
41
|
+
data.anchorPos = d.anchorPos;
|
42
42
|
|
43
|
-
links.push({target:d.anchorPos,source:d.labelPos})
|
44
|
-
nodes.push(d.anchorPos)
|
45
|
-
nodes.push(d.labelPos)
|
43
|
+
links.push({target: d.anchorPos, source: d.labelPos});
|
44
|
+
nodes.push(d.anchorPos);
|
45
|
+
nodes.push(d.labelPos);
|
46
46
|
}
|
47
|
-
})
|
48
|
-
labels
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
47
|
+
});
|
48
|
+
labels
|
49
|
+
.stop()
|
50
|
+
.nodes(nodes)
|
51
|
+
.links(links);
|
52
|
+
updateAnchor();
|
53
|
+
labels.start();
|
54
|
+
};
|
55
|
+
return labels;
|
56
|
+
};
|
57
|
+
})();
|
@@ -28,6 +28,7 @@ Projections:
|
|
28
28
|
* d3.geo.eisenlohr - [Eisenlohr conformal](http://bl.ocks.org/mbostock/3797585)
|
29
29
|
* d3.geo.equirectangular - [Equirectangular (Plate Carrée)](http://bl.ocks.org/mbostock/3757119)
|
30
30
|
* d3.geo.fahey - [Fahey](http://bl.ocks.org/mbostock/4731228)
|
31
|
+
* d3.geo.gallStereographic - [Gall’s stereographic](http://bl.ocks.org/mbostock/5234763)
|
31
32
|
* d3.geo.gnomonic - [gnomonic](http://bl.ocks.org/mbostock/3757349)
|
32
33
|
* d3.geo.gringorten - [Gringorten](http://bl.ocks.org/mbostock/4362031)
|
33
34
|
* d3.geo.guyou - [Guyou hemisphere-in-a-square](http://bl.ocks.org/mbostock/3763867)
|
@@ -44,7 +45,7 @@ Projections:
|
|
44
45
|
* d3.geo.loximuthal - [loximuthal](http://bl.ocks.org/mbostock/3867220)
|
45
46
|
* d3.geo.mercator - [Mercator](http://bl.ocks.org/mbostock/3757132)
|
46
47
|
* d3.geo.miller - [Miller](http://bl.ocks.org/mbostock/3734333)
|
47
|
-
* d3.geo.modifiedStereographic -
|
48
|
+
* d3.geo.modifiedStereographic - [modified stereographic](http://www.jasondavies.com/maps/modified-stereographic/)
|
48
49
|
* d3.geo.mollweide - [Mollweide](http://bl.ocks.org/mbostock/3734336), [Atlantis](http://bl.ocks.org/mbostock/4519975)
|
49
50
|
* d3.geo.mtFlatPolarParabolic - [McBryde–Thomas flat-polar parabolic](http://bl.ocks.org/mbostock/4465130)
|
50
51
|
* d3.geo.mtFlatPolarQuartic - [McBryde–Thomas flat-polar quartic](http://bl.ocks.org/mbostock/4465137)
|
@@ -53,26 +54,26 @@ Projections:
|
|
53
54
|
* d3.geo.nellHammer - [Nell–Hammer](http://bl.ocks.org/mbostock/3734342)
|
54
55
|
* d3.geo.orthographic - [orthographic](http://bl.ocks.org/mbostock/3757125)
|
55
56
|
* d3.geo.peirceQuincuncial - [Pierce quincuncial](http://bl.ocks.org/mbostock/4310087)
|
56
|
-
* d3.geo.polyconic - [
|
57
|
-
* d3.geo.rectangularPolyconic -
|
57
|
+
* d3.geo.polyconic - [polyconic](http://bl.ocks.org/mbostock/3734343)
|
58
|
+
* d3.geo.rectangularPolyconic - [rectangular polyconic](http://bl.ocks.org/mbostock/5230202)
|
58
59
|
* d3.geo.robinson - [Robinson](http://bl.ocks.org/mbostock/3710566)
|
59
60
|
* d3.geo.satellite - [satellite (tilted perpsective)](http://bl.ocks.org/mbostock/3790444)
|
60
61
|
* d3.geo.sinusoidal - [sinusoidal](http://bl.ocks.org/mbostock/3712399)
|
61
62
|
* d3.geo.sinuMollweide - [Sinu-Mollweide](http://bl.ocks.org/mbostock/4319903)
|
62
63
|
* d3.geo.stereographic - [stereographic](http://bl.ocks.org/mbostock/3757137)
|
63
|
-
* d3.geo.times - Times
|
64
|
-
* d3.geo.transverseMercator -
|
65
|
-
* d3.geo.twoPointAzimuthal -
|
66
|
-
* d3.geo.twoPointEquidistant -
|
64
|
+
* d3.geo.times - [Times](http://bl.ocks.org/mbostock/5230564)
|
65
|
+
* d3.geo.transverseMercator - [transverse Mercator](http://bl.ocks.org/mbostock/5126418)
|
66
|
+
* d3.geo.twoPointAzimuthal - [two-point azimuthal](https://www.jasondavies.com/maps/two-point-azimuthal/)
|
67
|
+
* d3.geo.twoPointEquidistant - [two-point equidistant](https://www.jasondavies.com/maps/two-point-equidistant/)
|
67
68
|
* d3.geo.vanDerGrinten - [Van der Grinten](http://bl.ocks.org/mbostock/3796831)
|
68
|
-
* d3.geo.vanDerGrinten2 - Van der Grinten II
|
69
|
-
* d3.geo.vanDerGrinten3 - Van der Grinten III
|
69
|
+
* d3.geo.vanDerGrinten2 - [Van der Grinten II](http://bl.ocks.org/mbostock/5230571)
|
70
|
+
* d3.geo.vanDerGrinten3 - [Van der Grinten III](http://bl.ocks.org/mbostock/5230580)
|
70
71
|
* d3.geo.vanDerGrinten4 - [Van der Grinten IV](http://bl.ocks.org/mbostock/4489365)
|
71
72
|
* d3.geo.wagner4 - [Wagner IV, Putniṇš P2´](http://bl.ocks.org/mbostock/4487674)
|
72
73
|
* d3.geo.wagner6 - [Wagner VI](http://bl.ocks.org/mbostock/3710148)
|
73
74
|
* d3.geo.wagner7 - [Wagner VII](http://bl.ocks.org/mbostock/4465109)
|
74
75
|
* d3.geo.wiechel - [Wiechel](http://bl.ocks.org/mbostock/4463155)
|
75
|
-
* d3.geo.winkel3 - [Winkel
|
76
|
+
* d3.geo.winkel3 - [Winkel tripel](http://bl.ocks.org/mbostock/3682676)
|
76
77
|
|
77
78
|
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).
|
78
79
|
|
@@ -25,7 +25,7 @@ function berghaus(n) {
|
|
25
25
|
var θ = Math.atan2(y, x),
|
26
26
|
θ0 = k * Math.round((θ - π / 2) / k) + π / 2,
|
27
27
|
s = θ > θ0 ? -1 : 1,
|
28
|
-
A = r * Math.cos(θ0 - θ)
|
28
|
+
A = r * Math.cos(θ0 - θ),
|
29
29
|
cotα = 1 / Math.tan(s * Math.acos((A - π) / Math.sqrt(π * (π - 2 * A) + r * r)));
|
30
30
|
θ = θ0 + 2 * Math.atan((cotα + s * Math.sqrt(cotα * cotα - 3)) / 3);
|
31
31
|
x = r * Math.cos(θ), y = r * Math.sin(θ);
|
@@ -54,7 +54,7 @@ function berghausProjection() {
|
|
54
54
|
p.rotate(rotate);
|
55
55
|
rotateStream.sphere = function() {
|
56
56
|
sphereStream.polygonStart(), sphereStream.lineStart();
|
57
|
-
var ε = 1e-
|
57
|
+
var ε = 1e-2;
|
58
58
|
for (var i = 0, δ = 360 / n, φ = 90 - 180 / n; i < n; ++i, φ -= δ) {
|
59
59
|
sphereStream.point(180, 0);
|
60
60
|
if (φ < -90) {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import "projection";
|
2
|
+
|
3
|
+
function gallStereographic(λ, φ) {
|
4
|
+
return [
|
5
|
+
λ * Math.SQRT1_2,
|
6
|
+
(1 + Math.SQRT1_2) * Math.tan(φ / 2)
|
7
|
+
];
|
8
|
+
}
|
9
|
+
|
10
|
+
gallStereographic.invert = function(x, y) {
|
11
|
+
return [
|
12
|
+
x * Math.SQRT2,
|
13
|
+
Math.atan(y / (1 + Math.SQRT1_2)) * 2
|
14
|
+
];
|
15
|
+
};
|
16
|
+
|
17
|
+
(d3.geo.gallStereographic = function() {
|
18
|
+
return projection(gallStereographic);
|
19
|
+
}).raw = gallStereographic;
|
@@ -9,9 +9,6 @@ import "boggs";
|
|
9
9
|
import "bonne";
|
10
10
|
import "bromley";
|
11
11
|
import "collignon";
|
12
|
-
import "conic-conformal";
|
13
|
-
import "conic-equal-area";
|
14
|
-
import "conic-equidistant";
|
15
12
|
import "craig";
|
16
13
|
import "craster";
|
17
14
|
import "cylindrical-equal-area";
|
@@ -23,6 +20,7 @@ import "eckert5";
|
|
23
20
|
import "eckert6";
|
24
21
|
import "eisenlohr";
|
25
22
|
import "fahey";
|
23
|
+
import "gall-stereographic";
|
26
24
|
import "gringorten";
|
27
25
|
import "guyou";
|
28
26
|
import "hammer-retroazimuthal";
|
@@ -53,7 +51,6 @@ import "satellite";
|
|
53
51
|
import "sinusoidal";
|
54
52
|
import "sinu-mollweide";
|
55
53
|
import "times";
|
56
|
-
import "transverse-mercator";
|
57
54
|
import "two-point-azimuthal";
|
58
55
|
import "two-point-equidistant";
|
59
56
|
import "van-der-grinten";
|
@@ -32,7 +32,7 @@ d3.geo.interrupt = function(project) {
|
|
32
32
|
return [
|
33
33
|
[lobe[0][0] * 180 / π, lobe[0][1] * 180 / π],
|
34
34
|
[lobe[1][0] * 180 / π, lobe[1][1] * 180 / π],
|
35
|
-
[lobe[2][0] * 180 / π, lobe[2][1] * 180 / π]
|
35
|
+
[lobe[2][0] * 180 / π, lobe[2][1] * 180 / π]
|
36
36
|
];
|
37
37
|
});
|
38
38
|
});
|
@@ -4,8 +4,8 @@ An interpolator for zooming and panning between two views of a two-dimensional p
|
|
4
4
|
|
5
5
|
Demo: <http://bl.ocks.org/3828981>
|
6
6
|
|
7
|
-
<a name="interpolateZoom" href="#interpolateZoom">#</a> d3
|
7
|
+
<a name="interpolateZoom" href="#interpolateZoom">#</a> d3.<b>interpolateZoom</b>(<i>start</i>, <i>end</i>)
|
8
8
|
|
9
9
|
Returns an [interpolator](https://github.com/mbostock/d3/wiki/Transitions#wiki-_interpolate) between the two points *start* and *end*. Each point should be defined as an array of three numbers in world coordinates: *ux*, *uy* and *w*. The first two coordinates *ux*, *uy* are the center of the viewport. The last coordinate *w* is the size of the viewport.
|
10
10
|
|
11
|
-
The returned interpolator also has a *duration* property which encodes the recommended transition duration in milliseconds. This duration is based on the path length of the curved trajectory through *u,w* space. If you want to a slower or faster transition, feel free to multiply this by an arbitrary scale factor (
|
11
|
+
The returned interpolator also has a *duration* property which encodes the recommended transition duration in milliseconds. This duration is based on the path length of the curved trajectory through *u,w* space. If you want to a slower or faster transition, feel free to multiply this by an arbitrary scale factor (<i>V</i> as described in the original paper).
|
@@ -24,7 +24,7 @@ suite.addBatch({
|
|
24
24
|
"can be modified via array methods, albeit unsafely": function(urlencode) {
|
25
25
|
var u = urlencode("foo", 1).and("bar", 2).and("baz", 3);
|
26
26
|
u.splice(1, 1);
|
27
|
-
u.push("unsafe=true")
|
27
|
+
u.push("unsafe=true");
|
28
28
|
u.sort();
|
29
29
|
assert.strictEqual(u + "", "baz=3&foo=1&unsafe=true");
|
30
30
|
},
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: d3js-plugins-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Gorodetsky
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
huM3+aQFhf3ji44P0XipQ3GsiF39ZRDA3MUe8jeuiHoq1vbmLrw0muYOH9jlTmCN
|
30
30
|
soY91zInZJIkyNXJub8NKDuoUBKLvE5Ij89OFA==
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-03-
|
32
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: railties
|
@@ -94,9 +94,6 @@ files:
|
|
94
94
|
- vendor/assets/javascripts/d3/plugins/geo/projection/bonne.js
|
95
95
|
- vendor/assets/javascripts/d3/plugins/geo/projection/bromley.js
|
96
96
|
- vendor/assets/javascripts/d3/plugins/geo/projection/collignon.js
|
97
|
-
- vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js
|
98
|
-
- vendor/assets/javascripts/d3/plugins/geo/projection/conic-equal-area.js
|
99
|
-
- vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js
|
100
97
|
- vendor/assets/javascripts/d3/plugins/geo/projection/craig.js
|
101
98
|
- vendor/assets/javascripts/d3/plugins/geo/projection/craster.js
|
102
99
|
- vendor/assets/javascripts/d3/plugins/geo/projection/cylindrical-equal-area.js
|
@@ -110,6 +107,7 @@ files:
|
|
110
107
|
- vendor/assets/javascripts/d3/plugins/geo/projection/elliptic.js
|
111
108
|
- vendor/assets/javascripts/d3/plugins/geo/projection/end.js
|
112
109
|
- vendor/assets/javascripts/d3/plugins/geo/projection/fahey.js
|
110
|
+
- vendor/assets/javascripts/d3/plugins/geo/projection/gall-stereographic.js
|
113
111
|
- vendor/assets/javascripts/d3/plugins/geo/projection/gringorten.js
|
114
112
|
- vendor/assets/javascripts/d3/plugins/geo/projection/guyou.js
|
115
113
|
- vendor/assets/javascripts/d3/plugins/geo/projection/hammer-retroazimuthal.js
|
@@ -186,7 +184,6 @@ files:
|
|
186
184
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/rectangular-polyconic-test.js
|
187
185
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/robinson-test.js
|
188
186
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/times-test.js
|
189
|
-
- vendor/assets/javascripts/d3/plugins/geo/projection/test/transverse-mercator-test.js
|
190
187
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/two-point-azimuthal-test.js
|
191
188
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/two-point-equidistant-test.js
|
192
189
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/van-der-grinten2-test.js
|
@@ -196,7 +193,6 @@ files:
|
|
196
193
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/wiechel-test.js
|
197
194
|
- vendor/assets/javascripts/d3/plugins/geo/projection/test/winkel3-test.js
|
198
195
|
- vendor/assets/javascripts/d3/plugins/geo/projection/times.js
|
199
|
-
- vendor/assets/javascripts/d3/plugins/geo/projection/transverse-mercator.js
|
200
196
|
- vendor/assets/javascripts/d3/plugins/geo/projection/two-point-azimuthal.js
|
201
197
|
- vendor/assets/javascripts/d3/plugins/geo/projection/two-point-equidistant.js
|
202
198
|
- vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten.js
|
@@ -242,8 +238,6 @@ files:
|
|
242
238
|
- vendor/assets/javascripts/d3/plugins/sankey/README.md
|
243
239
|
- vendor/assets/javascripts/d3/plugins/sankey/sankey.js
|
244
240
|
- vendor/assets/javascripts/d3/plugins/simplify/README.md
|
245
|
-
- vendor/assets/javascripts/d3/plugins/simplify/simplify-test.js
|
246
|
-
- vendor/assets/javascripts/d3/plugins/simplify/simplify.js
|
247
241
|
- vendor/assets/javascripts/d3/plugins/superformula/superformula.js
|
248
242
|
- vendor/assets/javascripts/d3/plugins/urlencode/urlencode-test.js
|
249
243
|
- vendor/assets/javascripts/d3/plugins/urlencode/urlencode.js
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import "projection";
|
2
|
-
import "parallel2";
|
3
|
-
|
4
|
-
function conicConformal(φ0, φ1) {
|
5
|
-
var cosφ0 = Math.cos(φ0),
|
6
|
-
t = function(φ) { return Math.tan(π / 4 + φ / 2); },
|
7
|
-
n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)),
|
8
|
-
F = cosφ0 * Math.pow(t(φ0), n) / n;
|
9
|
-
|
10
|
-
if (!n) return conicConformalMercator;
|
11
|
-
|
12
|
-
function forward(λ, φ) {
|
13
|
-
var ρ = Math.abs(Math.abs(φ) - π / 2) < ε ? 0 : F / Math.pow(t(φ), n);
|
14
|
-
return [
|
15
|
-
ρ * Math.sin(n * λ),
|
16
|
-
F - ρ * Math.cos(n * λ)
|
17
|
-
];
|
18
|
-
}
|
19
|
-
|
20
|
-
forward.invert = function(x, y) {
|
21
|
-
var ρ0_y = F - y,
|
22
|
-
ρ = sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);
|
23
|
-
return [
|
24
|
-
Math.atan2(x, ρ0_y) / n,
|
25
|
-
2 * Math.atan(Math.pow(F / ρ, 1 / n)) - π / 2
|
26
|
-
];
|
27
|
-
};
|
28
|
-
|
29
|
-
return forward;
|
30
|
-
}
|
31
|
-
|
32
|
-
function conicConformalMercator(λ, φ) {
|
33
|
-
return [λ, Math.log(Math.tan(π / 4 + φ / 2))];
|
34
|
-
}
|
35
|
-
|
36
|
-
conicConformalMercator.invert = function(x, y) {
|
37
|
-
return [x, 2 * Math.atan(Math.exp(y)) - π / 2];
|
38
|
-
};
|
39
|
-
|
40
|
-
(d3.geo.conicConformal = function() { return parallel2Projection(conicConformal); }).raw = conicConformal;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import "projection";
|
2
|
-
import "parallel2";
|
3
|
-
|
4
|
-
function conicEqualArea(φ0, φ1) {
|
5
|
-
var sinφ0 = Math.sin(φ0),
|
6
|
-
n = (sinφ0 + Math.sin(φ1)) / 2,
|
7
|
-
C = 1 + sinφ0 * (2 * n - sinφ0),
|
8
|
-
ρ0 = Math.sqrt(C) / n;
|
9
|
-
|
10
|
-
function conicEqualArea(λ, φ) {
|
11
|
-
var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
|
12
|
-
return [
|
13
|
-
ρ * Math.sin(λ *= n),
|
14
|
-
ρ0 - ρ * Math.cos(λ)
|
15
|
-
];
|
16
|
-
}
|
17
|
-
|
18
|
-
conicEqualArea.invert = function(x, y) {
|
19
|
-
var ρ0_y = ρ0 - y;
|
20
|
-
return [
|
21
|
-
Math.atan2(x, ρ0_y) / n,
|
22
|
-
Math.asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n))
|
23
|
-
];
|
24
|
-
};
|
25
|
-
|
26
|
-
return albers;
|
27
|
-
}
|
28
|
-
|
29
|
-
(d3.geo.conicEqualArea = function() { return parallel2Projection(conicEqualArea); }).raw = conicEqualArea;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import "projection";
|
2
|
-
import "parallel2";
|
3
|
-
|
4
|
-
function conicEquidistant(φ0, φ1) {
|
5
|
-
var cosφ0 = Math.cos(φ0),
|
6
|
-
n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0),
|
7
|
-
G = cosφ0 / n + φ0;
|
8
|
-
|
9
|
-
if (Math.abs(n) < ε) return d3.geo.equirectangular.raw;
|
10
|
-
|
11
|
-
function forward(λ, φ) {
|
12
|
-
var ρ = G - φ;
|
13
|
-
return [
|
14
|
-
ρ * Math.sin(n * λ),
|
15
|
-
G - ρ * Math.cos(n * λ)
|
16
|
-
];
|
17
|
-
}
|
18
|
-
|
19
|
-
forward.invert = function(x, y) {
|
20
|
-
var ρ0_y = G - y;
|
21
|
-
return [
|
22
|
-
Math.atan2(x, ρ0_y) / n,
|
23
|
-
G - sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y)
|
24
|
-
];
|
25
|
-
};
|
26
|
-
|
27
|
-
return forward;
|
28
|
-
}
|
29
|
-
|
30
|
-
(d3.geo.conicEquidistant = function() { return parallel2Projection(conicEquidistant); }).raw = conicEquidistant;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
var vows = require("vows"),
|
2
|
-
assert = require("./assert"),
|
3
|
-
load = require("./load");
|
4
|
-
|
5
|
-
var suite = vows.describe("d3.geo.transverseMercator");
|
6
|
-
|
7
|
-
suite.addBatch({
|
8
|
-
"transverseMercator": {
|
9
|
-
topic: load("transverse-mercator"),
|
10
|
-
"default": {
|
11
|
-
topic: function(geo) { return geo.transverseMercator(); },
|
12
|
-
"projections and inverse projections": function(transverseMercator) {
|
13
|
-
assert.equalInverse(transverseMercator, [ 0, 0], [480, 250]);
|
14
|
-
assert.equalInverse(transverseMercator, [ 0, -45], [480, 367.809724]);
|
15
|
-
assert.equalInverse(transverseMercator, [ 0, 45], [480, 132.190275]);
|
16
|
-
assert.equalInverse(transverseMercator, [-90, 0], [-Infinity, 250]);
|
17
|
-
assert.equalInverse(transverseMercator, [ 90, 0], [ Infinity, 250]);
|
18
|
-
assert.equalInverse(transverseMercator, [-80, 15], [203.284019, 100.632486]);
|
19
|
-
assert.equalInverse(transverseMercator, [ 1, 1], [482.617727, 247.381607]);
|
20
|
-
assert.equalInverse(transverseMercator, [ 15, 45], [507.764703, 129.590678]);
|
21
|
-
assert.equalInverse(transverseMercator, [ 0, 90], [480, 14.380550]);
|
22
|
-
assert.equalInverse(transverseMercator, [ 0, -90], [480, 485.619449]);
|
23
|
-
assert.equalInverse(transverseMercator, [180, 0], [480, -221.238898]);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
suite.export(module);
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import "projection";
|
2
|
-
import "hyperbolic";
|
3
|
-
|
4
|
-
function transverseMercator(λ, φ) {
|
5
|
-
var B = Math.cos(φ) * Math.sin(λ);
|
6
|
-
return [
|
7
|
-
.5 * Math.log((1 + B) / (1 - B)),
|
8
|
-
Math.atan2(Math.tan(φ), Math.cos(λ))
|
9
|
-
];
|
10
|
-
}
|
11
|
-
|
12
|
-
transverseMercator.invert = function(x, y) {
|
13
|
-
return [
|
14
|
-
Math.atan2(sinh(x), Math.cos(y)),
|
15
|
-
asin(Math.sin(y) / cosh(x))
|
16
|
-
];
|
17
|
-
};
|
18
|
-
|
19
|
-
(d3.geo.transverseMercator = function() { return projection(transverseMercator); }).raw = transverseMercator;
|
@@ -1,193 +0,0 @@
|
|
1
|
-
global.d3 = require("d3");
|
2
|
-
require("./simplify");
|
3
|
-
|
4
|
-
var vows = require("vows"),
|
5
|
-
assert = require("assert");
|
6
|
-
|
7
|
-
var suite = vows.describe("d3.simplify");
|
8
|
-
|
9
|
-
suite.addBatch({
|
10
|
-
"d3.simplify": {
|
11
|
-
"area(0)": {
|
12
|
-
topic: function() {
|
13
|
-
var simplify = d3.simplify().area(0).projection(d3.geo.equirectangular());
|
14
|
-
return function(d) { return simplify(simplify.project(d)); };
|
15
|
-
},
|
16
|
-
"LineString": {
|
17
|
-
"2 points": function(simplify) {
|
18
|
-
var p = {type: "LineString", coordinates: [[0, 0], [1, 1]]};
|
19
|
-
assert.deepEqual(simplify(p), p);
|
20
|
-
},
|
21
|
-
"9 points": function(simplify) {
|
22
|
-
var p = {type: "LineString", coordinates: [[0, 0], [0, 5], [0, 10], [5, 10], [10, 10], [10, 5], [10, 0], [5, 0], [0, 0]]};
|
23
|
-
assert.deepEqual(simplify(p), p);
|
24
|
-
}
|
25
|
-
},
|
26
|
-
"FeatureCollection": {
|
27
|
-
"preserves properties": function(simplify) {
|
28
|
-
var p = {type: "FeatureCollection", features: [], id: "test"};
|
29
|
-
assert.deepEqual(simplify(p), p);
|
30
|
-
}
|
31
|
-
},
|
32
|
-
"Feature": {
|
33
|
-
"preserves properties": function(simplify) {
|
34
|
-
var p = {type: "Feature", geometry: {type: "GeometryCollection", geometries: []}, properties: {name: "test"}, id: "test"};
|
35
|
-
assert.deepEqual(simplify(p), p);
|
36
|
-
}
|
37
|
-
},
|
38
|
-
"GeometryCollection": {
|
39
|
-
"preserves properties": function(simplify) {
|
40
|
-
var p = {type: "GeometryCollection", geometries: [], id: "test"};
|
41
|
-
assert.deepEqual(simplify(p), p);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
},
|
45
|
-
"area(10)": {
|
46
|
-
topic: function() {
|
47
|
-
var simplify = d3.simplify().area(10).projection(d3.geo.equirectangular());
|
48
|
-
return function(d) { return simplify(simplify.project(d)); };
|
49
|
-
},
|
50
|
-
"LineString": {
|
51
|
-
"2 points": function(simplify) {
|
52
|
-
var p = {type: "LineString", coordinates: [[0, 0], [1, 1]]};
|
53
|
-
assert.deepEqual(simplify(p).coordinates, []);
|
54
|
-
},
|
55
|
-
"3 collinear points": function(simplify) {
|
56
|
-
var p = {type: "LineString", coordinates: [[0, 0], [1, 1], [45, 45]]};
|
57
|
-
assert.deepEqual(simplify(p).coordinates, []);
|
58
|
-
},
|
59
|
-
"3 points": function(simplify) {
|
60
|
-
var p = {type: "LineString", coordinates: [[0, 0], [10, 10], [0, 20]]};
|
61
|
-
assert.deepEqual(simplify(p), p);
|
62
|
-
}
|
63
|
-
},
|
64
|
-
"MultiLineString": {
|
65
|
-
"1 line": {
|
66
|
-
"3 collinear points": function(simplify) {
|
67
|
-
var p = {type: "MultiLineString", coordinates: [[[0, 0], [1, 1], [2, 2]]]};
|
68
|
-
assert.deepEqual(simplify(p).coordinates, []);
|
69
|
-
}
|
70
|
-
},
|
71
|
-
"2 lines": function(simplify) {
|
72
|
-
var p = {type: "MultiLineString", coordinates: [[[0, 0], [1, 1], [0, 2]], [[10, 0], [15, 15], [20, 0]]]};
|
73
|
-
assert.deepEqual(simplify(p).coordinates, [p.coordinates[1]]);
|
74
|
-
}
|
75
|
-
},
|
76
|
-
"Polygon": {
|
77
|
-
"empty result": function(simplify) {
|
78
|
-
var p = {type: "Polygon", coordinates: [[[0, 0], [1, 1], [1, 0], [0, 0]]]};
|
79
|
-
assert.deepEqual(simplify(p).coordinates, []);
|
80
|
-
},
|
81
|
-
"1 ring": function(simplify) {
|
82
|
-
// TODO verify that LinearRings all have >= 4 points?
|
83
|
-
var p = {type: "Polygon", coordinates: [[[0, 0], [10, 10], [10, 0], [0, 0]]]};
|
84
|
-
assert.deepEqual(simplify(p), p);
|
85
|
-
}
|
86
|
-
},
|
87
|
-
"MultiPolygon": {
|
88
|
-
"empty result": function(simplify) {
|
89
|
-
var p = {type: "MultiPolygon", coordinates: [[[[0, 0], [1, 1], [1, 0], [0, 0]]]]};
|
90
|
-
assert.deepEqual(simplify(p).coordinates, []);
|
91
|
-
},
|
92
|
-
"1 polygon": function(simplify) {
|
93
|
-
var p = {type: "MultiPolygon", coordinates: [[[[0, 0], [10, 10], [10, 0], [0, 0]]]]};
|
94
|
-
assert.deepEqual(simplify(p), p);
|
95
|
-
}
|
96
|
-
},
|
97
|
-
"GeometryCollection": {
|
98
|
-
"empty result": function(simplify) {
|
99
|
-
var p = {type: "GeometryCollection", geometries: [{type: "Polygon", coordinates: [[[0, 0], [1, 1], [1, 0], [0, 0]]]}]};
|
100
|
-
assert.deepEqual(simplify(p).geometries, []);
|
101
|
-
},
|
102
|
-
"1 polygon": function(simplify) {
|
103
|
-
var p = {type: "GeometryCollection", geometries: [{type: "MultiPolygon", coordinates: [[[[0, 0], [10, 10], [10, 0], [0, 0]]]]}]};
|
104
|
-
assert.deepEqual(simplify(p), p);
|
105
|
-
}
|
106
|
-
},
|
107
|
-
"FeatureCollection": {
|
108
|
-
"empty result": function(simplify) {
|
109
|
-
var p = {type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Polygon", coordinates: [[[0, 0], [1, 1], [1, 0], [0, 0]]]}}]};
|
110
|
-
assert.deepEqual(simplify(p).features, []);
|
111
|
-
},
|
112
|
-
"1 polygon": function(simplify) {
|
113
|
-
var p = {type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "MultiPolygon", coordinates: [[[[0, 0], [10, 10], [10, 0], [0, 0]]]]}}]};
|
114
|
-
assert.deepEqual(simplify(p), p);
|
115
|
-
}
|
116
|
-
}
|
117
|
-
},
|
118
|
-
"topology": {
|
119
|
-
topic: function() {
|
120
|
-
var simplify = d3.simplify().topology(true).area(10).projection(d3.geo.equirectangular());
|
121
|
-
return function(d) { return simplify(simplify.project(d)); };
|
122
|
-
},
|
123
|
-
"Polygon": {
|
124
|
-
"preserves topology": function(simplify) {
|
125
|
-
assert.inDelta(simplify({
|
126
|
-
type: "GeometryCollection",
|
127
|
-
geometries: [
|
128
|
-
{type: "Polygon", coordinates: [octagon(-2)]},
|
129
|
-
{type: "Polygon", coordinates: [octagon(2)]}
|
130
|
-
]
|
131
|
-
}).geometries.map(function(d) { return d.coordinates; }), [[[
|
132
|
-
[474.444444, 250, 19.290123],
|
133
|
-
[475.833333, 247.222222, 13.503086],
|
134
|
-
[480, 248.611111, 19.290123],
|
135
|
-
[480, 250, 19.290123],
|
136
|
-
[480, 251.388888, 19.290123],
|
137
|
-
[475.833333, 252.777777, 13.503086],
|
138
|
-
[474.444444, 250, 19.290123]]], [[
|
139
|
-
[480, 250, 19.290123],
|
140
|
-
[480, 248.611111, 19.290123],
|
141
|
-
[485.555555, 248.611111, 19.290123],
|
142
|
-
[484.166666, 252.777777, 19.290123],
|
143
|
-
[480, 251.388888, 19.290123],
|
144
|
-
[480, 250, 19.290123]]]
|
145
|
-
], 1e-6);
|
146
|
-
},
|
147
|
-
"doesn't increase effective area of endpoints unless they touch another line": function(simplify) {
|
148
|
-
assert.inDelta(simplify({type: "Polygon", coordinates: [octagon()]}).coordinates, [[
|
149
|
-
[477.222222, 250, 21.219135],
|
150
|
-
[478.611111, 247.222222, 13.503086],
|
151
|
-
[482.777777, 248.611111, 21.219135],
|
152
|
-
[481.388888, 252.777777, 21.219135],
|
153
|
-
[477.222222, 250, 21.219135]
|
154
|
-
]], 1e-6);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
}
|
158
|
-
}
|
159
|
-
});
|
160
|
-
|
161
|
-
suite.export(module);
|
162
|
-
|
163
|
-
assert.inDelta = function(actual, expected, delta, message) {
|
164
|
-
if (!inDelta(actual, expected, delta)) {
|
165
|
-
assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta + "* of {expected}", null, assert.inDelta);
|
166
|
-
}
|
167
|
-
};
|
168
|
-
|
169
|
-
function inDelta(actual, expected, delta) {
|
170
|
-
return (Array.isArray(expected) ? inDeltaArray : inDeltaNumber)(actual, expected, delta);
|
171
|
-
}
|
172
|
-
|
173
|
-
function inDeltaArray(actual, expected, delta) {
|
174
|
-
var n = expected.length, i = -1;
|
175
|
-
if (actual.length !== n) return false;
|
176
|
-
while (++i < n) if (!inDelta(actual[i], expected[i], delta)) return false;
|
177
|
-
return true;
|
178
|
-
}
|
179
|
-
|
180
|
-
function inDeltaNumber(actual, expected, delta) {
|
181
|
-
return actual >= expected - delta && actual <= expected + delta;
|
182
|
-
}
|
183
|
-
|
184
|
-
function octagon(dx) {
|
185
|
-
dx = dx || 0;
|
186
|
-
return [
|
187
|
-
[-2, 0], [-2, 1], [-1, 2], [0, 2], [ 1, 2], [ 2, 1],
|
188
|
-
[ 2, 0], [ 2, -1], [ 1, -2], [0, -2], [-1, -2], [-2, -1],
|
189
|
-
[-2, 0]
|
190
|
-
].map(function(point) {
|
191
|
-
return [point[0] + dx, point[1]];
|
192
|
-
});
|
193
|
-
}
|
@@ -1,446 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
|
3
|
-
d3.simplify = function() {
|
4
|
-
var projection = d3.geo.albers(),
|
5
|
-
triangulateLineString = triangulateLineStringSimple,
|
6
|
-
heap,
|
7
|
-
minArea = 3,
|
8
|
-
topology = false,
|
9
|
-
ringId,
|
10
|
-
id,
|
11
|
-
idByRings,
|
12
|
-
idByPoint,
|
13
|
-
ringsByPoint,
|
14
|
-
sharedPoints,
|
15
|
-
lastRingByPoint,
|
16
|
-
isShared,
|
17
|
-
graph;
|
18
|
-
|
19
|
-
var projectCoordinates = {
|
20
|
-
MultiPolygon: projectMultiPolygon,
|
21
|
-
Polygon: projectPolygon,
|
22
|
-
MultiLineString: projectPolygon,
|
23
|
-
LineString: projectLineString
|
24
|
-
};
|
25
|
-
|
26
|
-
var triangulateCoordinates = {
|
27
|
-
MultiPolygon: triangulateMultiPolygon,
|
28
|
-
Polygon: triangulatePolygon,
|
29
|
-
MultiLineString: triangulatePolygon,
|
30
|
-
LineString: triangulateLineString
|
31
|
-
};
|
32
|
-
|
33
|
-
var simplifyCoordinates = {
|
34
|
-
MultiPolygon: simplifyMultiPolygon,
|
35
|
-
Polygon: simplifyPolygon,
|
36
|
-
MultiLineString: simplifyPolygon,
|
37
|
-
LineString: simplifyLineString
|
38
|
-
};
|
39
|
-
|
40
|
-
function simplify(object) {
|
41
|
-
var type = object.type;
|
42
|
-
if (type === "FeatureCollection") {
|
43
|
-
object = copy(object);
|
44
|
-
object.features = object.features.map(simplifyFeature).filter(nonemptyFeature);
|
45
|
-
return object;
|
46
|
-
}
|
47
|
-
return (type === "Feature" ? simplifyFeature : simplifyGeometry)(object);
|
48
|
-
}
|
49
|
-
|
50
|
-
simplify.project = function(feature) {
|
51
|
-
var maxArea = 0,
|
52
|
-
maxAreas = {},
|
53
|
-
triangle;
|
54
|
-
|
55
|
-
heap = minHeap();
|
56
|
-
|
57
|
-
if (topology) {
|
58
|
-
id = 0;
|
59
|
-
idByRings = {};
|
60
|
-
ringsByPoint = {};
|
61
|
-
idByPoint = {};
|
62
|
-
sharedPoints = {};
|
63
|
-
lastRingByPoint = {};
|
64
|
-
isShared = {};
|
65
|
-
graph = {};
|
66
|
-
triangulateTopology(feature);
|
67
|
-
} else {
|
68
|
-
triangulateSimple(feature);
|
69
|
-
}
|
70
|
-
|
71
|
-
while (triangle = heap.pop()) {
|
72
|
-
// If the area of the current point is less than that of the previous point
|
73
|
-
// to be eliminated, use the latter’s area instead. This ensures that the
|
74
|
-
// current point cannot be eliminated without eliminating previously-
|
75
|
-
// eliminated points.
|
76
|
-
if (triangle[1][2] < maxArea) triangle[1][2] = maxArea;
|
77
|
-
else maxArea = triangle[1][2];
|
78
|
-
|
79
|
-
if (triangle.previous) {
|
80
|
-
triangle.previous.next = triangle.next;
|
81
|
-
triangle.previous[2] = triangle[2];
|
82
|
-
update(triangle.previous);
|
83
|
-
} else if (topology) {
|
84
|
-
maxAreas[triangle.ring] = triangle[1][2];
|
85
|
-
} else {
|
86
|
-
triangle[0][2] = triangle[1][2];
|
87
|
-
}
|
88
|
-
|
89
|
-
if (triangle.next) {
|
90
|
-
triangle.next.previous = triangle.previous;
|
91
|
-
triangle.next[0] = triangle[0];
|
92
|
-
update(triangle.next);
|
93
|
-
} else if (topology) {
|
94
|
-
maxAreas[triangle.ring] = triangle[1][2];
|
95
|
-
} else {
|
96
|
-
triangle[2][2] = triangle[1][2];
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
function update(triangle) {
|
101
|
-
heap.remove(triangle);
|
102
|
-
triangle[1][2] = area(triangle);
|
103
|
-
heap.push(triangle);
|
104
|
-
}
|
105
|
-
|
106
|
-
if (topology) {
|
107
|
-
var seen = {},
|
108
|
-
max,
|
109
|
-
m,
|
110
|
-
c;
|
111
|
-
for (var key in graph) {
|
112
|
-
if (seen.hasOwnProperty(key)) continue;
|
113
|
-
max = 0;
|
114
|
-
for (var k in (c = components(graph, key))) if ((m = maxAreas[k]) > max) max = m;
|
115
|
-
for (var k in c) maxAreas[k] = max, seen[k] = 1;
|
116
|
-
}
|
117
|
-
|
118
|
-
for (var key in sharedPoints) {
|
119
|
-
maxArea = maxAreas[ringsByPoint[key][0]];
|
120
|
-
sharedPoints[key].forEach(function(point) { point[2] = maxArea; });
|
121
|
-
}
|
122
|
-
idByPoint = idByRings = ringsByPoint = sharedPoints = isShared = lastRingByPoint = graph = null;
|
123
|
-
}
|
124
|
-
|
125
|
-
heap = null;
|
126
|
-
return feature;
|
127
|
-
};
|
128
|
-
|
129
|
-
function components(graph, source) {
|
130
|
-
var seen = {},
|
131
|
-
nextLevel = {},
|
132
|
-
thisLevel,
|
133
|
-
empty;
|
134
|
-
nextLevel[source] = 1;
|
135
|
-
while (1) {
|
136
|
-
empty = true;
|
137
|
-
for (var k in nextLevel) empty = false;
|
138
|
-
if (empty) break;
|
139
|
-
thisLevel = nextLevel;
|
140
|
-
nextLevel = {};
|
141
|
-
for (var v in thisLevel) {
|
142
|
-
if (seen.hasOwnProperty(v)) continue;
|
143
|
-
seen[v] = 1;
|
144
|
-
var neighbors = graph[v];
|
145
|
-
for (var k in neighbors) nextLevel[k] = neighbors[k];
|
146
|
-
}
|
147
|
-
}
|
148
|
-
return seen;
|
149
|
-
}
|
150
|
-
|
151
|
-
function projectFeature(feature) {
|
152
|
-
projectGeometry(feature.geometry);
|
153
|
-
}
|
154
|
-
|
155
|
-
function projectGeometry(geometry) {
|
156
|
-
var type = geometry.type;
|
157
|
-
if (type === "GeometryCollection") geometry.geometries.forEach(projectGeometry);
|
158
|
-
else geometry.coordinates = projectCoordinates[type](geometry.coordinates);
|
159
|
-
}
|
160
|
-
|
161
|
-
function projectMultiPolygon(multiPolygon) {
|
162
|
-
return multiPolygon.map(projectPolygon);
|
163
|
-
}
|
164
|
-
|
165
|
-
function projectPolygon(polygon) {
|
166
|
-
return polygon.map(projectLineString);
|
167
|
-
}
|
168
|
-
|
169
|
-
function projectLineString(lineString) {
|
170
|
-
++ringId;
|
171
|
-
return lineString.map(projectPoint);
|
172
|
-
}
|
173
|
-
|
174
|
-
function projectPoint(point) {
|
175
|
-
var pointKey = (point = projection(point))[0] + "," + point[1],
|
176
|
-
key = (idByPoint.hasOwnProperty(pointKey) ? idByPoint[pointKey] + ":" : "") + ringId;
|
177
|
-
idByPoint[pointKey] = idByRings.hasOwnProperty(key)
|
178
|
-
? idByRings[key]
|
179
|
-
: idByRings[key] = ++id;
|
180
|
-
if (lastRingByPoint.hasOwnProperty(pointKey) && lastRingByPoint[pointKey] !== ringId) {
|
181
|
-
isShared[pointKey] = 1;
|
182
|
-
}
|
183
|
-
lastRingByPoint[pointKey] = ringId;
|
184
|
-
return point;
|
185
|
-
}
|
186
|
-
|
187
|
-
function triangulateLineStringTopology(lineString) {
|
188
|
-
++ringId;
|
189
|
-
var n = lineString.length - 1,
|
190
|
-
triangle0,
|
191
|
-
triangle,
|
192
|
-
a = lineString[0],
|
193
|
-
b = lineString[1],
|
194
|
-
c,
|
195
|
-
key0,
|
196
|
-
key,
|
197
|
-
idA = idByPoint[a[0] + "," + a[1]],
|
198
|
-
idB = idByPoint[key0 = b[0] + "," + b[1]],
|
199
|
-
idC;
|
200
|
-
|
201
|
-
lineString[0][2] = lineString[n][2] = 0;
|
202
|
-
if (n < 2) return lineString;
|
203
|
-
|
204
|
-
graph[ringId] = {};
|
205
|
-
|
206
|
-
addSharedPoint(a);
|
207
|
-
for (var i = 2; i <= n; ++i, a = b, b = c, idA = idB, idB = idC, key0 = key) {
|
208
|
-
c = lineString[i];
|
209
|
-
idC = idByPoint[key = c[0] + "," + c[1]];
|
210
|
-
if (idA === idB && idB === idC || !isShared.hasOwnProperty(key0)) {
|
211
|
-
triangle = [a, b, c];
|
212
|
-
triangle.ring = ringId;
|
213
|
-
b[2] = area(triangle);
|
214
|
-
heap.push(triangle);
|
215
|
-
if (triangle0) (triangle.previous = triangle0).next = triangle;
|
216
|
-
triangle0 = triangle;
|
217
|
-
} else {
|
218
|
-
addSharedPoint(b);
|
219
|
-
triangle0 = null;
|
220
|
-
}
|
221
|
-
}
|
222
|
-
addSharedPoint(b);
|
223
|
-
|
224
|
-
function addSharedPoint(point) {
|
225
|
-
var key = point[0] + "," + point[1],
|
226
|
-
rings = ringsByPoint.hasOwnProperty(key) ? ringsByPoint[key] : (ringsByPoint[key] = []);
|
227
|
-
rings.forEach(function(ring) {
|
228
|
-
graph[ring][ringId] = graph[ringId][ring] = 1;
|
229
|
-
});
|
230
|
-
rings.push(ringId);
|
231
|
-
if (sharedPoints.hasOwnProperty(key)) sharedPoints[key].push(point);
|
232
|
-
else sharedPoints[key] = [point];
|
233
|
-
}
|
234
|
-
|
235
|
-
return lineString;
|
236
|
-
}
|
237
|
-
|
238
|
-
// Project and triangulate.
|
239
|
-
function triangulateLineStringSimple(lineString) {
|
240
|
-
var points = lineString.map(projection),
|
241
|
-
n = points.length - 1,
|
242
|
-
triangle0,
|
243
|
-
triangle,
|
244
|
-
a = points[0],
|
245
|
-
b = points[1],
|
246
|
-
c;
|
247
|
-
|
248
|
-
points[0][2] = points[n][2] = 0;
|
249
|
-
|
250
|
-
for (var i = 2; i <= n; ++i) {
|
251
|
-
triangle = [a, b, c = points[i]];
|
252
|
-
b[2] = area(triangle);
|
253
|
-
heap.push(triangle);
|
254
|
-
if (triangle0) (triangle.previous = triangle0).next = triangle;
|
255
|
-
triangle0 = triangle;
|
256
|
-
a = b;
|
257
|
-
b = c;
|
258
|
-
}
|
259
|
-
|
260
|
-
return points;
|
261
|
-
}
|
262
|
-
|
263
|
-
function triangulateSimple(object) {
|
264
|
-
var type = object.type;
|
265
|
-
if (type === "FeatureCollection") object.features.forEach(triangulateFeature);
|
266
|
-
else (type === "Feature" ? triangulateFeature : triangulateGeometry)(object);
|
267
|
-
}
|
268
|
-
|
269
|
-
function triangulateTopology(object) {
|
270
|
-
var type = object.type;
|
271
|
-
ringId = 0;
|
272
|
-
if (type === "FeatureCollection") {
|
273
|
-
object.features.forEach(projectFeature);
|
274
|
-
ringId = 0;
|
275
|
-
object.features.forEach(triangulateFeature);
|
276
|
-
} else if (type === "Feature") {
|
277
|
-
projectFeature(object);
|
278
|
-
ringId = 0;
|
279
|
-
triangulateFeature(object);
|
280
|
-
} else {
|
281
|
-
projectGeometry(object);
|
282
|
-
ringId = 0;
|
283
|
-
triangulateGeometry(object);
|
284
|
-
}
|
285
|
-
}
|
286
|
-
|
287
|
-
function triangulateFeature(feature) {
|
288
|
-
triangulateGeometry(feature.geometry);
|
289
|
-
}
|
290
|
-
|
291
|
-
function triangulateGeometry(geometry) {
|
292
|
-
var type = geometry.type;
|
293
|
-
if (type === "GeometryCollection") geometry.geometries.forEach(triangulateGeometry);
|
294
|
-
else geometry.coordinates = triangulateCoordinates[type](geometry.coordinates);
|
295
|
-
}
|
296
|
-
|
297
|
-
function triangulateMultiPolygon(multiPolygon) {
|
298
|
-
return multiPolygon.map(triangulatePolygon);
|
299
|
-
}
|
300
|
-
|
301
|
-
function triangulatePolygon(polygon) {
|
302
|
-
return polygon.map(triangulateLineString);
|
303
|
-
}
|
304
|
-
|
305
|
-
function simplifyFeature(feature) {
|
306
|
-
feature = copy(feature);
|
307
|
-
feature.geometry = simplifyGeometry(feature.geometry);
|
308
|
-
return feature;
|
309
|
-
}
|
310
|
-
|
311
|
-
function simplifyGeometry(geometry) {
|
312
|
-
var type = geometry.type;
|
313
|
-
geometry = copy(geometry);
|
314
|
-
if (type === "GeometryCollection") {
|
315
|
-
geometry.geometries = geometry.geometries.map(simplifyGeometry).filter(nonemptyGeometry);
|
316
|
-
} else {
|
317
|
-
geometry.coordinates = simplifyCoordinates[type](geometry.coordinates);
|
318
|
-
}
|
319
|
-
return geometry;
|
320
|
-
}
|
321
|
-
|
322
|
-
function simplifyMultiPolygon(multiPolygon) {
|
323
|
-
return multiPolygon.map(simplifyPolygon).filter(length);
|
324
|
-
}
|
325
|
-
|
326
|
-
function simplifyPolygon(polygon) {
|
327
|
-
return polygon.map(simplifyLineString).filter(length);
|
328
|
-
}
|
329
|
-
|
330
|
-
function simplifyLineString(lineString) {
|
331
|
-
return lineString.filter(filterLineString);
|
332
|
-
}
|
333
|
-
|
334
|
-
function filterLineString(point) {
|
335
|
-
return point[2] >= minArea;
|
336
|
-
}
|
337
|
-
|
338
|
-
simplify.projection = function(_) {
|
339
|
-
if (!arguments.length) return projection;
|
340
|
-
projection = _;
|
341
|
-
return simplify;
|
342
|
-
};
|
343
|
-
|
344
|
-
simplify.area = function(_) {
|
345
|
-
if (!arguments.length) return minArea;
|
346
|
-
minArea = +_;
|
347
|
-
return simplify;
|
348
|
-
};
|
349
|
-
|
350
|
-
simplify.topology = function(_) {
|
351
|
-
if (!arguments.length) return topology;
|
352
|
-
triangulateCoordinates.LineString =
|
353
|
-
triangulateLineString = (topology = !!_)
|
354
|
-
? triangulateLineStringTopology
|
355
|
-
: triangulateLineStringSimple;
|
356
|
-
return simplify;
|
357
|
-
};
|
358
|
-
|
359
|
-
return simplify;
|
360
|
-
};
|
361
|
-
|
362
|
-
function compare(a, b) {
|
363
|
-
return a[1][2] - b[1][2] || a[1][1] - b[1][1] || a[1][0] - b[1][0];
|
364
|
-
}
|
365
|
-
|
366
|
-
function area(t) {
|
367
|
-
return Math.abs((t[0][0] - t[2][0]) * (t[1][1] - t[0][1]) - (t[0][0] - t[1][0]) * (t[2][1] - t[0][1]));
|
368
|
-
}
|
369
|
-
|
370
|
-
function minHeap() {
|
371
|
-
var heap = {},
|
372
|
-
array = [];
|
373
|
-
|
374
|
-
heap.push = function() {
|
375
|
-
for (var i = 0, n = arguments.length; i < n; ++i) {
|
376
|
-
var object = arguments[i];
|
377
|
-
up(object.index = array.push(object) - 1);
|
378
|
-
}
|
379
|
-
return array.length;
|
380
|
-
};
|
381
|
-
|
382
|
-
heap.pop = function() {
|
383
|
-
var removed = array[0],
|
384
|
-
object = array.pop();
|
385
|
-
if (array.length) {
|
386
|
-
array[object.index = 0] = object;
|
387
|
-
down(0);
|
388
|
-
}
|
389
|
-
return removed;
|
390
|
-
};
|
391
|
-
|
392
|
-
heap.remove = function(removed) {
|
393
|
-
var i = removed.index,
|
394
|
-
object = array.pop();
|
395
|
-
if (i !== array.length) {
|
396
|
-
array[object.index = i] = object;
|
397
|
-
(compare(object, removed) < 0 ? up : down)(i);
|
398
|
-
}
|
399
|
-
return i;
|
400
|
-
};
|
401
|
-
|
402
|
-
function up(i) {
|
403
|
-
var object = array[i];
|
404
|
-
while (i > 0) {
|
405
|
-
var up = ((i + 1) >> 1) - 1,
|
406
|
-
parent = array[up];
|
407
|
-
if (compare(object, parent) >= 0) break;
|
408
|
-
array[parent.index = i] = parent;
|
409
|
-
array[object.index = i = up] = object;
|
410
|
-
}
|
411
|
-
}
|
412
|
-
|
413
|
-
function down(i) {
|
414
|
-
var object = array[i];
|
415
|
-
while (true) {
|
416
|
-
var right = (i + 1) << 1,
|
417
|
-
left = right - 1,
|
418
|
-
down = i,
|
419
|
-
child = array[down];
|
420
|
-
if (left < array.length && compare(array[left], child) < 0) child = array[down = left];
|
421
|
-
if (right < array.length && compare(array[right], child) < 0) child = array[down = right];
|
422
|
-
if (down === i) break;
|
423
|
-
array[child.index = i] = child;
|
424
|
-
array[object.index = i = down] = object;
|
425
|
-
}
|
426
|
-
}
|
427
|
-
|
428
|
-
return heap;
|
429
|
-
}
|
430
|
-
|
431
|
-
function nonemptyFeature(d) { return nonemptyGeometry(d.geometry); }
|
432
|
-
|
433
|
-
function nonemptyGeometry(d) {
|
434
|
-
return length(d.type === "GeometryCollection"
|
435
|
-
? d.geometries : d.coordinates);
|
436
|
-
}
|
437
|
-
|
438
|
-
function length(d) { return d.length; }
|
439
|
-
|
440
|
-
function copy(object) {
|
441
|
-
var o = {};
|
442
|
-
for (var key in object) o[key] = object[key];
|
443
|
-
return o;
|
444
|
-
}
|
445
|
-
|
446
|
-
})();
|