Skip to content

Instantly share code, notes, and snippets.

@Fil
Last active Jul 24, 2017
Embed
What would you like to do?
Earth in a Cube + versor [UNLISTED]
license: mit
(function() {
var ε = 1e-5, // 1e-6 gives incorrect clipping for cahillKeyes
π = Math.PI,
radians = π / 180,
degrees = 180 / π;
// Creates a polyhedral projection.
// * root: a spanning tree of polygon faces. Nodes are automatically
// augmented with a transform matrix.
// * face: a function that returns the appropriate node for a given {λ, φ}
// point (radians).
// * r: rotation angle for final polyhedron net. Defaults to -π / 6 (for
// butterflies).
d3.geo.polyhedron = function(root, face, r) {
r = r == null ? -π / 6 : r; // TODO automate
var mesh = [];
recurse(root, {transform: [
Math.cos(r), Math.sin(r), 0,
-Math.sin(r), Math.cos(r), 0
]});
function recurse(node, parent) {
node.edges = faceEdges(node.face);
if (parent) {
// Find shared edge.
if (parent.face) {
var shared = node.shared = sharedEdge(node.face, parent.face),
m = matrix(shared.map(parent.project), shared.map(node.project)),
ring = node.face.slice();
ring.push(ring[0]);
var centroid = d3.geo.centroid({type: "Polygon", coordinates: [ring]});
mesh.push(shared.map(function(d) { return d3.geo.interpolate(d, centroid)(ε); }));
node.transform = parent.transform ? multiply(parent.transform, m) : m;
// Replace shared edge in parent edges array.
var edges = parent.edges;
for (var i = 0, n = edges.length; i < n; ++i) {
if (pointEqual(shared[0], edges[i][1]) && pointEqual(shared[1], edges[i][0])) edges[i] = node;
if (pointEqual(shared[0], edges[i][0]) && pointEqual(shared[1], edges[i][1])) edges[i] = node;
}
var edges = node.edges;
for (var i = 0, n = edges.length; i < n; ++i) {
if (pointEqual(shared[0], edges[i][0]) && pointEqual(shared[1], edges[i][1])) edges[i] = parent;
if (pointEqual(shared[0], edges[i][1]) && pointEqual(shared[1], edges[i][0])) edges[i] = parent;
}
} else {
node.transform = parent.transform;
}
}
if (node.children) {
node.children.forEach(function(child) {
recurse(child, node);
});
}
return node;
}
function forward(λ, φ) {
var node = face(λ, φ),
point = node.project([λ * degrees, φ * degrees]),
t;
if (t = node.transform) {
return [
t[0] * point[0] + t[1] * point[1] + t[2],
-(t[3] * point[0] + t[4] * point[1] + t[5])
];
}
point[1] = -point[1];
return point;
}
// Naive inverse! A faster solution would use bounding boxes, or even a
// polygonal quadtree.
if (hasInverse(root)) forward.invert = function(x, y) {
var coordinates = faceInvert(root, [x, -y]);
return coordinates && (coordinates[0] *= radians, coordinates[1] *= radians, coordinates);
};
function faceInvert(node, coordinates) {
var invert = node.project.invert,
t = node.transform,
point = coordinates;
if (t) {
t = inverseTransform(t);
point = [
t[0] * point[0] + t[1] * point[1] + t[2],
(t[3] * point[0] + t[4] * point[1] + t[5])
];
}
if (invert && node === faceDegrees(p = invert(point))) return p;
var p,
children = node.children;
for (var i = 0, n = children && children.length; i < n; ++i) {
if (p = faceInvert(children[i], coordinates)) return p;
}
}
function faceDegrees(coordinates) {
return face(coordinates[0] * radians, coordinates[1] * radians);
}
var clipPolygon = [];
outline({point: function(λ, φ) { clipPolygon.push([λ, φ]); }}, root);
clipPolygon.push(clipPolygon[0]);
var projection = d3.geo.projection(forward).clipPolygon([clipPolygon]);
projection.mesh = mesh;
// this messes up cahillKeyes: is it necessary for the rest of polyhedra?
// var stream_ = projection.stream;
// projection.stream = function(stream) {
// var rotate = projection.rotate(),
// rotateStream = stream_(stream),
// sphereStream = (projection.rotate([0, 0]), stream_(stream));
// projection.rotate(rotate);
// rotateStream.sphere = function() {
// sphereStream.polygonStart();
// sphereStream.lineStart();
// outline(sphereStream, root);
// sphereStream.lineEnd();
// sphereStream.polygonEnd();
// };
// return rotateStream;
// };
return projection;
};
d3.geo.polyhedron.butterfly = function(faceProjection) {
faceProjection = faceProjection || function(face) {
var centroid = d3.geo.centroid({type: "MultiPoint", coordinates: face});
return d3.geo.gnomonic().scale(1).translate([0, 0]).rotate([-centroid[0], -centroid[1]]);
};
var faces = d3.geo.polyhedron.octahedron.map(function(face) {
return {face: face, project: faceProjection(face)};
});
[-1, 0, 0, 1, 0, 1, 4, 5].forEach(function(d, i) {
var node = faces[d];
node && (node.children || (node.children = [])).push(faces[i]);
});
return d3.geo.polyhedron(faces[0], function(λ, φ) {
return faces[
λ < -π / 2 ? φ < 0 ? 6 : 4
: λ < 0 ? φ < 0 ? 2 : 0
: λ < π / 2 ? φ < 0 ? 3 : 1
: φ < 0 ? 7 : 5];
});
};
d3.geo.polyhedron.waterman = function(faceProjection) {
faceProjection = faceProjection || function(face) {
var centroid = face.length === 6 ? d3.geo.centroid({type: "MultiPoint", coordinates: face}) : face[0];
return d3.geo.gnomonic().scale(1).translate([0, 0]).rotate([-centroid[0], -centroid[1]]);
};
var octahedron = d3.geo.polyhedron.octahedron;
var w5 = octahedron.map(function(face) {
var xyz = face.map(cartesian),
n = xyz.length,
a = xyz[n - 1],
b,
hexagon = [];
for (var i = 0; i < n; ++i) {
b = xyz[i];
hexagon.push(spherical([
a[0] * 0.9486832980505138 + b[0] * 0.31622776601683794,
a[1] * 0.9486832980505138 + b[1] * 0.31622776601683794,
a[2] * 0.9486832980505138 + b[2] * 0.31622776601683794
]), spherical([
b[0] * 0.9486832980505138 + a[0] * 0.31622776601683794,
b[1] * 0.9486832980505138 + a[1] * 0.31622776601683794,
b[2] * 0.9486832980505138 + a[2] * 0.31622776601683794
]));
a = b;
}
return hexagon;
});
var cornerNormals = [];
var parents = [-1, 0, 0, 1, 0, 1, 4, 5];
w5.forEach(function(hexagon, j) {
var face = octahedron[j],
n = face.length,
normals = cornerNormals[j] = [];
for (var i = 0; i < n; ++i) {
w5.push([
face[i],
hexagon[(i * 2 + 2) % (2 * n)],
hexagon[(i * 2 + 1) % (2 * n)]
]);
parents.push(j);
normals.push(cross(
cartesian(hexagon[(i * 2 + 2) % (2 * n)]),
cartesian(hexagon[(i * 2 + 1) % (2 * n)])
));
}
});
var faces = w5.map(function(face) {
return {
project: faceProjection(face),
face: face
};
});
parents.forEach(function(d, i) {
var parent = faces[d];
parent && (parent.children || (parent.children = [])).push(faces[i]);
});
return d3.geo.polyhedron(faces[0], face).center([0, 45]);
function face(λ, φ) {
var cosφ = Math.cos(φ),
p = [cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)];
var hexagon = λ < -π / 2 ? φ < 0 ? 6 : 4
: λ < 0 ? φ < 0 ? 2 : 0
: λ < π / 2 ? φ < 0 ? 3 : 1
: φ < 0 ? 7 : 5;
var n = cornerNormals[hexagon];
return faces[
dot(n[0], p) < 0 ? 8 + 3 * hexagon
: dot(n[1], p) < 0 ? 8 + 3 * hexagon + 1
: dot(n[2], p) < 0 ? 8 + 3 * hexagon + 2
: hexagon];
}
};
d3.geo.polyhedron.cahillKeyes = function(faceProjection) {
faceProjection = faceProjection || function(face) {
var centroid = face.length === 6 ? d3.geo.centroid({type: "MultiPoint", coordinates: face}) : face[0];
return d3.geo.cahillKeyes().scale(1);
};
var octahedron = d3.geo.polyhedron.octahedron;
var ck = octahedron.map(function(face) {
var xyz = face.map(cartesian),
n = xyz.length,
a = xyz[n - 1],
b,
θ = 17,
cosθ = Math.cos(θ*radians),
sinθ = Math.sin(θ*radians),
hexagon = [];
for (var i = 0; i < n; ++i) {
b = xyz[i];
hexagon.push(spherical([
a[0] * cosθ + b[0] * sinθ,
a[1] * cosθ + b[1] * sinθ,
a[2] * cosθ + b[2] * sinθ
]), spherical([
b[0] * cosθ + a[0] * sinθ,
b[1] * cosθ + a[1] * sinθ,
b[2] * cosθ + a[2] * sinθ
]));
a = b;
}
return hexagon;
});
var cornerNormals = [];
var parents = [-1, 3, 0, 2, 0, 1, 4, 5];
ck.forEach(function(hexagon, j) {
var face = octahedron[j],
n = face.length,
normals = cornerNormals[j] = [];
for (var i = 0; i < n; ++i) {
ck.push([
face[i],
hexagon[(i * 2 + 2) % (2 * n)],
hexagon[(i * 2 + 1) % (2 * n)]
]);
parents.push(j);
normals.push(cross(
cartesian(hexagon[(i * 2 + 2) % (2 * n)]),
cartesian(hexagon[(i * 2 + 1) % (2 * n)])
));
}
});
var faces = ck.map(function(face) {
return {
project: faceProjection(face),
face: face
};
});
parents.forEach(function(d, i) {
var parent = faces[d];
parent && (parent.children || (parent.children = [])).push(faces[i]);
});
return d3.geo.polyhedron(faces[0], face, 0).center([0, 45]);
function face(λ, φ) {
var cosφ = Math.cos(φ),
p = [cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)];
var hexagon = λ < -π / 2 ? φ < 0 ? 6 : 4
: λ < 0 ? φ < 0 ? 2 : 0
: λ < π / 2 ? φ < 0 ? 3 : 1
: φ < 0 ? 7 : 5;
var n = cornerNormals[hexagon];
return faces[
dot(n[0], p) < 0 ? 8 + 3 * hexagon
: dot(n[1], p) < 0 ? 8 + 3 * hexagon + 1
: dot(n[2], p) < 0 ? 8 + 3 * hexagon + 2
: hexagon];
}
};
function outline(stream, node, parent) {
var point,
edges = node.edges,
n = edges.length,
edge,
multiPoint = {type: "MultiPoint", coordinates: node.face},
notPoles = node.face.filter(function(d) { return Math.abs(Math.abs(d[1]) - 90) > ε; }),
bounds = d3.geo.bounds({type: "MultiPoint", coordinates: notPoles}),
inside = false,
j = -1,
ring = node.face.slice();
ring.push(ring[0]);
var centroid = node.centroid || d3.geo.centroid({type: "Polygon", coordinates: [ring]});
// First find the shared edge…
if (parent) while (++j < n) {
if (edges[j] === parent) break;
}
++j;
for (var i = 0; i < n; ++i) {
edge = edges[(i + j) % n];
if (Array.isArray(edge)) {
if (!inside) {
stream.point((point = d3.geo.interpolate(edge[0], centroid)(ε))[0], point[1]);
inside = true;
}
stream.point((point = d3.geo.interpolate(edge[1], centroid)(ε))[0], point[1]);
} else {
inside = false;
if (edge !== parent) outline(stream, edge, node);
}
}
}
// TODO generate on-the-fly to avoid external modification.
var octahedron = [
[0, 90],
[-90, 0], [0, 0], [90, 0], [180, 0],
[0, -90]
];
d3.geo.polyhedron.octahedron = [
[0, 2, 1],
[0, 3, 2],
[5, 1, 2],
[5, 2, 3],
[0, 1, 4],
[0, 4, 3],
[5, 4, 1],
[5, 3, 4]
].map(function(face) {
return face.map(function(i) {
return octahedron[i];
});
});
var φ1 = Math.atan(Math.SQRT1_2) * degrees;
var cube = [
[0, φ1], [90, φ1], [180, φ1], [-90, φ1],
[0, -φ1], [90, -φ1], [180, -φ1], [-90, -φ1]
];
d3.geo.polyhedron.cube = [
[0, 3, 2, 1], // N
[0, 1, 5, 4],
[1, 2, 6, 5],
[2, 3, 7, 6],
[3, 0, 4, 7],
[4, 5, 6, 7] // S
].map(function(face) {
return face.map(function(i) {
return cube[i];
});
});
// Finds a shared edge given two clockwise polygons.
function sharedEdge(a, b) {
var x, y, n = a.length, found = null;
for (var i = 0; i < n; ++i) {
x = a[i];
for (var j = b.length; --j >= 0;) {
y = b[j];
if (x[0] === y[0] && x[1] === y[1]) {
if (found) return [found, x];
found = x;
}
}
}
}
// Note: 6-element arrays are used to denote the 3x3 affine transform matrix:
// [a, b, c,
// d, e, f,
// 0, 0, 1] - this redundant row is left out.
// Transform matrix for [a0, a1] -> [b0, b1].
function matrix(a, b) {
var u = subtract(a[1], a[0]),
v = subtract(b[1], b[0]),
φ = angle(u, v),
s = length(u) / length(v);
return multiply([
1, 0, a[0][0],
0, 1, a[0][1]
], multiply([
s, 0, 0,
0, s, 0
], multiply([
Math.cos(φ), Math.sin(φ), 0,
-Math.sin(φ), Math.cos(φ), 0
], [
1, 0, -b[0][0],
0, 1, -b[0][1]
])));
}
// Inverts a transform matrix.
function inverseTransform(m) {
var k = 1 / (m[0] * m[4] - m[1] * m[3]);
return [
k * m[4], -k * m[1], k * (m[1] * m[5] - m[2] * m[4]),
-k * m[3], k * m[0], k * (m[2] * m[3] - m[0] * m[5])
];
}
// Multiplies two 3x2 matrices.
function multiply(a, b) {
return [
a[0] * b[0] + a[1] * b[3],
a[0] * b[1] + a[1] * b[4],
a[0] * b[2] + a[1] * b[5] + a[2],
a[3] * b[0] + a[4] * b[3],
a[3] * b[1] + a[4] * b[4],
a[3] * b[2] + a[4] * b[5] + a[5]
];
}
// Subtracts 2D vectors.
function subtract(a, b) {
return [a[0] - b[0], a[1] - b[1]];
}
// Magnitude of a 2D vector.
function length(v) {
return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
}
// Angle between two 2D vectors.
function angle(a, b) {
return Math.atan2(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]);
}
function dot(a, b) {
for (var i = 0, n = a.length, s = 0; i < n; ++i) s += a[i] * b[i];
return s;
}
function cross(a, b) {
return [
a[1] * b[2] - a[2] * b[1],
a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0]
];
}
// Converts 3D Cartesian to spherical coordinates (degrees).
function spherical(cartesian) {
return [
Math.atan2(cartesian[1], cartesian[0]) * degrees,
Math.asin(Math.max(-1, Math.min(1, cartesian[2]))) * degrees
];
}
// Converts spherical coordinates (degrees) to 3D Cartesian.
function cartesian(coordinates) {
var λ = coordinates[0] * radians,
φ = coordinates[1] * radians,
cosφ = Math.cos(φ);
return [
cosφ * Math.cos(λ),
cosφ * Math.sin(λ),
Math.sin(φ)
];
}
// Tests equality of two spherical points.
function pointEqual(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1];
}
// Converts an array of n face vertices to an array of n + 1 edges.
function faceEdges(face) {
var n = face.length,
edges = [];
for (var a = face[n - 1], i = 0; i < n; ++i) edges.push([a, a = face[i]]);
return edges;
}
function hasInverse(node) {
return node.project.invert || node.children && node.children.some(hasInverse);
}
})();
!function(){function t(t){return t?t/Math.sin(t):1}function n(t){return t>0?1:0>t?-1:0}function a(t){return t>1?aa/2:-1>t?-aa/2:Math.asin(t)}function r(t){return t>1?0:-1>t?aa:Math.acos(t)}function e(t){return t>0?Math.sqrt(t):0}function o(t){function n(t,n){var a=Math.cos(t),r=Math.cos(n),o=Math.sin(n),i=r*a,h=-((1-i?Math.log(.5*(1+i))/(1-i):-.5)+e/(1+i));return[h*r*Math.sin(t),h*o]}var r=Math.tan(.5*t),e=2*Math.log(Math.cos(.5*t))/(r*r);return n.invert=function(n,r){var o,i=Math.sqrt(n*n+r*r),h=t*-.5,u=50;if(!i)return[0,0];do{var M=.5*h,s=Math.cos(M),c=Math.sin(M),f=Math.tan(M),v=Math.log(1/s);h-=o=(2/f*v-e*f-i)/(-v/(c*c)+1-e/(2*s*s))}while(Math.abs(o)>ta&&--u>0);var l=Math.sin(h);return[Math.atan2(n*l,i*Math.cos(h)),a(r*l/i)]},n}function i(){var t=aa/2,n=ha(o),a=n(t);return a.radius=function(a){return arguments.length?n(t=a*aa/180):180*(t/aa)},a}function h(n,a){var e=Math.cos(a),o=t(r(e*Math.cos(n/=2)));return[2*e*Math.sin(n)*o,Math.sin(a)*o]}function u(t){function n(t,n){var h=Math.cos(n),u=Math.cos(t/=2);return[(1+h)*Math.sin(t),(e*n>-Math.atan2(u,o)-.001?0:10*-e)+i+Math.sin(n)*r-(1+h)*a*u]}var a=Math.sin(t),r=Math.cos(t),e=t>0?1:-1,o=Math.tan(e*t),i=(1+a-r)/2;return n.invert=function(t,n){var h=0,u=0,M=50;do{var s=Math.cos(h),c=Math.sin(h),f=Math.cos(u),v=Math.sin(u),l=1+f,g=l*c-t,d=i+v*r-l*a*s-n,p=.5*l*s,b=-c*v,q=.5*a*l*c,w=r*f+a*s*v,m=b*q-w*p,S=.5*(d*b-g*w)/m,T=(g*q-d*p)/m;h-=S,u-=T}while((Math.abs(S)>ta||Math.abs(T)>ta)&&--M>0);return e*u>-Math.atan2(Math.cos(h),o)-.001?[2*h,u]:null},n}function M(){var t=aa/9,n=t>0?1:-1,a=Math.tan(n*t),r=ha(u),e=r(t),o=e.stream;return e.parallel=function(e){return arguments.length?(a=Math.tan((n=(t=e*aa/180)>0?1:-1)*t),r(t)):180*(t/aa)},e.stream=function(r){var i=e.rotate(),h=o(r),u=(e.rotate([0,0]),o(r));return e.rotate(i),h.sphere=function(){u.polygonStart(),u.lineStart();for(var r=-180*n;180>n*r;r+=90*n)u.point(r,90*n);for(;n*(r-=t)>=-180;)u.point(r,n*-Math.atan2(Math.cos(r*ea/2),a)*oa);u.lineEnd(),u.polygonEnd()},h},e}function s(t){return t=Math.exp(2*t),(t-1)/(t+1)}function c(t){return.5*(Math.exp(t)-Math.exp(-t))}function f(t){return.5*(Math.exp(t)+Math.exp(-t))}function v(t){return Math.log(t+e(t*t+1))}function l(t){return Math.log(t+e(t*t-1))}function g(t,n){var a=Math.tan(n/2),r=e(1-a*a),o=1+r*Math.cos(t/=2),i=Math.sin(t)*r/o,h=a/o,u=i*i,M=h*h;return[4/3*i*(3+u-3*M),4/3*h*(3+3*u-M)]}function d(t,a){var r=Math.abs(a);return aa/4>r?[t,Math.log(Math.tan(aa/4+a/2))]:[t*Math.cos(r)*(2*Math.SQRT2-1/Math.sin(r)),n(a)*(2*Math.SQRT2*(r-aa/4)-Math.log(Math.tan(r/2)))]}function p(t){function n(t,n){var e=Ma(t,n);if(Math.abs(t)>aa/2){var o=Math.atan2(e[1],e[0]),i=Math.sqrt(e[0]*e[0]+e[1]*e[1]),h=r*Math.round((o-aa/2)/r)+aa/2,u=Math.atan2(Math.sin(o-=h),2-Math.cos(o));o=h+a(aa/i*Math.sin(u))-u,e[0]=i*Math.cos(o),e[1]=i*Math.sin(o)}return e}var r=2*aa/t;return n.invert=function(t,n){var a=Math.sqrt(t*t+n*n);if(a>aa/2){var e=Math.atan2(n,t),o=r*Math.round((e-aa/2)/r)+aa/2,i=e>o?-1:1,h=a*Math.cos(o-e),u=1/Math.tan(i*Math.acos((h-aa)/Math.sqrt(aa*(aa-2*h)+a*a)));e=o+2*Math.atan((u+i*Math.sqrt(u*u-3))/3),t=a*Math.cos(e),n=a*Math.sin(e)}return Ma.invert(t,n)},n}function b(){var t=5,n=ha(p),a=n(t),r=a.stream;return a.lobes=function(a){return arguments.length?n(t=+a):t},a.stream=function(n){var e=a.rotate(),o=r(n),i=(a.rotate([0,0]),r(n));return a.rotate(e),o.sphere=function(){i.polygonStart(),i.lineStart();for(var n=.01,a=0,r=360/t,e=90-180/t;t>a;++a,e-=r)i.point(180,0),-90>e?(i.point(-90,180-e-n),i.point(-90,180-e+n)):(i.point(90,e+n),i.point(90,e-n));i.lineEnd(),i.polygonEnd()},o},a}function q(t){return function(n){var a,r=t*Math.sin(n),e=30;do n-=a=(n+Math.sin(n)-r)/(1+Math.cos(n));while(Math.abs(a)>ta&&--e>0);return n/2}}function w(t,n,r){function e(a,r){return[t*a*Math.cos(r=o(r)),n*Math.sin(r)]}var o=q(r);return e.invert=function(e,o){var i=a(o/n);return[e/(t*Math.cos(i)),a((2*i+Math.sin(2*i))/r)]},e}function m(t,n){var a=2.00276,r=sa(n);return[a*t/(1/Math.cos(n)+1.11072/Math.cos(r)),(n+Math.SQRT2*Math.sin(r))/a]}function S(t){var n=0,a=ha(t),r=a(n);return r.parallel=function(t){return arguments.length?a(n=t*aa/180):180*(n/aa)},r}function T(t,n){return[t*Math.cos(n),n]}function A(t){function n(n,r){var e=a+t-r,o=e?n*Math.cos(r)/e:e;return[e*Math.sin(o),a-e*Math.cos(o)]}if(!t)return T;var a=1/Math.tan(t);return n.invert=function(n,r){var e=Math.sqrt(n*n+(r=a-r)*r),o=a+t-e;return[e/Math.cos(o)*Math.atan2(n,r),o]},n}function Q(t){function n(){var t,n,o,i,h,u,M,s,d,p,b,q=29,w=15,m=Math.sqrt(3);return k.lengthMA=.094*k.lengthMG,k.lengthParallel0to73At0=k.lengthMG/100,k.lengthParallel73to90At0=(k.lengthMG-k.lengthMA-73*k.lengthParallel0to73At0)/17,k.sin60=.866025403784439,k.cos60=.5,k.yTranslate=k.lengthMG*k.sin60,k.pointM=[0,0],k.pointG=[k.lengthMG,0],t=[k.lengthMG,k.lengthMG*Math.tan(30*ea)],k.pointA=[k.lengthMA,0],k.pointB=e(k.pointM,30,k.pointA,45),k.lengthAG=a(k.pointA,k.pointG),k.lengthAB=a(k.pointA,k.pointB),n=a(k.pointM,k.pointB),o=a(k.pointM,t),i=a(t,k.pointG),k.pointD=r(n,o,t,k.pointM),k.pointF=[k.lengthMG,i-n],k.pointE=[t[0]-k.lengthMA*Math.sin(30*ea),t[1]-k.lengthMA*Math.cos(30*ea)],k.lengthGF=a(k.pointG,k.pointF),k.lengthBD=a(k.pointB,k.pointD),k.lengthBDE=k.lengthBD+k.lengthAB,k.lengthGFE=k.lengthGF+k.lengthAB,k.deltaMEq=k.lengthGFE/45,k.lengthAP75=15*k.lengthParallel73to90At0,k.lengthAP73=k.lengthMG-k.lengthMA-73*k.lengthParallel0to73At0,h=[k.pointA[0]+k.lengthAP73*Math.cos(30*ea),k.pointA[1]+k.lengthAP73*Math.sin(30*ea)],k.pointT=e(h,-60,k.pointB,30),u=g(q),M=u.lengthParallel73,s=v(q),d=l(q),p=w*(s+d+M)/73,b=[0,0],k.pointC=[0,0],k.radius=0,p-=s,b=r(p,d,c(q),f(q)),k.pointC[1]=(b[0]*b[0]+b[1]*b[1]-k.pointD[0]*k.pointD[0]-k.pointD[1]*k.pointD[1])/(2*(m*b[0]+b[1]-m*k.pointD[0]-k.pointD[1])),k.pointC[0]=m*k.pointC[1],k.radius=a(k.pointC,k.pointD),k}function a(t,n){var a=t[0]-n[0],r=t[1]-n[1];return Math.sqrt(a*a+r*r)}function r(t,n,a,r){var e=[a[0]+(r[0]-a[0])*t/n,a[1]+(r[1]-a[1])*t/n];return e}function e(t,n,a,r){var e=Math.tan(n*ea),o=Math.tan(r*ea),i=[0,0];return i[0]=(e*t[0]-o*a[0]-t[1]+a[1])/(e-o),i[1]=e*(i[0]-t[0])+t[1],i}function o(t,n,a,r){var e=a[0],o=a[1],i=r[0],h=r[1],u=t[0],M=t[1],s=(i-e)*(i-e)+(h-o)*(h-o),c=2*((i-e)*(e-u)+(h-o)*(o-M)),f=u*u+M*M+e*e+o*o-2*(u*e+M*o)-n*n,v=c*c-4*s*f,l=0,g=0,d=0,p=0;return 0===s?[0,[0,0]]:0>v?[0,[0,0]]:(l=(-c+Math.sqrt(v))/(2*s),g=(-c-Math.sqrt(v))/(2*s),l>=0&&1>=l?(d=e+l*(i-e),p=o+l*(h-o),[1,[d,p]]):g>=0&&1>=g?(d=e+g*(i-e),p=o+g*(h-o),[1,[d,p]]):[0,[0,0]])}function i(t,n){var a=[0,0];return-60===n?(a[0]=t[0]*k.cos60+t[1]*k.sin60,a[1]=-t[0]*k.sin60+t[1]*k.cos60):-120===n?(a[0]=-t[0]*k.cos60+t[1]*k.sin60,a[1]=-t[0]*k.sin60-t[1]*k.cos60):(console.log("rotate: angle "+n+" different than -60 or -120!"),a[0]=t[0]*Math.cos(n*ea)-t[1]*Math.sin(n*ea),a[1]=t[0]*Math.sin(n*ea)+t[1]*Math.cos(n*ea)),a}function h(t){return t>=0?1:-1}function u(t){return Math[t>0?"floor":"ceil"](t)}function M(t){var n=k.deltaMEq*t,a=[0,0];return n<=k.lengthGF?a=[k.pointG[0],n]:(n-=k.lengthGF,a=r(n,k.lengthAB,k.pointF,k.pointE)),a}function s(t){return M(t)}function c(t){return e(k.pointM,2*t/3,s(t),t/3)}function f(t){if(0===t)return[k.pointA+k.lengthAB,0];var n=e(k.pointA,t,k.pointM,2*t/3);return n}function v(t){return a(s(t),c(t))}function l(t){return a(c(t),f(t))}function g(t){var n=[0,0],r=f(t),o=0,i=[0,0];return 30>=t?(n[0]=k.pointA[0]+k.lengthAP73*Math.cos(t*ea),n[1]=k.pointA[1]+k.lengthAP73*Math.sin(t*ea),o=a(r,n)):(n=e(k.pointT,-60,r,t),o=a(r,n),t>44&&(i=e(k.pointT,-60,r,2/3*t),i[0]>n[0]&&(n=i,o=-a(r,n)))),{parallel73:n,lengthParallel73:o}}function d(t){return[k.pointA[0]+k.lengthAP75*Math.cos(t*ea),k.pointA[1]+k.lengthAP75*Math.sin(t*ea)]}function p(t,n){var a,r=[0,6,7,8,5],e=u((t+180)/90+1),o=t+180-90*(e-1)-45,i=h(o);return o=Math.abs(o),5===e&&(e=1),0>n&&(e=r[e]),a=Math.abs(n),[o,a,i,e]}function b(t,n){return[k.pointA[0]+104*(90-n),0]}function q(t,n){return[k.pointG[0]-100*n,0]}function w(t,n){var a=104*(90-n);return[k.pointA[0]+a*Math.cos(t*ea),k.pointA[1]+a*Math.sin(t*ea)]}function m(t,n){return n=n,M(t)}function S(t,n){var a=1560+100*(75-n);return[k.pointA[0]+a*Math.cos(t*ea),k.pointA[1]+a*Math.sin(t*ea)]}function T(t,n){return r(n,15,k.pointE,k.pointD)}function A(t,n){var a=n-15;return r(a,58,k.pointD,k.pointT)}function Q(t,n){var e=d(45),o=g(t),i=o.parallel73,h=a(k.pointT,k.pointB),u=a(k.pointB,e),M=(75-n)*(u+h)/2,s=[0,0];return u>=M?s=r(M,u,e,k.pointB):(M-=u,s=r(M,h,k.pointB,i)),s}function R(t,n){var a,e=g(t),o=v(t),i=l(t),h=n*(o+i+e.lengthParallel73)/73;return o>=h?a=r(h,o,s(t),c(t)):o+i>=h?(h-=o,a=r(h,i,c(t),f(t))):(h=h-o-i,a=r(h,e.lengthParallel73,f(t),e.parallel73)),a}function y(t,n){var e=d(t),o=a(f(t),e),i=g(t),h=i.parallel73,u=i.lengthParallel73,M=(75-n)*(o-u)/2,s=[0,0];return o>=M?s=r(M,o,e,f(t)):(M-=o,s=r(M,-u,f(t),h)),s}function G(t,n,a){var e=n*a/15,o=v(t),i=l(t),h=[0,0];return o>=e?h=r(e,o,s(t),c(t)):(e-=o,h=r(e,i,c(t),f(t))),h}function P(t,n,a){var e,o=g(t),i=o.parallel73,h=v(t),u=l(t),M=o.lengthParallel73,d=a+(n-15)*(h+u+M-a)/58;return h>=d?e=r(d,h,s(t),f(t)):h+u>=d?(d-=h,e=r(d,u,c(t),f(t))):(d=d-h-u,e=r(d,M,f(t),i)),e}function x(t,n){var r,e,i,h,u,M=[0,0];return 0===t?M=n>=75?b(t,n):q(t,n):n>=75?M=w(t,n):0===n?M=m(t,n):n>=73&&30>=t?M=S(t,n):45===t?M=15>=n?T(t,n):73>=n?A(t,n):Q(t,n):29>=t?M=R(t,n):n>=73?M=y(t,n):(e=o(k.pointC,k.radius,c(t),f(t)),h=e[0],i=e[1],r=v(t),1===h?u=r+a(c(t),i):(e=o(k.pointC,k.radius,s(t),c(t)),h=e[0],i=e[1],0===h&&console.log("Something weird!"),u=r-a(c(t),i)),M=15>=n?G(t,n,u):P(t,n,u)),M}function E(t,n){var a=[0,0];if(0===n)a=i(t,-60);else if(1===n)a=i(t,-120),a[0]-=k.lengthMG;else if(2===n)a=i(t,-60),a[0]-=k.lengthMG;else if(3===n)a=i(t,-120),a[0]+=k.lengthMG;else if(4===n)a=i(t,-60),a[0]+=k.lengthMG;else if(5===n)a=i([2*k.lengthMG-t[0],t[1]],-60),a[0]+=k.lengthMG;else if(6===n)a=i([2*k.lengthMG-t[0],t[1]],-120),a[0]-=k.lengthMG;else if(7===n)a=i([2*k.lengthMG-t[0],t[1]],-60),a[0]-=k.lengthMG;else{if(8!==n)return console.log("mj2g: something weird happened!"),a;a=i([2*k.lengthMG-t[0],t[1]],-120),a[0]+=k.lengthMG}return a[1]+=k.yTranslate,a}function B(t,n){var a=t*oa,r=n*oa,e=p(a,r),o=e[0],i=e[1],h=e[2],u=e[3],M=x(o,i),s=E([M[0],h*M[1]],u);return s}var k={lengthMG:t};return n(),B}function R(){var t=1e4,n=ha(Q),a=n(t);return a}function y(t){function n(n,a){for(var r=Math.sin(a),e=Math.cos(a),o=new Array(3),M=0;3>M;++M){var s=t[M];if(o[M]=P(a-s[1],s[3],s[2],e,r,n-s[0]),!o[M][0])return s.point;o[M][1]=E(o[M][1]-s.v[1])}for(var c=u.slice(),M=0;3>M;++M){var f=2==M?0:M+1,v=x(t[M].v[0],o[M][0],o[f][0]);o[M][1]<0&&(v=-v),M?1==M?(v=i-v,c[0]-=o[M][0]*Math.cos(v),c[1]-=o[M][0]*Math.sin(v)):(v=h-v,c[0]+=o[M][0]*Math.cos(v),c[1]+=o[M][0]*Math.sin(v)):(c[0]+=o[M][0]*Math.cos(v),c[1]-=o[M][0]*Math.sin(v))}return c[0]/=3,c[1]/=3,c}t=t.map(function(t){return[t[0],t[1],Math.sin(t[1]),Math.cos(t[1])]});for(var a,r=t[2],e=0;3>e;++e,r=a)a=t[e],r.v=P(a[1]-r[1],r[3],r[2],a[3],a[2],a[0]-r[0]),r.point=[0,0];var o=x(t[0].v[0],t[2].v[0],t[1].v[0]),i=x(t[0].v[0],t[1].v[0],t[2].v[0]),h=aa-o;t[2].point[1]=0,t[0].point[0]=-(t[1].point[0]=.5*t[0].v[0]);var u=[t[2].point[0]=t[0].point[0]+t[2].v[0]*Math.cos(o),2*(t[0].point[1]=t[1].point[1]=t[2].v[0]*Math.sin(o))];return n}function G(){var t=[[0,0],[0,0],[0,0]],n=ha(y),a=n(t),r=a.rotate;return delete a.rotate,a.points=function(e){if(!arguments.length)return t;t=e;var o=d3.geo.centroid({type:"MultiPoint",coordinates:t}),i=[-o[0],-o[1]];return r.call(a,i),n(t.map(d3.geo.rotation(i)).map(B))},a.points([[-150,55],[-35,55],[-92.5,10]])}function P(t,n,e,o,i,h){var u,M=Math.cos(h);if(Math.abs(t)>1||Math.abs(h)>1)u=r(e*i+n*o*M);else{var s=Math.sin(.5*t),c=Math.sin(.5*h);u=2*a(Math.sqrt(s*s+n*o*c*c))}return Math.abs(u)>ta?[u,Math.atan2(o*Math.sin(h),n*i-e*o*M)]:[0,0]}function x(t,n,a){return r(.5*(t*t+n*n-a*a)/(t*n))}function E(t){return t-2*aa*Math.floor((t+aa)/(2*aa))}function B(t){return[t[0]*ea,t[1]*ea]}function k(t,n){var a=e(1-Math.sin(n));return[2/ra*t*a,ra*(1-a)]}function D(t){function n(t,n){return[t,(t?t/Math.sin(t):1)*(Math.sin(n)*Math.cos(t)-r*Math.cos(n))]}var r=Math.tan(t);return n.invert=r?function(t,n){t&&(n*=Math.sin(t)/t);var a=Math.cos(t);return[t,2*Math.atan2(Math.sqrt(a*a+r*r-n*n)-a,r-n)]}:function(t,n){return[t,a(t?n*Math.tan(t)/t:n)]},n}function _(t,n){var a=Math.sqrt(3);return[a*t*(2*Math.cos(2*n/3)-1)/ra,a*ra*Math.sin(n/3)]}function F(t){function n(t,n){return[t*r,Math.sin(n)/r]}var r=Math.cos(t);return n.invert=function(t,n){return[t/r,a(n*r)]},n}function z(t){function n(t,n){return[t*a,(1+a)*Math.tan(.5*n)]}var a=Math.cos(t);return n.invert=function(t,n){return[t/a,2*Math.atan(n/(1+a))]},n}function C(t,n){var a=Math.sqrt(8/(3*aa));return[a*t*(1-Math.abs(n)/aa),a*n]}function j(t,a){var r=Math.sqrt(4-3*Math.sin(Math.abs(a)));return[2/Math.sqrt(6*aa)*t*r,n(a)*Math.sqrt(2*aa/3)*(2-r)]}function H(t,n){var a=Math.sqrt(aa*(4+aa));return[2/a*t*(1+Math.sqrt(1-4*n*n/(aa*aa))),4/a*n]}function I(t,n){var a=(2+aa/2)*Math.sin(n);n/=2;for(var r=0,e=1/0;10>r&&Math.abs(e)>ta;r++){var o=Math.cos(n);n-=e=(n+Math.sin(n)*(o+2)-a)/(2*o*(1+o))}return[2/Math.sqrt(aa*(4+aa))*t*(1+Math.cos(n)),2*Math.sqrt(aa/(4+aa))*Math.sin(n)]}function K(t,n){return[t*(1+Math.cos(n))/Math.sqrt(2+aa),2*n/Math.sqrt(2+aa)]}function J(t,n){for(var a=(1+aa/2)*Math.sin(n),r=0,e=1/0;10>r&&Math.abs(e)>ta;r++)n-=e=(n+Math.sin(n)-a)/(1+Math.cos(n));return a=Math.sqrt(2+aa),[t*(1+Math.cos(n))/a,2*n/a]}function L(t,n){var a=Math.sin(t/=2),r=Math.cos(t),e=Math.sqrt(Math.cos(n)),o=Math.cos(n/=2),i=Math.sin(n)/(o+Math.SQRT2*r*e),h=Math.sqrt(2/(1+i*i)),u=Math.sqrt((Math.SQRT2*o+(r+a)*e)/(Math.SQRT2*o+(r-a)*e));return[va*(h*(u-1/u)-2*Math.log(u)),va*(h*i*(u+1/u)-2*Math.atan(i))]}function N(t,n){var a=Math.tan(n/2);return[t*la*e(1-a*a),(1+la)*a]}function O(t,n){var a=n/2,r=Math.cos(a);return[2*t/ra*Math.cos(n)*r*r,ra*Math.tan(a)]}function U(t,n,a,r,o,i,h,u){function M(e,M){if(!M)return[t*e/aa,0];var s=M*M,c=t+s*(n+s*(a+s*r)),f=M*(o-1+s*(i-u+s*h)),v=(c*c+f*f)/(2*f),l=e*Math.asin(c/v)/aa;return[v*Math.sin(l),M*(1+s*u)+v*(1-Math.cos(l))]}return arguments.length<8&&(u=0),M.invert=function(M,s){var c,f,v=aa*M/t,l=s,g=50;do{var d=l*l,p=t+d*(n+d*(a+d*r)),b=l*(o-1+d*(i-u+d*h)),q=p*p+b*b,w=2*b,m=q/w,S=m*m,T=Math.asin(p/m)/aa,A=v*T;if(xB2=p*p,dxBdφ=(2*n+d*(4*a+6*d*r))*l,dyBdφ=o+d*(3*i+5*d*h),dpdφ=2*(p*dxBdφ+b*(dyBdφ-1)),dqdφ=2*(dyBdφ-1),dmdφ=(dpdφ*w-q*dqdφ)/(w*w),cosα=Math.cos(A),sinα=Math.sin(A),mcosα=m*cosα,msinα=m*sinα,dαdφ=v/aa*(1/e(1-xB2/S))*(dxBdφ*m-p*dmdφ)/S,fx=msinα-M,fy=l*(1+d*u)+m-mcosα-s,δxδφ=dmdφ*sinα+mcosα*dαdφ,δxδλ=mcosα*T,δyδφ=1+dmdφ-(dmdφ*cosα-msinα*dαdφ),δyδλ=msinα*T,denominator=δxδφ*δyδλ-δyδφ*δxδλ,!denominator)break;v-=c=(fy*δxδφ-fx*δyδφ)/denominator,l-=f=(fx*δyδλ-fy*δxδλ)/denominator}while((Math.abs(c)>ta||Math.abs(f)>ta)&&--g>0);return[v,l]},M}function V(t,n){var a=t*t,r=n*n;return[t*(1-.162388*r)*(.87-952426e-9*a*a),n*(1+r/12)]}function W(t){function a(){var t=!1,n=ha(r),a=n(t);return a.quincuncial=function(a){return arguments.length?n(t=!!a):t},a}function r(a){var r=a?function(a,r){var o=Math.abs(a)<aa/2,i=t(o?a:a>0?a-aa:a+aa,r),h=(i[0]-i[1])*Math.SQRT1_2,u=(i[0]+i[1])*Math.SQRT1_2;if(o)return[h,u];var M=e*Math.SQRT1_2,s=h>0^u>0?-1:1;return[s*h-n(u)*M,s*u-n(h)*M]}:function(n,a){var r=n>0?-.5:.5,o=t(n+r*aa,a);return o[0]-=r*e,o};return t.invert&&(r.invert=a?function(n,a){var r=(n+a)*Math.SQRT1_2,o=(a-n)*Math.SQRT1_2,i=Math.abs(r)<.5*e&&Math.abs(o)<.5*e;if(!i){var h=e*Math.SQRT1_2,u=r>0^o>0?-1:1,M=-u*(n+(o>0?1:-1)*h),s=-u*(a+(r>0?1:-1)*h);r=(-M-s)*Math.SQRT1_2,o=(M-s)*Math.SQRT1_2}var c=t.invert(r,o);return i||(c[0]+=r>0?aa:-aa),c}:function(n,a){var r=n>0?-.5:.5,o=t.invert(n+r*e,a),i=o[0]-r*aa;return-aa>i?i+=2*aa:i>aa&&(i-=2*aa),o[0]=i,o}),r}var e=t(aa/2,0)[0]-t(-aa/2,0)[0];return a.raw=r,a}function X(t,r){var e=n(t),o=n(r),i=Math.cos(r),h=Math.cos(t)*i,u=Math.sin(t)*i,M=Math.sin(o*r);t=Math.abs(Math.atan2(u,M)),r=a(h),Math.abs(t-aa/2)>ta&&(t%=aa/2);var s=Y(t>aa/4?aa/2-t:t,r);return t>aa/4&&(M=s[0],s[0]=-s[1],s[1]=-M),s[0]*=e,s[1]*=-o,s}function Y(t,n){if(n===aa/2)return[0,0];var r=Math.sin(n),o=r*r,i=o*o,h=1+i,u=1+3*i,M=1-i,s=a(1/Math.sqrt(h)),c=M+o*h*s,f=(1-r)/c,v=Math.sqrt(f),l=f*h,g=Math.sqrt(l),d=v*M;if(0===t)return[0,-(d+o*g)];var p=Math.cos(n),b=1/p,q=2*r*p,w=(-3*o+s*u)*q,m=(-c*p-(1-r)*w)/(c*c),S=.5*m/v,T=M*S-2*o*v*q,A=o*h*m+f*u*q,Q=-b*q,R=-b*A,y=-2*b*T,G=4*t/aa;if(t>.222*aa||aa/4>n&&t>.175*aa){var P=(d+o*e(l*(1+i)-d*d))/(1+i);if(t>aa/4)return[P,P];var x=P,E=.5*P,B=50;P=.5*(E+x);do{var k=Math.sqrt(l-P*P),D=P*(y+Q*k)+R*a(P/g)-G;if(!D)break;0>D?E=P:x=P,P=.5*(E+x)}while(Math.abs(x-E)>ta&&--B>0)}else{var _,P=ta,B=25;do{var F=P*P,k=e(l-F),z=y+Q*k,D=P*z+R*a(P/g)-G,C=z+(R-Q*F)/k;P-=_=k?D/C:0}while(Math.abs(_)>ta&&--B>0)}return[P,-d-o*e(l-P*P)]}function Z(t,n){for(var a=0,r=1,e=.5,o=50;;){var i=e*e,h=Math.sqrt(e),u=Math.asin(1/Math.sqrt(1+i)),M=1-i+e*(1+i)*u,s=(1-h)/M,c=Math.sqrt(s),f=s*(1+i),v=c*(1-i),l=f-t*t,g=Math.sqrt(l),d=n+v+e*g;if(Math.abs(r-a)<na||0===--o||0===d)break;d>0?a=e:r=e,e=.5*(a+r)}if(!o)return null;var p=Math.asin(h),b=Math.cos(p),q=1/b,w=2*h*b,m=(-3*e+u*(1+3*i))*w,S=(-M*b-(1-h)*m)/(M*M),T=.5*S/c,A=(1-i)*T-2*e*c*w,Q=-2*q*A,R=-q*w,y=-q*(e*(1+i)*S+s*(1+3*i)*w);return[aa/4*(t*(Q+R*g)+y*Math.asin(t/Math.sqrt(f))),p]}function $(t,n,a){if(!t){var r=tn(n,1-a);return[[0,r[0]/r[1]],[1/r[1],0],[r[2]/r[1],0]]}var e=tn(t,a);if(!n)return[[e[0],0],[e[1],0],[e[2],0]];var r=tn(n,1-a),o=r[1]*r[1]+a*e[0]*e[0]*r[0]*r[0];return[[e[0]*r[2]/o,e[1]*e[2]*r[0]*r[1]/o],[e[1]*r[1]/o,-e[0]*e[2]*r[0]*r[2]/o],[e[2]*r[1]*r[2]/o,-a*e[0]*e[1]*r[0]/o]]}function tn(t,n){var r,o,i,h,u;if(ta>n)return h=Math.sin(t),o=Math.cos(t),r=.25*n*(t-h*o),[h-r*o,o+r*h,1-.5*n*h*h,t-r];if(n>=1-ta)return r=.25*(1-n),o=f(t),h=s(t),i=1/o,u=o*c(t),[h+r*(u-t)/(o*o),i-r*h*i*(u-t),i+r*h*i*(u+t),2*Math.atan(Math.exp(t))-aa/2+r*(u-t)/o];var M=[1,0,0,0,0,0,0,0,0],v=[Math.sqrt(n),0,0,0,0,0,0,0,0],l=0;for(o=Math.sqrt(1-n),u=1;Math.abs(v[l]/M[l])>ta&&8>l;)r=M[l++],v[l]=.5*(r-o),M[l]=.5*(r+o),o=e(r*o),u*=2;i=u*M[l]*t;do h=v[l]*Math.sin(o=i)/M[l],i=.5*(a(h)+i);while(--l);return[Math.sin(i),h=Math.cos(i),h/Math.cos(i-o),i]}function nn(t,a,r){var o=Math.abs(t),i=Math.abs(a),h=c(i);if(o){var u=1/Math.sin(o),M=1/(Math.tan(o)*Math.tan(o)),s=-(M+r*h*h*u*u-1+r),f=(r-1)*M,v=.5*(-s+Math.sqrt(s*s-4*f));return[an(Math.atan(1/Math.sqrt(v)),r)*n(t),an(Math.atan(e((v/M-1)/r)),1-r)*n(a)]}return[0,an(Math.atan(h),1-r)*n(a)]}function an(t,n){if(!n)return t;if(1===n)return Math.log(Math.tan(t/2+aa/4));for(var a=1,r=Math.sqrt(1-n),e=Math.sqrt(n),o=0;Math.abs(e)>ta;o++){if(t%aa){var i=Math.atan(r*Math.tan(t)/a);0>i&&(i+=aa),t+=i+~~(t/aa)*aa}else t+=t;e=(a+r)/2,r=Math.sqrt(a*r),e=((a=e)-r)/2}return t/(Math.pow(2,o)*a)}function rn(t,a){var r=(Math.SQRT2-1)/(Math.SQRT2+1),e=Math.sqrt(1-r*r),o=an(aa/2,e*e),i=-1,h=Math.log(Math.tan(aa/4+Math.abs(a)/2)),u=Math.exp(i*h)/Math.sqrt(r),M=en(u*Math.cos(i*t),u*Math.sin(i*t)),s=nn(M[0],M[1],e*e);return[-s[1],n(a)*(.5*o-s[0])]}function en(t,a){var r=t*t,e=a+1,o=1-r-a*a;return[n(t)*aa/4-.5*Math.atan2(o,2*t),-.25*Math.log(o*o+4*r)+.5*Math.log(e*e+r)]}function on(t,n){var a=n[0]*n[0]+n[1]*n[1];return[(t[0]*n[0]+t[1]*n[1])/a,(t[1]*n[0]-t[0]*n[1])/a]}function hn(t){function n(t,n){var e=i(t,n);t=e[0],n=e[1];var h=Math.sin(n),u=Math.cos(n),M=Math.cos(t),s=r(a*h+o*u*M),c=Math.sin(s),f=Math.abs(c)>ta?s/c:1;return[f*o*Math.sin(t),(Math.abs(t)>aa/2?f:-f)*(a*u-o*h*M)]}var a=Math.sin(t),o=Math.cos(t),i=un(t);return i.invert=un(-t),n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),o=-Math.sin(r),h=Math.cos(r),u=r*h,M=-n*o,s=r*a,c=e(u*u+M*M-s*s),f=Math.atan2(u*s+M*c,M*s-u*c),v=(r>aa/2?-1:1)*Math.atan2(t*o,r*Math.cos(f)*h+n*Math.sin(f)*o);return i.invert(v,f)},n}function un(t){var n=Math.sin(t),r=Math.cos(t);return function(t,e){var o=Math.cos(e),i=Math.cos(t)*o,h=Math.sin(t)*o,u=Math.sin(e);return[Math.atan2(h,i*r-u*n),a(u*r+i*n)]}}function Mn(){var t=0,n=ha(hn),a=n(t),r=a.rotate,e=a.stream,o=d3.geo.circle();return a.parallel=function(r){if(!arguments.length)return 180*(t/aa);var e=a.rotate();return n(t=r*aa/180).rotate(e)},a.rotate=function(n){return arguments.length?(r.call(a,[n[0],n[1]-180*(t/aa)]),o.origin([-n[0],-n[1]]),a):(n=r.call(a),n[1]+=180*(t/aa),n)},a.stream=function(t){return t=e(t),t.sphere=function(){t.polygonStart();var n,a=.01,r=o.angle(90-a)().coordinates[0],e=r.length-1,i=-1;for(t.lineStart();++i<e;)t.point((n=r[i])[0],n[1]);for(t.lineEnd(),r=o.angle(90+a)().coordinates[0],e=r.length-1,t.lineStart();--i>=0;)t.point((n=r[i])[0],n[1]);t.lineEnd(),t.polygonEnd()},t},a}function sn(t,n){function a(a,r){var e=qa(a/n,r);return e[0]*=t,e}return arguments.length<2&&(n=t),1===n?qa:1/0===n?fn:(a.invert=function(a,r){var e=qa.invert(a/t,r);return e[0]*=n,e},a)}function cn(){var t=2,n=ha(sn),a=n(t);return a.coefficient=function(a){return arguments.length?n(t=+a):t},a}function fn(t,n){return[t*Math.cos(n)/Math.cos(n/=2),2*Math.sin(n)]}function vn(t,n){for(var a,r=Math.sin(n)*(0>n?2.43763:2.67595),e=0;20>e&&(n-=a=(n+Math.sin(n)-r)/(1+Math.cos(n)),!(Math.abs(a)<ta));e++);return[.85*t*Math.cos(n*=.5),Math.sin(n)*(0>n?1.93052:1.75859)]}function ln(t){function n(n,s){var c,f=Math.abs(s);if(f>r){var v=Math.min(t-1,Math.max(0,Math.floor((n+aa)/M)));n+=aa*(t-1)/t-v*M,c=d3.geo.collignon.raw(n,f),c[0]=c[0]*e/o-e*(t-1)/(2*t)+v*e/t,c[1]=i+4*(c[1]-h)*u/e,0>s&&(c[1]=-c[1])}else c=a(n,s);return c[0]/=2,c}var a=d3.geo.cylindricalEqualArea.raw(0),r=wa*aa/180,e=2*aa,o=d3.geo.collignon.raw(aa,r)[0]-d3.geo.collignon.raw(-aa,r)[0],i=a(0,r)[1],h=d3.geo.collignon.raw(0,r)[1],u=d3.geo.collignon.raw(0,aa/2)[1]-h,M=2*aa/t;return n.invert=function(n,r){n*=2;var s=Math.abs(r);if(s>i){var c=Math.min(t-1,Math.max(0,Math.floor((n+aa)/M)));n=(n+aa*(t-1)/t-c*M)*o/e;var f=d3.geo.collignon.raw.invert(n,.25*(s-i)*e/u+h);return f[0]-=aa*(t-1)/t-c*M,0>r&&(f[1]=-f[1]),f}return a.invert(n,r)},n}function gn(){function t(){var t=180/n;return{type:"Polygon",coordinates:[d3.range(-180,180+t/2,t).map(function(t,n){return[t,1&n?90-1e-6:wa]}).concat(d3.range(180,-180-t/2,-t).map(function(t,n){return[t,1&n?-90+1e-6:-wa]}))]}}var n=2,a=ha(ln),r=a(n),e=r.stream;return r.lobes=function(t){return arguments.length?a(n=+t):n},r.stream=function(n){var a=r.rotate(),o=e(n),i=(r.rotate([0,0]),e(n));return r.rotate(a),o.sphere=function(){d3.geo.stream(t(),i)},o},r}function dn(t){function n(n,a){var r,i,f=1-Math.sin(a);if(f&&2>f){var v,l=aa/2-a,g=25;do{var d=Math.sin(l),p=Math.cos(l),b=h+Math.atan2(d,o-p),q=1+c-2*o*p;l-=v=(l-s*h-o*d+q*b-.5*f*e)/(2*o*d*b)}while(Math.abs(v)>na&&--g>0);r=u*Math.sqrt(q),i=n*b/aa}else r=u*(t+f),i=n*h/aa;return[r*Math.sin(i),M-r*Math.cos(i)]}var e,o=1+t,i=Math.sin(1/o),h=a(i),u=2*Math.sqrt(aa/(e=aa+4*h*o)),M=.5*u*(o+Math.sqrt(t*(2+t))),s=t*t,c=o*o;return n.invert=function(t,n){var i=t*t+(n-=M)*n,f=(1+c-i/(u*u))/(2*o),v=r(f),l=Math.sin(v),g=h+Math.atan2(l,o-f);return[a(t/Math.sqrt(i))*aa/g,a(1-2*(v-s*h-o*l+(1+c-2*o*f)*g)/e)]},n}function pn(){var t=1,n=ha(dn),a=n(t);return a.ratio=function(a){return arguments.length?n(t=+a):t},a}function bn(t,n){return n>-ma?(t=ca(t,n),t[1]+=Sa,t):T(t,n)}function qn(t,n){return Math.abs(n)>ma?(t=ca(t,n),t[1]-=n>0?Sa:-Sa,t):T(t,n)}function wn(t,n){return[3*t/(2*aa)*Math.sqrt(aa*aa/3-n*n),n]}function mn(t){function r(n,a){if(Math.abs(Math.abs(a)-aa/2)<ta)return[0,0>a?-2:2];var r=Math.sin(a),e=Math.pow((1+r)/(1-r),t/2),o=.5*(e+1/e)+Math.cos(n*=t);return[2*Math.sin(n)/o,(e-1/e)/o]}return r.invert=function(r,e){var o=Math.abs(e);if(Math.abs(o-2)<ta)return r?null:[0,n(e)*aa/2];if(o>2)return null;r/=2,e/=2;var i=r*r,h=e*e,u=2*e/(1+i+h);return u=Math.pow((1+u)/(1-u),1/t),[Math.atan2(2*r,1-i-h)/t,a((u-1)/(u+1))]},r}function Sn(){var t=.5,n=ha(mn),a=n(t);return a.spacing=function(a){return arguments.length?n(t=+a):t},a}function Tn(t,n){return[t*(1+Math.sqrt(Math.cos(n)))/2,n/(Math.cos(n/2)*Math.cos(t/6))]}function An(t,n){var a=t*t,r=n*n;return[t*(.975534+r*(-.119161+a*-.0143059+r*-.0547009)),n*(1.00384+a*(.0802894+r*-.02855+199025e-9*a)+r*(.0998909+r*-.0491032))]}function Qn(t,n){return[Math.sin(t)/Math.cos(n),Math.tan(n)*Math.cos(t)]}function Rn(t){function n(n,e){var o=e-t,i=Math.abs(o)<ta?n*a:Math.abs(i=aa/4+e/2)<ta||Math.abs(Math.abs(i)-aa/2)<ta?0:n*o/Math.log(Math.tan(i)/r);return[i,o]}var a=Math.cos(t),r=Math.tan(aa/4+t/2);return n.invert=function(n,e){var o,i=e+t;return[Math.abs(e)<ta?n/a:Math.abs(o=aa/4+i/2)<ta||Math.abs(Math.abs(o)-aa/2)<ta?0:n*Math.log(Math.tan(o)/r)/e,i]},n}function yn(t,n){return[t,1.25*Math.log(Math.tan(aa/4+.4*n))]}function Gn(t){function n(n,a){for(var e,o=Math.cos(a),i=2/(1+o*Math.cos(n)),h=i*o*Math.sin(n),u=i*Math.sin(a),M=r,s=t[M],c=s[0],f=s[1];--M>=0;)s=t[M],c=s[0]+h*(e=c)-u*f,f=s[1]+h*f+u*e;return c=h*(e=c)-u*f,f=h*f+u*e,[c,f]}var r=t.length-1;return n.invert=function(n,e){var o=20,i=n,h=e;do{for(var u,M=r,s=t[M],c=s[0],f=s[1],v=0,l=0;--M>=0;)s=t[M],v=c+i*(u=v)-h*l,l=f+i*l+h*u,c=s[0]+i*(u=c)-h*f,f=s[1]+i*f+h*u;v=c+i*(u=v)-h*l,l=f+i*l+h*u,c=i*(u=c)-h*f-n,f=i*f+h*u-e;var g,d,p=v*v+l*l;i-=g=(c*v+f*l)/p,h-=d=(f*v-c*l)/p}while(Math.abs(g)+Math.abs(d)>ta*ta&&--o>0);if(o){var b=Math.sqrt(i*i+h*h),q=2*Math.atan(.5*b),w=Math.sin(q);return[Math.atan2(i*w,b*Math.cos(q)),b?a(h*w/b):0]}},n}function Pn(){var t=Ta.miller,n=ha(Gn),a=n(t);return a.coefficients=function(a){return arguments.length?n(t="string"==typeof a?Ta[a]:a):t},a}function xn(t,n){var a=Math.sqrt(6),r=Math.sqrt(7),e=Math.asin(7*Math.sin(n)/(3*a));return[a*t*(2*Math.cos(2*e/3)-1)/r,9*Math.sin(e/3)/r]}function En(t,n){for(var a,r=(1+Math.SQRT1_2)*Math.sin(n),e=n,o=0;25>o&&(e-=a=(Math.sin(e/2)+Math.sin(e)-r)/(.5*Math.cos(e/2)+Math.cos(e)),!(Math.abs(a)<ta));o++);return[t*(1+2*Math.cos(e)/Math.cos(e/2))/(3*Math.SQRT2),2*Math.sqrt(3)*Math.sin(e/2)/Math.sqrt(2+Math.SQRT2)]}function Bn(t,n){for(var a,r=Math.sqrt(6/(4+aa)),e=(1+aa/4)*Math.sin(n),o=n/2,i=0;25>i&&(o-=a=(o/2+Math.sin(o)-e)/(.5+Math.cos(o)),!(Math.abs(a)<ta));i++);return[r*(.5+Math.cos(o))*t/1.5,r*o]}function kn(t,n){var a=n*n,r=a*a;return[t*(.8707-.131979*a+r*(-.013791+r*(.003971*a-.001529*r))),n*(1.007226+a*(.015085+r*(-.044475+.028874*a-.005916*r)))]}function Dn(t,n){return[t*(1+Math.cos(n))/2,2*(n-Math.tan(n/2))]}function _n(t,n){if(Math.abs(n)<ta)return[t,0];var a=Math.tan(n),r=t*Math.sin(n);return[Math.sin(r)/a,n+(1-Math.cos(r))/a]}function Fn(t){function n(n,a){var r=e?Math.tan(n*e/2)/e:n/2;if(!a)return[2*r,-t];var o=2*Math.atan(r*Math.sin(a)),i=1/Math.tan(a);return[Math.sin(o)*i,a+(1-Math.cos(o))*i-t]}var e=Math.sin(t);return n.invert=function(n,o){if(Math.abs(o+=t)<ta)return[e?2*Math.atan(e*n/2)/e:n,0];var i,h=n*n+o*o,u=0,M=10;do{var s=Math.tan(u),c=1/Math.cos(u),f=h-2*o*u+u*u;u-=i=(s*f+2*(u-o))/(2+f*c*c+2*(u-o)*s)}while(Math.abs(i)>ta&&--M>0);var v=n*(s=Math.tan(u)),l=Math.tan(Math.abs(o)<Math.abs(u+1/s)?.5*a(v):.5*r(v)+aa/4)/Math.sin(u);return[e?2*Math.atan(e*l)/e:2*l,u]},n}function zn(t,n){var a,r=Math.min(18,36*Math.abs(n)/aa),e=Math.floor(r),o=r-e,i=(a=Qa[e])[0],h=a[1],u=(a=Qa[++e])[0],M=a[1],s=(a=Qa[Math.min(19,++e)])[0],c=a[1];return[t*(u+o*(s-i)/2+o*o*(s-2*u+i)/2),(n>0?aa:-aa)/2*(M+o*(c-h)/2+o*o*(c-2*M+h)/2)]}function Cn(t){function n(n,a){var r=Math.cos(a),e=(t-1)/(t-r*Math.cos(n));return[e*r*Math.sin(n),e*Math.sin(a)]}return n.invert=function(n,r){var e=n*n+r*r,o=Math.sqrt(e),i=(t-Math.sqrt(1-e*(t+1)/(t-1)))/((t-1)/o+o/(t-1));return[Math.atan2(n*i,o*Math.sqrt(1-i*i)),o?a(r*i/o):0]},n}function jn(t,n){function a(n,a){var i=r(n,a),h=i[1],u=h*o/(t-1)+e;return[i[0]*e/u,h/u]}var r=Cn(t);if(!n)return r;var e=Math.cos(n),o=Math.sin(n);return a.invert=function(n,a){var i=(t-1)/(t-1-a*o);return r.invert(i*n,i*a*e)},a}function Hn(){var t=1.4,n=0,a=ha(jn),r=a(t,n);return r.distance=function(r){return arguments.length?a(t=+r,n):t},r.tilt=function(r){return arguments.length?a(t,n=r*aa/180):180*n/aa},r}function In(t,n){var a=Math.tan(n/2),r=Math.sin(aa/4*a);return[t*(.74482-.34588*r*r),1.70711*a]}function Kn(t){function n(n,h){var u=r(Math.cos(h)*Math.cos(n-a)),M=r(Math.cos(h)*Math.cos(n-o)),s=0>h?-1:1;return u*=u,M*=M,[(u-M)/(2*t),s*e(4*i*M-(i-u+M)*(i-u+M))/(2*t)]}if(!t)return d3.geo.azimuthalEquidistant.raw;var a=-t/2,o=-a,i=t*t,h=Math.tan(o),u=.5/Math.sin(o);return n.invert=function(t,n){var e,i,M=n*n,s=Math.cos(Math.sqrt(M+(e=t+a)*e)),c=Math.cos(Math.sqrt(M+(e=t+o)*e));return[Math.atan2(i=s-c,e=(s+c)*h),(0>n?-1:1)*r(Math.sqrt(e*e+i*i)*u)]},n}function Jn(){var t=[[0,0],[0,0]],n=ha(Kn),r=n(0),e=r.rotate;return delete r.rotate,r.points=function(r){if(!arguments.length)return t;t=r;var o=d3.geo.interpolate(r[0],r[1]),i=o(.5),h=d3.geo.rotation([-i[0],-i[1]])(r[0]),u=.5*o.distance,M=(h[0]<0?-1:1)*h[1]*ea,s=a(Math.sin(M)/Math.sin(u));return e.call(h,[-i[0],-i[1],-s*oa]),n(2*u)},r}function Ln(t){function n(t,n){var r=d3.geo.gnomonic.raw(t,n);return r[0]*=a,r}var a=Math.cos(t);return n.invert=function(t,n){return d3.geo.gnomonic.raw.invert(t/a,n)},n}function Nn(){var t=[[0,0],[0,0]],n=ha(Ln),r=n(0),e=r.rotate;return delete r.rotate,r.points=function(r){if(!arguments.length)return t;t=r;var o=d3.geo.interpolate(r[0],r[1]),i=o(.5),h=twoPointEquidistant_rotate(-i[0]*ea,-i[1]*ea,r[0][0]*ea,r[0][1]*ea),u=.5*o.distance,M=(h[0]<0?-1:1)*h[1],s=a(Math.sin(M)/Math.sin(u));return e.call(h,[-i[0],-i[1],-s*oa]),n(u)},r}function On(t,r){if(Math.abs(r)<ta)return[t,0];var e=Math.abs(2*r/aa),o=a(e);if(Math.abs(t)<ta||Math.abs(Math.abs(r)-aa/2)<ta)return[0,n(r)*aa*Math.tan(o/2)];var i=Math.cos(o),h=Math.abs(aa/t-t/aa)/2,u=h*h,M=i/(e+i-1),s=M*(2/e-1),c=s*s,f=c+u,v=M-c,l=u+M;return[n(t)*aa*(h*v+Math.sqrt(u*v*v-f*(M*M-c)))/f,n(r)*aa*(s*l-h*Math.sqrt((u+1)*f-l*l))/f]}function Un(t,r){if(Math.abs(r)<ta)return[t,0];var o=Math.abs(2*r/aa),i=a(o);if(Math.abs(t)<ta||Math.abs(Math.abs(r)-aa/2)<ta)return[0,n(r)*aa*Math.tan(i/2)];var h=Math.cos(i),u=Math.abs(aa/t-t/aa)/2,M=u*u,s=h*(Math.sqrt(1+M)-u*h)/(1+M*o*o);return[n(t)*aa*s,n(r)*aa*e(1-s*(2*u+s))]}function Vn(t,r){if(Math.abs(r)<ta)return[t,0];var o=2*r/aa,i=a(o);if(Math.abs(t)<ta||Math.abs(Math.abs(r)-aa/2)<ta)return[0,aa*Math.tan(i/2)];var h=(aa/t-t/aa)/2,u=o/(1+Math.cos(i));return[aa*(n(t)*e(h*h+1-u*u)-h),aa*u]}function Wn(t,a){if(!a)return[t,0];var r=Math.abs(a);if(!t||r===aa/2)return[0,a];var o=2*r/aa,i=o*o,h=(8*o-i*(i+2)-5)/(2*i*(o-1)),u=h*h,M=o*h,s=i+u+2*M,c=o+3*h,f=2*t/aa,v=f+1/f,l=n(Math.abs(t)-aa/2)*Math.sqrt(v*v-4),g=l*l,d=s*(i+u*g-1)+(1-i)*(i*(c*c+4*u)+12*M*u+4*u*u),p=(l*(s+u-1)+2*e(d))/(4*s+g);return[n(t)*aa*p/2,n(a)*aa/2*e(1+l*Math.abs(p)-p*p)]}function Xn(t,n){return[t*Math.sqrt(1-3*n*n/(aa*aa)),n]}function Yn(t,n){var a=.90631*Math.sin(n),r=Math.sqrt(1-a*a),e=Math.sqrt(2/(1+r*Math.cos(t/=3)));return[2.66723*r*e*Math.sin(t),1.24104*a*e]}function Zn(t,n){var a=Math.cos(n),r=Math.cos(t)*a,o=1-r,i=Math.cos(t=Math.atan2(Math.sin(t)*a,-Math.sin(n))),h=Math.sin(t);return a=e(1-r*r),[h*a-i*o,-i*a-h*o]}function $n(t,n){var a=h(t,n);return[(a[0]+2*t/aa)/2,(a[1]+n)/2]}var ta=1e-6,na=ta*ta,aa=Math.PI,ra=Math.sqrt(aa),ea=aa/180,oa=180/aa,ia=d3.geo.projection,ha=d3.geo.projectionMutator;d3.geo.interrupt=function(t){function n(n,a){for(var r=0>a?-1:1,e=h[+(0>a)],o=0,i=e.length-1;i>o&&n>e[o][2][0];++o);var u=t(n-e[o][1][0],a);return u[0]+=t(e[o][1][0],r*a>r*e[o][0][1]?e[o][0][1]:a)[0],u}function a(){i=h.map(function(n){return n.map(function(n){var a,r=t(n[0][0],n[0][1])[0],e=t(n[2][0],n[2][1])[0],o=t(n[1][0],n[0][1])[1],i=t(n[1][0],n[1][1])[1];return o>i&&(a=o,o=i,i=a),[[r,o],[e,i]]})})}function r(){for(var t=1e-6,n=[],a=0,r=h[0].length;r>a;++a){var o=h[0][a],i=180*o[0][0]/aa,u=180*o[0][1]/aa,M=180*o[1][1]/aa,s=180*o[2][0]/aa,c=180*o[2][1]/aa;n.push(e([[i+t,u+t],[i+t,M-t],[s-t,M-t],[s-t,c+t]],30))}for(var a=h[1].length-1;a>=0;--a){var o=h[1][a],i=180*o[0][0]/aa,u=180*o[0][1]/aa,M=180*o[1][1]/aa,s=180*o[2][0]/aa,c=180*o[2][1]/aa;n.push(e([[s-t,c-t],[s-t,M+t],[i+t,M+t],[i+t,u-t]],30))}return{type:"Polygon",coordinates:[d3.merge(n)]}}function e(t,n){for(var a,r,e,o=-1,i=t.length,h=t[0],u=[];++o<i;){a=t[o],r=(a[0]-h[0])/n,e=(a[1]-h[1])/n;for(var M=0;n>M;++M)u.push([h[0]+M*r,h[1]+M*e]);h=a}return u.push(a),u}function o(t,n){return Math.abs(t[0]-n[0])<ta&&Math.abs(t[1]-n[1])<ta}var i,h=[[[[-aa,0],[0,aa/2],[aa,0]]],[[[-aa,0],[0,-aa/2],[aa,0]]]];t.invert&&(n.invert=function(a,r){for(var e=i[+(0>r)],u=h[+(0>r)],M=0,s=e.length;s>M;++M){var c=e[M];
if(c[0][0]<=a&&a<c[1][0]&&c[0][1]<=r&&r<c[1][1]){var f=t.invert(a-t(u[M][1][0],0)[0],r);return f[0]+=u[M][1][0],o(n(f[0],f[1]),[a,r])?f:null}}});var u=d3.geo.projection(n),M=u.stream;return u.stream=function(t){var n=u.rotate(),a=M(t),e=(u.rotate([0,0]),M(t));return u.rotate(n),a.sphere=function(){d3.geo.stream(r(),e)},a},u.lobes=function(t){return arguments.length?(h=t.map(function(t){return t.map(function(t){return[[t[0][0]*aa/180,t[0][1]*aa/180],[t[1][0]*aa/180,t[1][1]*aa/180],[t[2][0]*aa/180,t[2][1]*aa/180]]})}),a(),u):h.map(function(t){return t.map(function(t){return[[180*t[0][0]/aa,180*t[0][1]/aa],[180*t[1][0]/aa,180*t[1][1]/aa],[180*t[2][0]/aa,180*t[2][1]/aa]]})})},u},(d3.geo.airy=i).raw=o,h.invert=function(t,n){var a=t,e=n,o=25;do{var i,h=Math.sin(a),u=Math.sin(a/2),M=Math.cos(a/2),s=Math.sin(e),c=Math.cos(e),f=Math.sin(2*e),v=s*s,l=c*c,g=u*u,d=1-l*M*M,p=d?r(c*M)*Math.sqrt(i=1/d):i=0,b=2*p*c*u-t,q=p*s-n,w=i*(l*g+p*c*M*v),m=i*(.5*h*f-2*p*s*u),S=.25*i*(f*u-p*s*l*h),T=i*(v*M+p*g*c),A=m*S-T*w;if(!A)break;var Q=(q*m-b*T)/A,R=(b*S-q*w)/A;a-=Q,e-=R}while((Math.abs(Q)>ta||Math.abs(R)>ta)&&--o>0);return[a,e]},(d3.geo.aitoff=function(){return ia(h)}).raw=h,(d3.geo.armadillo=M).raw=u,g.invert=function(t,r){if(t*=3/8,r*=3/8,!t&&Math.abs(r)>1)return null;var e=t*t,o=r*r,i=1+e+o,h=Math.sqrt(.5*(i-Math.sqrt(i*i-4*r*r))),u=a(h)/3,M=h?l(Math.abs(r/h))/3:v(Math.abs(t))/3,s=Math.cos(u),g=f(M),d=g*g-s*s;return[2*n(t)*Math.atan2(c(M)*s,.25-d),2*n(r)*Math.atan2(g*Math.sin(u),.25+d)]},(d3.geo.august=function(){return ia(g)}).raw=g;var ua=Math.log(1+Math.SQRT2);d.invert=function(t,a){if((e=Math.abs(a))<ua)return[t,2*Math.atan(Math.exp(a))-aa/2];var r,e,o=Math.sqrt(8),i=aa/4,h=25;do{var u=Math.cos(i/2),M=Math.tan(i/2);i-=r=(o*(i-aa/4)-Math.log(M)-e)/(o-.5*u*u/M)}while(Math.abs(r)>na&&--h>0);return[t/(Math.cos(i)*(o-1/Math.sin(i))),n(a)*i]},(d3.geo.baker=function(){return ia(d)}).raw=d;var Ma=d3.geo.azimuthalEquidistant.raw;(d3.geo.berghaus=b).raw=p;var sa=q(aa),ca=w(2*Math.SQRT2/aa,Math.SQRT2,aa);(d3.geo.mollweide=function(){return ia(ca)}).raw=ca,m.invert=function(t,n){var a,r,e=2.00276,o=e*n,i=0>n?-aa/4:aa/4,h=25;do r=o-Math.SQRT2*Math.sin(i),i-=a=(Math.sin(2*i)+2*i-aa*Math.sin(r))/(2*Math.cos(2*i)+2+aa*Math.cos(r)*Math.SQRT2*Math.cos(i));while(Math.abs(a)>ta&&--h>0);return r=o-Math.SQRT2*Math.sin(i),[t*(1/Math.cos(r)+1.11072/Math.cos(i))/e,r]},(d3.geo.boggs=function(){return ia(m)}).raw=m,T.invert=function(t,n){return[t/Math.cos(n),n]},(d3.geo.sinusoidal=function(){return ia(T)}).raw=T,(d3.geo.bonne=function(){return S(A).parallel(45)}).raw=A;var fa=w(1,4/aa,aa);(d3.geo.bromley=function(){return ia(fa)}).raw=fa,(d3.geo.cahillKeyes=R).raw=Q,(d3.geo.chamberlin=G).raw=y,k.invert=function(t,n){var r=(r=n/ra-1)*r;return[r>0?t*Math.sqrt(aa/r)/2:0,a(1-r)]},(d3.geo.collignon=function(){return ia(k)}).raw=k,(d3.geo.craig=function(){return S(D)}).raw=D,_.invert=function(t,n){var r=Math.sqrt(3),e=3*a(n/(r*ra));return[ra*t/(r*(2*Math.cos(2*e/3)-1)),e]},(d3.geo.craster=function(){return ia(_)}).raw=_,(d3.geo.cylindricalEqualArea=function(){return S(F)}).raw=F,(d3.geo.cylindricalStereographic=function(){return S(z)}).raw=z,C.invert=function(t,n){var a=Math.sqrt(8/(3*aa)),r=n/a;return[t/(a*(1-Math.abs(r)/aa)),r]},(d3.geo.eckert1=function(){return ia(C)}).raw=C,j.invert=function(t,r){var e=2-Math.abs(r)/Math.sqrt(2*aa/3);return[t*Math.sqrt(6*aa)/(2*e),n(r)*a((4-e*e)/3)]},(d3.geo.eckert2=function(){return ia(j)}).raw=j,H.invert=function(t,n){var a=Math.sqrt(aa*(4+aa))/2;return[t*a/(1+e(1-n*n*(4+aa)/(4*aa))),n*a/2]},(d3.geo.eckert3=function(){return ia(H)}).raw=H,I.invert=function(t,n){var r=.5*n*Math.sqrt((4+aa)/aa),e=a(r),o=Math.cos(e);return[t/(2/Math.sqrt(aa*(4+aa))*(1+o)),a((e+r*(o+2))/(2+aa/2))]},(d3.geo.eckert4=function(){return ia(I)}).raw=I,K.invert=function(t,n){var a=Math.sqrt(2+aa),r=n*a/2;return[a*t/(1+Math.cos(r)),r]},(d3.geo.eckert5=function(){return ia(K)}).raw=K,J.invert=function(t,n){var r=1+aa/2,e=Math.sqrt(r/2);return[2*t*e/(1+Math.cos(n*=e)),a((n+Math.sin(n))/r)]},(d3.geo.eckert6=function(){return ia(J)}).raw=J,L.invert=function(t,n){var a=d3.geo.august.raw.invert(t/1.2,1.065*n);if(!a)return null;var r=a[0],e=a[1],o=20;t/=va,n/=va;do{var i=r/2,h=e/2,u=Math.sin(i),M=Math.cos(i),s=Math.sin(h),c=Math.cos(h),f=Math.cos(e),v=Math.sqrt(f),l=s/(c+Math.SQRT2*M*v),g=l*l,d=Math.sqrt(2/(1+g)),p=Math.SQRT2*c+(M+u)*v,b=Math.SQRT2*c+(M-u)*v,q=p/b,w=Math.sqrt(q),m=w-1/w,S=w+1/w,T=d*m-2*Math.log(w)-t,A=d*l*S-2*Math.atan(l)-n,Q=s&&Math.SQRT1_2*v*u*g/s,R=(Math.SQRT2*M*c+v)/(2*(c+Math.SQRT2*M*v)*(c+Math.SQRT2*M*v)*v),y=-.5*l*d*d*d,G=y*Q,P=y*R,x=(x=2*c+Math.SQRT2*v*(M-u))*x*w,E=(Math.SQRT2*M*c*v+f)/x,B=-(Math.SQRT2*u*s)/(v*x),k=m*G-2*E/w+d*(E+E/q),D=m*P-2*B/w+d*(B+B/q),_=l*S*G-2*Q/(1+g)+d*S*Q+d*l*(E-E/q),F=l*S*P-2*R/(1+g)+d*S*R+d*l*(B-B/q),z=D*_-F*k;if(!z)break;var C=(A*D-T*F)/z,j=(T*_-A*k)/z;r-=C,e=Math.max(-aa/2,Math.min(aa/2,e-j))}while((Math.abs(C)>ta||Math.abs(j)>ta)&&--o>0);return Math.abs(Math.abs(e)-aa/2)<ta?[0,e]:o&&[r,e]};var va=3+2*Math.SQRT2;(d3.geo.eisenlohr=function(){return ia(L)}).raw=L,N.invert=function(t,n){var a=n/(1+la);return[t?t/(la*e(1-a*a)):0,2*Math.atan(a)]};var la=Math.cos(35*ea);(d3.geo.fahey=function(){return ia(N)}).raw=N,O.invert=function(t,n){var a=Math.atan(n/ra),r=Math.cos(a),e=2*a;return[.5*t*ra/(Math.cos(e)*r*r),e]},(d3.geo.foucaut=function(){return ia(O)}).raw=O,d3.geo.gilbert=function(t){function n(n){return t([.5*n[0],a(Math.tan(.5*n[1]*ea))*oa])}var r=d3.geo.equirectangular().scale(oa).translate([0,0]);return t.invert&&(n.invert=function(n){return n=t.invert(n),n[0]*=2,n[1]=2*Math.atan(Math.sin(n[1]*ea))*oa,n}),n.stream=function(n){n=t.stream(n);var e=r.stream({point:function(t,r){n.point(.5*t,a(Math.tan(.5*-r*ea))*oa)},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}});return e.sphere=function(){n.sphere()},e.valid=!1,e},n};var ga=U(2.8284,-1.6988,.75432,-.18071,1.76003,-.38914,.042555);(d3.geo.ginzburg4=function(){return ia(ga)}).raw=ga;var da=U(2.583819,-.835827,.170354,-.038094,1.543313,-.411435,.082742);(d3.geo.ginzburg5=function(){return ia(da)}).raw=da;var pa=U(5/6*aa,-.62636,-.0344,0,1.3493,-.05524,0,.045);(d3.geo.ginzburg6=function(){return ia(pa)}).raw=pa,V.invert=function(t,n){var a,r=t,e=n,o=50;do{var i=e*e;e-=a=(e*(1+i/12)-n)/(1+i/4)}while(Math.abs(a)>ta&&--o>0);o=50,t/=1-.162388*i;do{var h=(h=r*r)*h;r-=a=(r*(.87-952426e-9*h)-t)/(.87-.00476213*h)}while(Math.abs(a)>ta&&--o>0);return[r,e]},(d3.geo.ginzburg8=function(){return ia(V)}).raw=V;var ba=U(2.6516,-.76534,.19123,-.047094,1.36289,-.13965,.031762);(d3.geo.ginzburg9=function(){return ia(ba)}).raw=ba,X.invert=function(t,r){var e=n(t),o=n(r),i=-e*t,h=-o*r,u=1>h/i,M=Z(u?h:i,u?i:h),s=M[0],c=M[1];u&&(s=-aa/2-s);var f=Math.cos(c),t=Math.cos(s)*f,r=Math.sin(s)*f,v=Math.sin(c);return[e*(Math.atan2(r,-v)+aa),o*a(t)]},d3.geo.gringorten=W(X),rn.invert=function(t,n){var a=(Math.SQRT2-1)/(Math.SQRT2+1),r=Math.sqrt(1-a*a),e=an(aa/2,r*r),o=-1,i=$(.5*e-n,-t,r*r),h=on(i[0],i[1]),u=Math.atan2(h[1],h[0])/o;return[u,2*Math.atan(Math.exp(.5/o*Math.log(a*h[0]*h[0]+a*h[1]*h[1])))-aa/2]},d3.geo.guyou=W(rn),(d3.geo.hammerRetroazimuthal=Mn).raw=hn;var qa=d3.geo.azimuthalEqualArea.raw;fn.invert=function(t,n){var r=2*a(n/2);return[t*Math.cos(r/2)/Math.cos(r),r]},(d3.geo.hammer=cn).raw=sn,vn.invert=function(t,n){var r=Math.abs(r=n*(0>n?.5179951515653813:.5686373742600607))>1-ta?r>0?aa/2:-aa/2:a(r);return[1.1764705882352942*t/Math.cos(r),Math.abs(r=((r+=r)+Math.sin(r))*(0>n?.4102345310814193:.3736990601468637))>1-ta?r>0?aa/2:-aa/2:a(r)]},(d3.geo.hatano=function(){return ia(vn)}).raw=vn;var wa=41+48/36+37/3600;(d3.geo.healpix=gn).raw=ln,(d3.geo.hill=pn).raw=dn;var ma=.7109889596207567,Sa=.0528035274542;bn.invert=function(t,n){return n>-ma?ca.invert(t,n-Sa):T.invert(t,n)},(d3.geo.sinuMollweide=function(){return ia(bn).rotate([-20,-55])}).raw=bn,qn.invert=function(t,n){return Math.abs(n)>ma?ca.invert(t,n+(n>0?Sa:-Sa)):T.invert(t,n)},(d3.geo.homolosine=function(){return ia(qn)}).raw=qn,wn.invert=function(t,n){return[2/3*aa*t/Math.sqrt(aa*aa/3-n*n),n]},(d3.geo.kavrayskiy7=function(){return ia(wn)}).raw=wn,(d3.geo.lagrange=Sn).raw=mn,Tn.invert=function(t,n){var a=Math.abs(t),o=Math.abs(n),i=aa/Math.SQRT2,h=ta,u=aa/2;i>o?u*=o/i:h+=6*r(i/o);for(var M=0;25>M;M++){var s=Math.sin(u),c=e(Math.cos(u)),f=Math.sin(u/2),v=Math.cos(u/2),l=Math.sin(h/6),g=Math.cos(h/6),d=.5*h*(1+c)-a,p=u/(v*g)-o,b=c?-.25*h*s/c:0,q=.5*(1+c),w=(1+.5*u*f/v)/(v*g),m=u/v*(l/6)/(g*g),S=b*m-w*q,T=(d*m-p*q)/S,A=(p*b-d*w)/S;if(u-=T,h-=A,Math.abs(T)<ta&&Math.abs(A)<ta)break}return[0>t?-h:h,0>n?-u:u]},(d3.geo.larrivee=function(){return ia(Tn)}).raw=Tn,An.invert=function(t,a){var r=n(t)*aa,e=a/2,o=50;do{var i=r*r,h=e*e,u=r*e,M=r*(.975534+h*(-.119161+i*-.0143059+h*-.0547009))-t,s=e*(1.00384+i*(.0802894+h*-.02855+199025e-9*i)+h*(.0998909+h*-.0491032))-a,c=.975534-h*(.119161+.0143059*3*i+.0547009*h),f=-u*(.238322+.2188036*h+.0286118*i),v=u*(.1605788+7961e-7*i+-0.0571*h),l=1.00384+i*(.0802894+199025e-9*i)+h*(3*(.0998909-.02855*i)-.245516*h),g=f*v-l*c,d=(s*f-M*l)/g,p=(M*v-s*c)/g;r-=d,e-=p}while((Math.abs(d)>ta||Math.abs(p)>ta)&&--o>0);return o&&[r,e]},(d3.geo.laskowski=function(){return ia(An)}).raw=An,Qn.invert=function(t,e){var o=t*t,i=e*e,h=i+1,u=t?Math.SQRT1_2*Math.sqrt((h-Math.sqrt(o*o+2*o*(i-1)+h*h))/o+1):1/Math.sqrt(h);return[a(t*u),n(e)*r(u)]},(d3.geo.littrow=function(){return ia(Qn)}).raw=Qn,(d3.geo.loximuthal=function(){return S(Rn).parallel(40)}).raw=Rn,yn.invert=function(t,n){return[t,2.5*Math.atan(Math.exp(.8*n))-.625*aa]},(d3.geo.miller=function(){return ia(yn)}).raw=yn;var Ta={alaska:[[.9972523,0],[.0052513,-.0041175],[.0074606,.0048125],[-.0153783,-.1968253],[.0636871,-.1408027],[.3660976,-.2937382]],gs48:[[.98879,0],[0,0],[-.050909,0],[0,0],[.075528,0]],gs50:[[.984299,0],[.0211642,.0037608],[-.1036018,-.0575102],[-.0329095,-.0320119],[.0499471,.1223335],[.026046,.0899805],[7388e-7,-.1435792],[.0075848,-.1334108],[-.0216473,.0776645],[-.0225161,.0853673]],miller:[[.9245,0],[0,0],[.01943,0]],lee:[[.721316,0],[0,0],[-.00881625,-.00617325]]};(d3.geo.modifiedStereographic=Pn).raw=Gn,xn.invert=function(t,n){var r=Math.sqrt(6),e=Math.sqrt(7),o=3*a(n*e/9);return[t*e/(r*(2*Math.cos(2*o/3)-1)),a(3*Math.sin(o)*r/7)]},(d3.geo.mtFlatPolarParabolic=function(){return ia(xn)}).raw=xn,En.invert=function(t,n){var r=n*Math.sqrt(2+Math.SQRT2)/(2*Math.sqrt(3)),e=2*a(r);return[3*Math.SQRT2*t/(1+2*Math.cos(e)/Math.cos(e/2)),a((r+Math.sin(e))/(1+Math.SQRT1_2))]},(d3.geo.mtFlatPolarQuartic=function(){return ia(En)}).raw=En,Bn.invert=function(t,n){var r=Math.sqrt(6/(4+aa)),e=n/r;return Math.abs(Math.abs(e)-aa/2)<ta&&(e=0>e?-aa/2:aa/2),[1.5*t/(r*(.5+Math.cos(e))),a((e/2+Math.sin(e))/(1+aa/4))]},(d3.geo.mtFlatPolarSinusoidal=function(){return ia(Bn)}).raw=Bn,kn.invert=function(t,n){var a,r=n,e=25;do{var o=r*r,i=o*o;r-=a=(r*(1.007226+o*(.015085+i*(-.044475+.028874*o-.005916*i)))-n)/(1.007226+o*(.045255+i*(-0.311325+.259866*o-.005916*11*i)))}while(Math.abs(a)>ta&&--e>0);return[t/(.8707+(o=r*r)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),r]},(d3.geo.naturalEarth=function(){return ia(kn)}).raw=kn,Dn.invert=function(t,n){for(var a=n/2,r=0,e=1/0;10>r&&Math.abs(e)>ta;r++){var o=Math.cos(n/2);n-=e=(n-Math.tan(n/2)-a)/(1-.5/(o*o))}return[2*t/(1+Math.cos(n)),n]},(d3.geo.nellHammer=function(){return ia(Dn)}).raw=Dn;var Aa=W(rn);(d3.geo.peirceQuincuncial=function(){return Aa().quincuncial(!0).rotate([-90,-90,45]).clipAngle(180-1e-6)}).raw=Aa.raw,_n.invert=function(t,e){if(Math.abs(e)<ta)return[t,0];var o,i=t*t+e*e,h=.5*e,u=10;do{var M=Math.tan(h),s=1/Math.cos(h),c=i-2*e*h+h*h;h-=o=(M*c+2*(h-e))/(2+c*s*s+2*(h-e)*M)}while(Math.abs(o)>ta&&--u>0);return M=Math.tan(h),[(Math.abs(e)<Math.abs(h+1/M)?a(t*M):n(t)*(r(Math.abs(t*M))+aa/2))/Math.sin(h),h]},(d3.geo.polyconic=function(){return ia(_n)}).raw=_n,(d3.geo.rectangularPolyconic=function(){return S(Fn)}).raw=Fn;var Qa=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];Qa.forEach(function(t){t[1]*=1.0144}),zn.invert=function(t,n){var a=2*n/aa,r=90*a,e=Math.min(18,Math.abs(r/5)),o=Math.max(0,Math.floor(e));do{var i=Qa[o][1],h=Qa[o+1][1],u=Qa[Math.min(19,o+2)][1],M=u-i,s=u-2*h+i,c=2*(Math.abs(a)-h)/M,f=s/M,v=c*(1-f*c*(1-2*f*c));if(v>=0||1===o){r=(n>=0?5:-5)*(v+e);var l,g=50;do e=Math.min(18,Math.abs(r)/5),o=Math.floor(e),v=e-o,i=Qa[o][1],h=Qa[o+1][1],u=Qa[Math.min(19,o+2)][1],r-=(l=(n>=0?aa:-aa)/2*(h+v*(u-i)/2+v*v*(u-2*h+i)/2)-n)*oa;while(Math.abs(l)>na&&--g>0);break}}while(--o>=0);var d=Qa[o][0],p=Qa[o+1][0],b=Qa[Math.min(19,o+2)][0];return[t/(p+v*(b-d)/2+v*v*(b-2*p+d)/2),r*ea]},(d3.geo.robinson=function(){return ia(zn)}).raw=zn,(d3.geo.satellite=Hn).raw=jn,In.invert=function(t,n){var a=n/1.70711,r=Math.sin(aa/4*a);return[t/(.74482-.34588*r*r),2*Math.atan(a)]},(d3.geo.times=function(){return ia(In)}).raw=In,(d3.geo.twoPointEquidistant=Jn).raw=Kn,(d3.geo.twoPointAzimuthal=Nn).raw=Ln,On.invert=function(t,a){if(Math.abs(a)<ta)return[t,0];if(Math.abs(t)<ta)return[0,aa/2*Math.sin(2*Math.atan(a/aa))];var e=(t/=aa)*t,o=(a/=aa)*a,i=e+o,h=i*i,u=-Math.abs(a)*(1+i),M=u-2*o+e,s=-2*u+1+2*o+h,c=o/s+(2*M*M*M/(s*s*s)-9*u*M/(s*s))/27,f=(u-M*M/(3*s))/s,v=2*Math.sqrt(-f/3),l=r(3*c/(f*v))/3;return[aa*(i-1+Math.sqrt(1+2*(e-o)+h))/(2*t),n(a)*aa*(-v*Math.cos(l+aa/3)-M/(3*s))]},(d3.geo.vanDerGrinten=function(){return ia(On)}).raw=On,Un.invert=function(t,a){if(!t)return[0,aa/2*Math.sin(2*Math.atan(a/aa))];var r=Math.abs(t/aa),e=(1-r*r-(a/=aa)*a)/(2*r),o=e*e,i=Math.sqrt(o+1);return[n(t)*aa*(i-e),n(a)*aa/2*Math.sin(2*Math.atan2(Math.sqrt((1-2*e*r)*(e+i)-r),Math.sqrt(i+e+r)))]},(d3.geo.vanDerGrinten2=function(){return ia(Un)}).raw=Un,Vn.invert=function(t,a){if(!a)return[t,0];var r=a/aa,e=(aa*aa*(1-r*r)-t*t)/(2*aa*t);return[t?aa*(n(t)*Math.sqrt(e*e+1)-e):0,aa/2*Math.sin(2*Math.atan(r))]},(d3.geo.vanDerGrinten3=function(){return ia(Vn)}).raw=Vn,Wn.invert=function(t,a){if(!t||!a)return[t,a];a/=aa;var r=2*n(t)*t/aa,e=(r*r-1+4*a*a)/Math.abs(r),o=e*e,i=2*a,h=50;do{var u=i*i,M=(8*i-u*(u+2)-5)/(2*u*(i-1)),s=(3*i-u*i-10)/(2*u*i),c=M*M,f=i*M,v=i+M,l=v*v,g=i+3*M,d=l*(u+c*o-1)+(1-u)*(u*(g*g+4*c)+c*(12*f+4*c)),p=-2*v*(4*f*c+(1-4*u+3*u*u)*(1+s)+c*(-6+14*u-o+(-8+8*u-2*o)*s)+f*(-8+12*u+(-10+10*u-o)*s)),b=Math.sqrt(d),q=e*(l+c-1)+2*b-r*(4*l+o),w=e*(2*M*s+2*v*(1+s))+p/b-8*v*(e*(-1+c+l)+2*b)*(1+s)/(o+4*l);i-=δ=q/w}while(δ>ta&&--h>0);return[n(t)*(Math.sqrt(e*e+4)+e)*aa/4,aa/2*i]},(d3.geo.vanDerGrinten4=function(){return ia(Wn)}).raw=Wn;var Ra=function(){var t=4*aa+3*Math.sqrt(3),n=2*Math.sqrt(2*aa*Math.sqrt(3)/t);return w(n*Math.sqrt(3)/aa,n,t/6)}();(d3.geo.wagner4=function(){return ia(Ra)}).raw=Ra,Xn.invert=function(t,n){return[t/Math.sqrt(1-3*n*n/(aa*aa)),n]},(d3.geo.wagner6=function(){return ia(Xn)}).raw=Xn,Yn.invert=function(t,n){var r=t/2.66723,e=n/1.24104,o=Math.sqrt(r*r+e*e),i=2*a(o/2);return[3*Math.atan2(t*Math.tan(i),2.66723*o),o&&a(n*Math.sin(i)/(1.24104*.90631*o))]},(d3.geo.wagner7=function(){return ia(Yn)}).raw=Yn,Zn.invert=function(t,n){var r=-.5*(t*t+n*n),e=Math.sqrt(-r*(2+r)),o=n*r+t*e,i=t*r-n*e,h=Math.sqrt(i*i+o*o);return[Math.atan2(e*o,h*(1+r)),h?-a(e*i/h):0]},(d3.geo.wiechel=function(){return ia(Zn)}).raw=Zn,$n.invert=function(t,n){var a=t,e=n,o=25;do{var i,h=Math.cos(e),u=Math.sin(e),M=Math.sin(2*e),s=u*u,c=h*h,f=Math.sin(a),v=Math.cos(a/2),l=Math.sin(a/2),g=l*l,d=1-c*v*v,p=d?r(h*v)*Math.sqrt(i=1/d):i=0,b=.5*(2*p*h*l+2*a/aa)-t,q=.5*(p*u+e)-n,w=.5*i*(c*g+p*h*v*s)+1/aa,m=i*(f*M/4-p*u*l),S=.125*i*(M*l-p*u*c*f),T=.5*i*(s*v+p*g*h)+.5,A=m*S-T*w,Q=(q*m-b*T)/A,R=(b*S-q*w)/A;a-=Q,e-=R}while((Math.abs(Q)>ta||Math.abs(R)>ta)&&--o>0);return[a,e]},(d3.geo.winkel3=function(){return ia($n)}).raw=$n}();
d3 = function() {
var d3 = {
version: "3.1.8"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_document = document, d3_window = window;
try {
d3_document.createElement("div").style.setProperty("opacity", 0, "");
} catch (error) {
var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
d3_style_prototype.setProperty = function(name, value, priority) {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
d3.ascending = function(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
};
d3.descending = function(a, b) {
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
};
d3.min = function(array, f) {
var i = -1, n = array.length, a, b;
if (arguments.length === 1) {
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
while (++i < n) if ((b = array[i]) != null && a > b) a = b;
} else {
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
}
return a;
};
d3.max = function(array, f) {
var i = -1, n = array.length, a, b;
if (arguments.length === 1) {
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
} else {
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
}
return a;
};
d3.extent = function(array, f) {
var i = -1, n = array.length, a, b, c;
if (arguments.length === 1) {
while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
while (++i < n) if ((b = array[i]) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
} else {
while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
}
return [ a, c ];
};
d3.sum = function(array, f) {
var s = 0, n = array.length, a, i = -1;
if (arguments.length === 1) {
while (++i < n) if (!isNaN(a = +array[i])) s += a;
} else {
while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a;
}
return s;
};
function d3_number(x) {
return x != null && !isNaN(x);
}
d3.mean = function(array, f) {
var n = array.length, a, m = 0, i = -1, j = 0;
if (arguments.length === 1) {
while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
} else {
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
}
return j ? m : undefined;
};
d3.quantile = function(values, p) {
var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
return e ? v + e * (values[h] - v) : v;
};
d3.median = function(array, f) {
if (arguments.length > 1) array = array.map(f);
array = array.filter(d3_number);
return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined;
};
d3.bisector = function(f) {
return {
left: function(a, x, lo, hi) {
if (arguments.length < 3) lo = 0;
if (arguments.length < 4) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid;
}
return lo;
},
right: function(a, x, lo, hi) {
if (arguments.length < 3) lo = 0;
if (arguments.length < 4) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1;
}
return lo;
}
};
};
var d3_bisector = d3.bisector(function(d) {
return d;
});
d3.bisectLeft = d3_bisector.left;
d3.bisect = d3.bisectRight = d3_bisector.right;
d3.shuffle = function(array) {
var m = array.length, t, i;
while (m) {
i = Math.random() * m-- | 0;
t = array[m], array[m] = array[i], array[i] = t;
}
return array;
};
d3.permute = function(array, indexes) {
var permutes = [], i = -1, n = indexes.length;
while (++i < n) permutes[i] = array[indexes[i]];
return permutes;
};
d3.zip = function() {
if (!(n = arguments.length)) return [];
for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) {
zip[j] = arguments[j][i];
}
}
return zips;
};
function d3_zipLength(d) {
return d.length;
}
d3.transpose = function(matrix) {
return d3.zip.apply(d3, matrix);
};
d3.keys = function(map) {
var keys = [];
for (var key in map) keys.push(key);
return keys;
};
d3.values = function(map) {
var values = [];
for (var key in map) values.push(map[key]);
return values;
};
d3.entries = function(map) {
var entries = [];
for (var key in map) entries.push({
key: key,
value: map[key]
});
return entries;
};
d3.merge = function(arrays) {
return Array.prototype.concat.apply([], arrays);
};
d3.range = function(start, stop, step) {
if (arguments.length < 3) {
step = 1;
if (arguments.length < 2) {
stop = start;
start = 0;
}
}
if ((stop - start) / step === Infinity) throw new Error("infinite range");
var range = [], k = d3_range_integerScale(Math.abs(step)), i = -1, j;
start *= k, stop *= k, step *= k;
if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);
return range;
};
function d3_range_integerScale(x) {
var k = 1;
while (x * k % 1) k *= 10;
return k;
}
function d3_class(ctor, properties) {
try {
for (var key in properties) {
Object.defineProperty(ctor.prototype, key, {
value: properties[key],
enumerable: false
});
}
} catch (e) {
ctor.prototype = properties;
}
}
d3.map = function(object) {
var map = new d3_Map();
for (var key in object) map.set(key, object[key]);
return map;
};
function d3_Map() {}
d3_class(d3_Map, {
has: function(key) {
return d3_map_prefix + key in this;
},
get: function(key) {
return this[d3_map_prefix + key];
},
set: function(key, value) {
return this[d3_map_prefix + key] = value;
},
remove: function(key) {
key = d3_map_prefix + key;
return key in this && delete this[key];
},
keys: function() {
var keys = [];
this.forEach(function(key) {
keys.push(key);
});
return keys;
},
values: function() {
var values = [];
this.forEach(function(key, value) {
values.push(value);
});
return values;
},
entries: function() {
var entries = [];
this.forEach(function(key, value) {
entries.push({
key: key,
value: value
});
});
return entries;
},
forEach: function(f) {
for (var key in this) {
if (key.charCodeAt(0) === d3_map_prefixCode) {
f.call(this, key.substring(1), this[key]);
}
}
}
});
var d3_map_prefix = "\0", d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
d3.nest = function() {
var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
function map(mapType, array, depth) {
if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;
while (++i < n) {
if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
values.push(object);
} else {
valuesByKey.set(keyValue, [ object ]);
}
}
if (mapType) {
object = mapType();
setter = function(keyValue, values) {
object.set(keyValue, map(mapType, values, depth));
};
} else {
object = {};
setter = function(keyValue, values) {
object[keyValue] = map(mapType, values, depth);
};
}
valuesByKey.forEach(setter);
return object;
}
function entries(map, depth) {
if (depth >= keys.length) return map;
var array = [], sortKey = sortKeys[depth++];
map.forEach(function(key, keyMap) {
array.push({
key: key,
values: entries(keyMap, depth)
});
});
return sortKey ? array.sort(function(a, b) {
return sortKey(a.key, b.key);
}) : array;
}
nest.map = function(array, mapType) {
return map(mapType, array, 0);
};
nest.entries = function(array) {
return entries(map(d3.map, array, 0), 0);
};
nest.key = function(d) {
keys.push(d);
return nest;
};
nest.sortKeys = function(order) {
sortKeys[keys.length - 1] = order;
return nest;
};
nest.sortValues = function(order) {
sortValues = order;
return nest;
};
nest.rollup = function(f) {
rollup = f;
return nest;
};
return nest;
};
d3.set = function(array) {
var set = new d3_Set();
if (array) for (var i = 0; i < array.length; i++) set.add(array[i]);
return set;
};
function d3_Set() {}
d3_class(d3_Set, {
has: function(value) {
return d3_map_prefix + value in this;
},
add: function(value) {
this[d3_map_prefix + value] = true;
return value;
},
remove: function(value) {
value = d3_map_prefix + value;
return value in this && delete this[value];
},
values: function() {
var values = [];
this.forEach(function(value) {
values.push(value);
});
return values;
},
forEach: function(f) {
for (var value in this) {
if (value.charCodeAt(0) === d3_map_prefixCode) {
f.call(this, value.substring(1));
}
}
}
});
d3.behavior = {};
d3.rebind = function(target, source) {
var i = 1, n = arguments.length, method;
while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
return target;
};
function d3_rebind(target, source, method) {
return function() {
var value = method.apply(source, arguments);
return value === source ? target : value;
};
}
d3.dispatch = function() {
var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
return dispatch;
};
function d3_dispatch() {}
d3_dispatch.prototype.on = function(type, listener) {
var i = type.indexOf("."), name = "";
if (i >= 0) {
name = type.substring(i + 1);
type = type.substring(0, i);
}
if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
if (arguments.length === 2) {
if (listener == null) for (type in this) {
if (this.hasOwnProperty(type)) this[type].on(name, null);
}
return this;
}
};
function d3_dispatch_event(dispatch) {
var listeners = [], listenerByName = new d3_Map();
function event() {
var z = listeners, i = -1, n = z.length, l;
while (++i < n) if (l = z[i].on) l.apply(this, arguments);
return dispatch;
}
event.on = function(name, listener) {
var l = listenerByName.get(name), i;
if (arguments.length < 2) return l && l.on;
if (l) {
l.on = null;
listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
listenerByName.remove(name);
}
if (listener) listeners.push(listenerByName.set(name, {
on: listener
}));
return dispatch;
};
return event;
}
d3.event = null;
function d3_eventCancel() {
d3.event.stopPropagation();
d3.event.preventDefault();
}
function d3_eventSource() {
var e = d3.event, s;
while (s = e.sourceEvent) e = s;
return e;
}
function d3_eventSuppress(target, type) {
function off() {
target.on(type, null);
}
target.on(type, function() {
d3_eventCancel();
off();
}, true);
setTimeout(off, 0);
}
function d3_eventDispatch(target) {
var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
dispatch.of = function(thiz, argumentz) {
return function(e1) {
try {
var e0 = e1.sourceEvent = d3.event;
e1.target = target;
d3.event = e1;
dispatch[e1.type].apply(thiz, argumentz);
} finally {
d3.event = e0;
}
};
};
return dispatch;
}
d3.mouse = function(container) {
return d3_mousePoint(container, d3_eventSource());
};
var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
function d3_mousePoint(container, e) {
var svg = container.ownerSVGElement || container;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
svg = d3.select(d3_document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
var ctm = svg[0][0].getScreenCTM();
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
if (d3_mouse_bug44083) {
point.x = e.pageX;
point.y = e.pageY;
} else {
point.x = e.clientX;
point.y = e.clientY;
}
point = point.matrixTransform(container.getScreenCTM().inverse());
return [ point.x, point.y ];
}
var rect = container.getBoundingClientRect();
return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
}
var d3_array = d3_arraySlice;
function d3_arrayCopy(pseudoarray) {
var i = -1, n = pseudoarray.length, array = [];
while (++i < n) array.push(pseudoarray[i]);
return array;
}
function d3_arraySlice(pseudoarray) {
return Array.prototype.slice.call(pseudoarray);
}
try {
d3_array(d3_document.documentElement.childNodes)[0].nodeType;
} catch (e) {
d3_array = d3_arrayCopy;
}
var d3_arraySubclass = [].__proto__ ? function(array, prototype) {
array.__proto__ = prototype;
} : function(array, prototype) {
for (var property in prototype) array[property] = prototype[property];
};
d3.touches = function(container, touches) {
if (arguments.length < 2) touches = d3_eventSource().touches;
return touches ? d3_array(touches).map(function(touch) {
var point = d3_mousePoint(container, touch);
point.identifier = touch.identifier;
return point;
}) : [];
};
d3.behavior.drag = function() {
var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null;
function drag() {
this.on("mousedown.drag", mousedown).on("touchstart.drag", mousedown);
}
function mousedown() {
var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null, offset, origin_ = point(), moved = 0;
var w = d3.select(d3_window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
if (origin) {
offset = origin.apply(target, arguments);
offset = [ offset.x - origin_[0], offset.y - origin_[1] ];
} else {
offset = [ 0, 0 ];
}
if (touchId == null) d3_eventCancel();
event_({
type: "dragstart"
});
function point() {
var p = target.parentNode;
return touchId != null ? d3.touches(p).filter(function(p) {
return p.identifier === touchId;
})[0] : d3.mouse(p);
}
function dragmove() {
if (!target.parentNode) return dragend();
var p = point(), dx = p[0] - origin_[0], dy = p[1] - origin_[1];
moved |= dx | dy;
origin_ = p;
d3_eventCancel();
event_({
type: "drag",
x: p[0] + offset[0],
y: p[1] + offset[1],
dx: dx,
dy: dy
});
}
function dragend() {
event_({
type: "dragend"
});
if (moved) {
d3_eventCancel();
if (d3.event.target === eventTarget) d3_eventSuppress(w, "click");
}
w.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null);
}
}
drag.origin = function(x) {
if (!arguments.length) return origin;
origin = x;
return drag;
};
return d3.rebind(drag, event, "on");
};
function d3_selection(groups) {
d3_arraySubclass(groups, d3_selectionPrototype);
return groups;
}
var d3_select = function(s, n) {
return n.querySelector(s);
}, d3_selectAll = function(s, n) {
return n.querySelectorAll(s);
}, d3_selectRoot = d3_document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
return d3_selectMatcher.call(n, s);
};
if (typeof Sizzle === "function") {
d3_select = function(s, n) {
return Sizzle(s, n)[0] || null;
};
d3_selectAll = function(s, n) {
return Sizzle.uniqueSort(Sizzle(s, n));
};
d3_selectMatches = Sizzle.matchesSelector;
}
d3.selection = function() {
return d3_selectionRoot;
};
var d3_selectionPrototype = d3.selection.prototype = [];
d3_selectionPrototype.select = function(selector) {
var subgroups = [], subgroup, subnode, group, node;
if (typeof selector !== "function") selector = d3_selection_selector(selector);
for (var j = -1, m = this.length; ++j < m; ) {
subgroups.push(subgroup = []);
subgroup.parentNode = (group = this[j]).parentNode;
for (var i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) {
subgroup.push(subnode = selector.call(node, node.__data__, i));
if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
} else {
subgroup.push(null);
}
}
}
return d3_selection(subgroups);
};
function d3_selection_selector(selector) {
return function() {
return d3_select(selector, this);
};
}
d3_selectionPrototype.selectAll = function(selector) {
var subgroups = [], subgroup, node;
if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
for (var j = -1, m = this.length; ++j < m; ) {
for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) {
subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
subgroup.parentNode = node;
}
}
}
return d3_selection(subgroups);
};
function d3_selection_selectorAll(selector) {
return function() {
return d3_selectAll(selector, this);
};
}
var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
d3.ns = {
prefix: d3_nsPrefix,
qualify: function(name) {
var i = name.indexOf(":"), prefix = name;
if (i >= 0) {
prefix = name.substring(0, i);
name = name.substring(i + 1);
}
return d3_nsPrefix.hasOwnProperty(prefix) ? {
space: d3_nsPrefix[prefix],
local: name
} : name;
}
};
d3_selectionPrototype.attr = function(name, value) {
if (arguments.length < 2) {
if (typeof name === "string") {
var node = this.node();
name = d3.ns.qualify(name);
return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);
}
for (value in name) this.each(d3_selection_attr(value, name[value]));
return this;
}
return this.each(d3_selection_attr(name, value));
};
function d3_selection_attr(name, value) {
name = d3.ns.qualify(name);
function attrNull() {
this.removeAttribute(name);
}
function attrNullNS() {
this.removeAttributeNS(name.space, name.local);
}
function attrConstant() {
this.setAttribute(name, value);
}
function attrConstantNS() {
this.setAttributeNS(name.space, name.local, value);
}
function attrFunction() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
}
function attrFunctionNS() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
}
return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
}
function d3_collapse(s) {
return s.trim().replace(/\s+/g, " ");
}
d3.requote = function(s) {
return s.replace(d3_requote_re, "\\$&");
};
var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
d3_selectionPrototype.classed = function(name, value) {
if (arguments.length < 2) {
if (typeof name === "string") {
var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1;
if (value = node.classList) {
while (++i < n) if (!value.contains(name[i])) return false;
} else {
value = node.getAttribute("class");
while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;
}
return true;
}
for (value in name) this.each(d3_selection_classed(value, name[value]));
return this;
}
return this.each(d3_selection_classed(name, value));
};
function d3_selection_classedRe(name) {
return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
}
function d3_selection_classed(name, value) {
name = name.trim().split(/\s+/).map(d3_selection_classedName);
var n = name.length;
function classedConstant() {
var i = -1;
while (++i < n) name[i](this, value);
}
function classedFunction() {
var i = -1, x = value.apply(this, arguments);
while (++i < n) name[i](this, x);
}
return typeof value === "function" ? classedFunction : classedConstant;
}
function d3_selection_classedName(name) {
var re = d3_selection_classedRe(name);
return function(node, value) {
if (c = node.classList) return value ? c.add(name) : c.remove(name);
var c = node.getAttribute("class") || "";
if (value) {
re.lastIndex = 0;
if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name));
} else {
node.setAttribute("class", d3_collapse(c.replace(re, " ")));
}
};
}
d3_selectionPrototype.style = function(name, value, priority) {
var n = arguments.length;
if (n < 3) {
if (typeof name !== "string") {
if (n < 2) value = "";
for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
return this;
}
if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);
priority = "";
}
return this.each(d3_selection_style(name, value, priority));
};
function d3_selection_style(name, value, priority) {
function styleNull() {
this.style.removeProperty(name);
}
function styleConstant() {
this.style.setProperty(name, value, priority);
}
function styleFunction() {
var x = value.apply(this, arguments);
if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
}
return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
}
d3_selectionPrototype.property = function(name, value) {
if (arguments.length < 2) {
if (typeof name === "string") return this.node()[name];
for (value in name) this.each(d3_selection_property(value, name[value]));
return this;
}
return this.each(d3_selection_property(name, value));
};
function d3_selection_property(name, value) {
function propertyNull() {
delete this[name];
}
function propertyConstant() {
this[name] = value;
}
function propertyFunction() {
var x = value.apply(this, arguments);
if (x == null) delete this[name]; else this[name] = x;
}
return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
}
d3_selectionPrototype.text = function(value) {
return arguments.length ? this.each(typeof value === "function" ? function() {
var v = value.apply(this, arguments);
this.textContent = v == null ? "" : v;
} : value == null ? function() {
this.textContent = "";
} : function() {
this.textContent = value;
}) : this.node().textContent;
};
d3_selectionPrototype.html = function(value) {
return arguments.length ? this.each(typeof value === "function" ? function() {
var v = value.apply(this, arguments);
this.innerHTML = v == null ? "" : v;
} : value == null ? function() {
this.innerHTML = "";
} : function() {
this.innerHTML = value;
}) : this.node().innerHTML;
};
d3_selectionPrototype.append = function(name) {
name = d3.ns.qualify(name);
function append() {
return this.appendChild(d3_document.createElementNS(this.namespaceURI, name));
}
function appendNS() {
return this.appendChild(d3_document.createElementNS(name.space, name.local));
}
return this.select(name.local ? appendNS : append);
};
d3_selectionPrototype.insert = function(name, before) {
name = d3.ns.qualify(name);
if (typeof before !== "function") before = d3_selection_selector(before);
function insert(d, i) {
return this.insertBefore(d3_document.createElementNS(this.namespaceURI, name), before.call(this, d, i));
}
function insertNS(d, i) {
return this.insertBefore(d3_document.createElementNS(name.space, name.local), before.call(this, d, i));
}
return this.select(name.local ? insertNS : insert);
};
d3_selectionPrototype.remove = function() {
return this.each(function() {
var parent = this.parentNode;
if (parent) parent.removeChild(this);
});
};
d3_selectionPrototype.data = function(value, key) {
var i = -1, n = this.length, group, node;
if (!arguments.length) {
value = new Array(n = (group = this[0]).length);
while (++i < n) {
if (node = group[i]) {
value[i] = node.__data__;
}
}
return value;
}
function bind(group, groupData) {
var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;
if (key) {
var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue;
for (i = -1; ++i < n; ) {
keyValue = key.call(node = group[i], node.__data__, i);
if (nodeByKeyValue.has(keyValue)) {
exitNodes[i] = node;
} else {
nodeByKeyValue.set(keyValue, node);
}
keyValues.push(keyValue);
}
for (i = -1; ++i < m; ) {
keyValue = key.call(groupData, nodeData = groupData[i], i);
if (node = nodeByKeyValue.get(keyValue)) {
updateNodes[i] = node;
node.__data__ = nodeData;
} else if (!dataByKeyValue.has(keyValue)) {
enterNodes[i] = d3_selection_dataNode(nodeData);
}
dataByKeyValue.set(keyValue, nodeData);
nodeByKeyValue.remove(keyValue);
}
for (i = -1; ++i < n; ) {
if (nodeByKeyValue.has(keyValues[i])) {
exitNodes[i] = group[i];
}
}
} else {
for (i = -1; ++i < n0; ) {
node = group[i];
nodeData = groupData[i];
if (node) {
node.__data__ = nodeData;
updateNodes[i] = node;
} else {
enterNodes[i] = d3_selection_dataNode(nodeData);
}
}
for (;i < m; ++i) {
enterNodes[i] = d3_selection_dataNode(groupData[i]);
}
for (;i < n; ++i) {
exitNodes[i] = group[i];
}
}
enterNodes.update = updateNodes;
enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
enter.push(enterNodes);
update.push(updateNodes);
exit.push(exitNodes);
}
var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
if (typeof value === "function") {
while (++i < n) {
bind(group = this[i], value.call(group, group.parentNode.__data__, i));
}
} else {
while (++i < n) {
bind(group = this[i], value);
}
}
update.enter = function() {
return enter;
};
update.exit = function() {
return exit;
};
return update;
};
function d3_selection_dataNode(data) {
return {
__data__: data
};
}
d3_selectionPrototype.datum = function(value) {
return arguments.length ? this.property("__data__", value) : this.property("__data__");
};
d3_selectionPrototype.filter = function(filter) {
var subgroups = [], subgroup, group, node;
if (typeof filter !== "function") filter = d3_selection_filter(filter);
for (var j = 0, m = this.length; j < m; j++) {
subgroups.push(subgroup = []);
subgroup.parentNode = (group = this[j]).parentNode;
for (var i = 0, n = group.length; i < n; i++) {
if ((node = group[i]) && filter.call(node, node.__data__, i)) {
subgroup.push(node);
}
}
}
return d3_selection(subgroups);
};
function d3_selection_filter(selector) {
return function() {
return d3_selectMatches(this, selector);
};
}
d3_selectionPrototype.order = function() {
for (var j = -1, m = this.length; ++j < m; ) {
for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
if (node = group[i]) {
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
return this;
};
d3_selectionPrototype.sort = function(comparator) {
comparator = d3_selection_sortComparator.apply(this, arguments);
for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);
return this.order();
};
function d3_selection_sortComparator(comparator) {
if (!arguments.length) comparator = d3.ascending;
return function(a, b) {
return !a - !b || comparator(a.__data__, b.__data__);
};
}
function d3_noop() {}
d3_selectionPrototype.on = function(type, listener, capture) {
var n = arguments.length;
if (n < 3) {
if (typeof type !== "string") {
if (n < 2) listener = false;
for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));
return this;
}
if (n < 2) return (n = this.node()["__on" + type]) && n._;
capture = false;
}
return this.each(d3_selection_on(type, listener, capture));
};
function d3_selection_on(type, listener, capture) {
var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener;
if (i > 0) type = type.substring(0, i);
var filter = d3_selection_onFilters.get(type);
if (filter) type = filter, wrap = d3_selection_onFilter;
function onRemove() {
var l = this[name];
if (l) {
this.removeEventListener(type, l, l.$);
delete this[name];
}
}
function onAdd() {
var l = wrap(listener, d3_array(arguments));
onRemove.call(this);
this.addEventListener(type, this[name] = l, l.$ = capture);
l._ = listener;
}
function removeAll() {
var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match;
for (var name in this) {
if (match = name.match(re)) {
var l = this[name];
this.removeEventListener(match[1], l, l.$);
delete this[name];
}
}
}
return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;
}
var d3_selection_onFilters = d3.map({
mouseenter: "mouseover",
mouseleave: "mouseout"
});
d3_selection_onFilters.forEach(function(k) {
if ("on" + k in d3_document) d3_selection_onFilters.remove(k);
});
function d3_selection_onListener(listener, argumentz) {
return function(e) {
var o = d3.event;
d3.event = e;
argumentz[0] = this.__data__;
try {
listener.apply(this, argumentz);
} finally {
d3.event = o;
}
};
}
function d3_selection_onFilter(listener, argumentz) {
var l = d3_selection_onListener(listener, argumentz);
return function(e) {
var target = this, related = e.relatedTarget;
if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {
l.call(target, e);
}
};
}
d3_selectionPrototype.each = function(callback) {
return d3_selection_each(this, function(node, i, j) {
callback.call(node, node.__data__, i, j);
});
};
function d3_selection_each(groups, callback) {
for (var j = 0, m = groups.length; j < m; j++) {
for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
if (node = group[i]) callback(node, i, j);
}
}
return groups;
}
d3_selectionPrototype.call = function(callback) {
var args = d3_array(arguments);
callback.apply(args[0] = this, args);
return this;
};
d3_selectionPrototype.empty = function() {
return !this.node();
};
d3_selectionPrototype.node = function() {
for (var j = 0, m = this.length; j < m; j++) {
for (var group = this[j], i = 0, n = group.length; i < n; i++) {
var node = group[i];
if (node) return node;
}
}
return null;
};
function d3_selection_enter(selection) {
d3_arraySubclass(selection, d3_selection_enterPrototype);
return selection;
}
var d3_selection_enterPrototype = [];
d3.selection.enter = d3_selection_enter;
d3.selection.enter.prototype = d3_selection_enterPrototype;
d3_selection_enterPrototype.append = d3_selectionPrototype.append;
d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
d3_selection_enterPrototype.node = d3_selectionPrototype.node;
d3_selection_enterPrototype.select = function(selector) {
var subgroups = [], subgroup, subnode, upgroup, group, node;
for (var j = -1, m = this.length; ++j < m; ) {
upgroup = (group = this[j]).update;
subgroups.push(subgroup = []);
subgroup.parentNode = group.parentNode;
for (var i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) {
subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i));
subnode.__data__ = node.__data__;
} else {
subgroup.push(null);
}
}
}
return d3_selection(subgroups);
};
d3_selectionPrototype.transition = function() {
var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = Object.create(d3_transitionInherit);
transition.time = Date.now();
for (var j = -1, m = this.length; ++j < m; ) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) d3_transitionNode(node, i, id, transition);
subgroup.push(node);
}
}
return d3_transition(subgroups, id);
};
d3.select = function(node) {
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
group.parentNode = d3_selectRoot;
return d3_selection([ group ]);
};
d3.selectAll = function(nodes) {
var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes);
group.parentNode = d3_selectRoot;
return d3_selection([ group ]);
};
var d3_selectionRoot = d3.select(d3_selectRoot);
d3.behavior.zoom = function() {
var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
function zoom() {
this.on("mousedown.zoom", mousedown).on("mousemove.zoom", mousemove).on(d3_behavior_zoomWheel + ".zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart);
}
zoom.translate = function(x) {
if (!arguments.length) return translate;
translate = x.map(Number);
rescale();
return zoom;
};
zoom.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
rescale();
return zoom;
};
zoom.scaleExtent = function(x) {
if (!arguments.length) return scaleExtent;
scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number);
return zoom;
};
zoom.x = function(z) {
if (!arguments.length) return x1;
x1 = z;
x0 = z.copy();
translate = [ 0, 0 ];
scale = 1;
return zoom;
};
zoom.y = function(z) {
if (!arguments.length) return y1;
y1 = z;
y0 = z.copy();
translate = [ 0, 0 ];
scale = 1;
return zoom;
};
function location(p) {
return [ (p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale ];
}
function point(l) {
return [ l[0] * scale + translate[0], l[1] * scale + translate[1] ];
}
function scaleTo(s) {
scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
}
function translateTo(p, l) {
l = point(l);
translate[0] += p[0] - l[0];
translate[1] += p[1] - l[1];
}
function rescale() {
if (x1) x1.domain(x0.range().map(function(x) {
return (x - translate[0]) / scale;
}).map(x0.invert));
if (y1) y1.domain(y0.range().map(function(y) {
return (y - translate[1]) / scale;
}).map(y0.invert));
}
function dispatch(event) {
rescale();
d3.event.preventDefault();
event({
type: "zoom",
scale: scale,
translate: translate
});
}
function mousedown() {
var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
d3_window.focus();
d3_eventCancel();
function mousemove() {
moved = 1;
translateTo(d3.mouse(target), l);
dispatch(event_);
}
function mouseup() {
if (moved) d3_eventCancel();
w.on("mousemove.zoom", null).on("mouseup.zoom", null);
if (moved && d3.event.target === eventTarget) d3_eventSuppress(w, "click.zoom");
}
}
function mousewheel() {
if (!translate0) translate0 = location(d3.mouse(this));
scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale);
translateTo(d3.mouse(this), translate0);
dispatch(event.of(this, arguments));
}
function mousemove() {
translate0 = null;
}
function dblclick() {
var p = d3.mouse(this), l = location(p), k = Math.log(scale) / Math.LN2;
scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1));
translateTo(p, l);
dispatch(event.of(this, arguments));
}
function touchstart() {
var touches = d3.touches(this), now = Date.now();
scale0 = scale;
translate0 = {};
touches.forEach(function(t) {
translate0[t.identifier] = location(t);
});
d3_eventCancel();
if (touches.length === 1) {
if (now - touchtime < 500) {
var p = touches[0], l = location(touches[0]);
scaleTo(scale * 2);
translateTo(p, l);
dispatch(event.of(this, arguments));
}
touchtime = now;
}
}
function touchmove() {
var touches = d3.touches(this), p0 = touches[0], l0 = translate0[p0.identifier];
if (p1 = touches[1]) {
var p1, l1 = translate0[p1.identifier];
p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
scaleTo(d3.event.scale * scale0);
}
translateTo(p0, l0);
touchtime = null;
dispatch(event.of(this, arguments));
}
return d3.rebind(zoom, event, "on");
};
var d3_behavior_zoomInfinity = [ 0, Infinity ];
var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() {
return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);
}, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() {
return d3.event.wheelDelta;
}, "mousewheel") : (d3_behavior_zoomDelta = function() {
return -d3.event.detail;
}, "MozMousePixelScroll");
function d3_Color() {}
d3_Color.prototype.toString = function() {
return this.rgb() + "";
};
d3.hsl = function(h, s, l) {
return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l);
};
function d3_hsl(h, s, l) {
return new d3_Hsl(h, s, l);
}
function d3_Hsl(h, s, l) {
this.h = h;
this.s = s;
this.l = l;
}
var d3_hslPrototype = d3_Hsl.prototype = new d3_Color();
d3_hslPrototype.brighter = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, this.l / k);
};
d3_hslPrototype.darker = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, k * this.l);
};
d3_hslPrototype.rgb = function() {
return d3_hsl_rgb(this.h, this.s, this.l);
};
function d3_hsl_rgb(h, s, l) {
var m1, m2;
h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
l = l < 0 ? 0 : l > 1 ? 1 : l;
m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
m1 = 2 * l - m2;
function v(h) {
if (h > 360) h -= 360; else if (h < 0) h += 360;
if (h < 60) return m1 + (m2 - m1) * h / 60;
if (h < 180) return m2;
if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
return m1;
}
function vv(h) {
return Math.round(v(h) * 255);
}
return d3_rgb(vv(h + 120), vv(h