Skip to content

Instantly share code, notes, and snippets.

@rveciana
Last active September 23, 2016 22:02
Show Gist options
  • Save rveciana/ee2119324e835e1bad42d0e4c1b9ab0d to your computer and use it in GitHub Desktop.
Save rveciana/ee2119324e835e1bad42d0e4c1b9ab0d to your computer and use it in GitHub Desktop.
geoAlbersUsa

This file shows how to use the geoAlbers projection from d3-composite-projections.

To change the file, edit draw.js and run

browserify draw.js > bundle.js

The dependencies are installed with:

npm install d3-composite-projections d3-geo d3-request d3-selection d3-transition topojson

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var d3_composite = require("d3-composite-projections");
var d3_geo = require("d3-geo");
var d3_request = require("d3-request");
var d3_selection = require("d3-selection");
var d3_transition = require("d3-transition");
var topojson = require("topojson");
var width = 960;
var height = 500;
var projection = d3_composite.geoAlbersUsa();
var path = d3_geo.geoPath()
.projection(projection);
var svg = d3_selection.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var t = d3_transition.transition()
.on("interrupt", function(d,i){
console.info(i);
});
d3_request.json("us.json", function(error, topojsonData) {
var us = topojson.feature(topojsonData, topojsonData.objects.states);
svg.selectAll(".region")
.data(us.features)
.enter()
.append("path")
.attr("d", path)
.attr("class","region")
.style("fill", "#aca")
.style("stroke", "#000")
.style("stroke-width", "0.5px")
.on("mouseover", function(d,i) {
d3_selection.select(this)
.transition(t)
.style("fill", "red");
})
.on("mouseout", function(d,i) {
d3_selection.select(this).interrupt();
d3_selection.select(this)
.transition(t)
.style("fill", "#aca");
});
svg
.append("path")
.style("fill","none")
.style("stroke","#f00")
.attr("d", projection.getCompositionBorders());
});
},{"d3-composite-projections":5,"d3-geo":10,"d3-request":13,"d3-selection":14,"d3-transition":16,"topojson":17}],2:[function(require,module,exports){
// https://d3js.org/d3-array/ Version 1.0.1. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3 = global.d3 || {})));
}(this, function (exports) { 'use strict';
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
function bisector(compare) {
if (compare.length === 1) compare = ascendingComparator(compare);
return {
left: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) < 0) lo = mid + 1;
else hi = mid;
}
return lo;
},
right: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) > 0) hi = mid;
else lo = mid + 1;
}
return lo;
}
};
}
function ascendingComparator(f) {
return function(d, x) {
return ascending(f(d), x);
};
}
var ascendingBisect = bisector(ascending);
var bisectRight = ascendingBisect.right;
var bisectLeft = ascendingBisect.left;
function descending(a, b) {
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
}
function number(x) {
return x === null ? NaN : +x;
}
function variance(array, f) {
var n = array.length,
m = 0,
a,
d,
s = 0,
i = -1,
j = 0;
if (f == null) {
while (++i < n) {
if (!isNaN(a = number(array[i]))) {
d = a - m;
m += d / ++j;
s += d * (a - m);
}
}
}
else {
while (++i < n) {
if (!isNaN(a = number(f(array[i], i, array)))) {
d = a - m;
m += d / ++j;
s += d * (a - m);
}
}
}
if (j > 1) return s / (j - 1);
}
function deviation(array, f) {
var v = variance(array, f);
return v ? Math.sqrt(v) : v;
}
function extent(array, f) {
var i = -1,
n = array.length,
a,
b,
c;
if (f == null) {
while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; }
while (++i < n) if ((b = array[i]) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
}
else {
while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = c = b; break; }
while (++i < n) if ((b = f(array[i], i, array)) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
}
return [a, c];
}
var array = Array.prototype;
var slice = array.slice;
var map = array.map;
function constant(x) {
return function() {
return x;
};
}
function identity(x) {
return x;
}
function range(start, stop, step) {
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
}
var e10 = Math.sqrt(50);
var e5 = Math.sqrt(10);
var e2 = Math.sqrt(2);
function ticks(start, stop, count) {
var step = tickStep(start, stop, count);
return range(
Math.ceil(start / step) * step,
Math.floor(stop / step) * step + step / 2, // inclusive
step
);
}
function tickStep(start, stop, count) {
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;
else if (error >= e5) step1 *= 5;
else if (error >= e2) step1 *= 2;
return stop < start ? -step1 : step1;
}
function sturges(values) {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
}
function histogram() {
var value = identity,
domain = extent,
threshold = sturges;
function histogram(data) {
var i,
n = data.length,
x,
values = new Array(n);
for (i = 0; i < n; ++i) {
values[i] = value(data[i], i, data);
}
var xz = domain(values),
x0 = xz[0],
x1 = xz[1],
tz = threshold(values, x0, x1);
// Convert number of thresholds into uniform thresholds.
if (!Array.isArray(tz)) tz = ticks(x0, x1, tz);
// Remove any thresholds outside the domain.
var m = tz.length;
while (tz[0] <= x0) tz.shift(), --m;
while (tz[m - 1] >= x1) tz.pop(), --m;
var bins = new Array(m + 1),
bin;
// Initialize bins.
for (i = 0; i <= m; ++i) {
bin = bins[i] = [];
bin.x0 = i > 0 ? tz[i - 1] : x0;
bin.x1 = i < m ? tz[i] : x1;
}
// Assign data to bins by value, ignoring any outside the domain.
for (i = 0; i < n; ++i) {
x = values[i];
if (x0 <= x && x <= x1) {
bins[bisectRight(tz, x, 0, m)].push(data[i]);
}
}
return bins;
}
histogram.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
};
histogram.domain = function(_) {
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
};
histogram.thresholds = function(_) {
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
};
return histogram;
}
function quantile(array, p, f) {
if (f == null) f = number;
if (!(n = array.length)) return;
if ((p = +p) <= 0 || n < 2) return +f(array[0], 0, array);
if (p >= 1) return +f(array[n - 1], n - 1, array);
var n,
h = (n - 1) * p,
i = Math.floor(h),
a = +f(array[i], i, array),
b = +f(array[i + 1], i + 1, array);
return a + (b - a) * (h - i);
}
function freedmanDiaconis(values, min, max) {
values = map.call(values, number).sort(ascending);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
}
function scott(values, min, max) {
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
}
function max(array, f) {
var i = -1,
n = array.length,
a,
b;
if (f == null) {
while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
}
else {
while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
while (++i < n) if ((b = f(array[i], i, array)) != null && b > a) a = b;
}
return a;
}
function mean(array, f) {
var s = 0,
n = array.length,
a,
i = -1,
j = n;
if (f == null) {
while (++i < n) if (!isNaN(a = number(array[i]))) s += a; else --j;
}
else {
while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) s += a; else --j;
}
if (j) return s / j;
}
function median(array, f) {
var numbers = [],
n = array.length,
a,
i = -1;
if (f == null) {
while (++i < n) if (!isNaN(a = number(array[i]))) numbers.push(a);
}
else {
while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) numbers.push(a);
}
return quantile(numbers.sort(ascending), 0.5);
}
function merge(arrays) {
var n = arrays.length,
m,
i = -1,
j = 0,
merged,
array;
while (++i < n) j += arrays[i].length;
merged = new Array(j);
while (--n >= 0) {
array = arrays[n];
m = array.length;
while (--m >= 0) {
merged[--j] = array[m];
}
}
return merged;
}
function min(array, f) {
var i = -1,
n = array.length,
a,
b;
if (f == null) {
while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
while (++i < n) if ((b = array[i]) != null && a > b) a = b;
}
else {
while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
while (++i < n) if ((b = f(array[i], i, array)) != null && a > b) a = b;
}
return a;
}
function pairs(array) {
var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
while (i < n) pairs[i] = [p, p = array[++i]];
return pairs;
}
function permute(array, indexes) {
var i = indexes.length, permutes = new Array(i);
while (i--) permutes[i] = array[indexes[i]];
return permutes;
}
function scan(array, compare) {
if (!(n = array.length)) return;
var i = 0,
n,
j = 0,
xi,
xj = array[j];
if (!compare) compare = ascending;
while (++i < n) if (compare(xi = array[i], xj) < 0 || compare(xj, xj) !== 0) xj = xi, j = i;
if (compare(xj, xj) === 0) return j;
}
function shuffle(array, i0, i1) {
var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),
t,
i;
while (m) {
i = Math.random() * m-- | 0;
t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
}
function sum(array, f) {
var s = 0,
n = array.length,
a,
i = -1;
if (f == null) {
while (++i < n) if (a = +array[i]) s += a; // Note: zero and null are equivalent.
}
else {
while (++i < n) if (a = +f(array[i], i, array)) s += a;
}
return s;
}
function transpose(matrix) {
if (!(n = matrix.length)) return [];
for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) {
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {
row[j] = matrix[j][i];
}
}
return transpose;
}
function length(d) {
return d.length;
}
function zip() {
return transpose(arguments);
}
exports.bisect = bisectRight;
exports.bisectRight = bisectRight;
exports.bisectLeft = bisectLeft;
exports.ascending = ascending;
exports.bisector = bisector;
exports.descending = descending;
exports.deviation = deviation;
exports.extent = extent;
exports.histogram = histogram;
exports.thresholdFreedmanDiaconis = freedmanDiaconis;
exports.thresholdScott = scott;
exports.thresholdSturges = sturges;
exports.max = max;
exports.mean = mean;
exports.median = median;
exports.merge = merge;
exports.min = min;
exports.pairs = pairs;
exports.permute = permute;
exports.quantile = quantile;
exports.range = range;
exports.scan = scan;
exports.shuffle = shuffle;
exports.sum = sum;
exports.ticks = ticks;
exports.tickStep = tickStep;
exports.transpose = transpose;
exports.variance = variance;
exports.zip = zip;
Object.defineProperty(exports, '__esModule', { value: true });
}));
},{}],3:[function(require,module,exports){
// https://d3js.org/d3-collection/ Version 1.0.1. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3 = global.d3 || {})));
}(this, function (exports) { 'use strict';
var prefix = "$";
function Map() {}
Map.prototype = map.prototype = {
constructor: Map,
has: function(key) {
return (prefix + key) in this;
},
get: function(key) {
return this[prefix + key];
},
set: function(key, value) {
this[prefix + key] = value;
return this;
},
remove: function(key) {
var property = prefix + key;
return property in this && delete this[property];
},
clear: function() {
for (var property in this) if (property[0] === prefix) delete this[property];
},
keys: function() {
var keys = [];
for (var property in this) if (property[0] === prefix) keys.push(property.slice(1));
return keys;
},
values: function() {
var values = [];
for (var property in this) if (property[0] === prefix) values.push(this[property]);
return values;
},
entries: function() {
var entries = [];
for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]});
return entries;
},
size: function() {
var size = 0;
for (var property in this) if (property[0] === prefix) ++size;
return size;
},
empty: function() {
for (var property in this) if (property[0] === prefix) return false;
return true;
},
each: function(f) {
for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
}
};
function map(object, f) {
var map = new Map;
// Copy constructor.
if (object instanceof Map) object.each(function(value, key) { map.set(key, value); });
// Index array by numeric index or specified key function.
else if (Array.isArray(object)) {
var i = -1,
n = object.length,
o;
if (f == null) while (++i < n) map.set(i, object[i]);
else while (++i < n) map.set(f(o = object[i], i, object), o);
}
// Convert object to map.
else if (object) for (var key in object) map.set(key, object[key]);
return map;
}
function nest() {
var keys = [],
sortKeys = [],
sortValues,
rollup,
nest;
function apply(array, depth, createResult, setResult) {
if (depth >= keys.length) return rollup != null
? rollup(array) : (sortValues != null
? array.sort(sortValues)
: array);
var i = -1,
n = array.length,
key = keys[depth++],
keyValue,
value,
valuesByKey = map(),
values,
result = createResult();
while (++i < n) {
if (values = valuesByKey.get(keyValue = key(value = array[i]) + "")) {
values.push(value);
} else {
valuesByKey.set(keyValue, [value]);
}
}
valuesByKey.each(function(values, key) {
setResult(result, key, apply(values, depth, createResult, setResult));
});
return result;
}
function entries(map, depth) {
if (++depth > keys.length) return map;
var array, sortKey = sortKeys[depth - 1];
if (rollup != null && depth >= keys.length) array = map.entries();
else array = [], map.each(function(v, k) { array.push({key: k, values: entries(v, depth)}); });
return sortKey != null ? array.sort(function(a, b) { return sortKey(a.key, b.key); }) : array;
}
return nest = {
object: function(array) { return apply(array, 0, createObject, setObject); },
map: function(array) { return apply(array, 0, createMap, setMap); },
entries: function(array) { return entries(apply(array, 0, createMap, setMap), 0); },
key: function(d) { keys.push(d); return nest; },
sortKeys: function(order) { sortKeys[keys.length - 1] = order; return nest; },
sortValues: function(order) { sortValues = order; return nest; },
rollup: function(f) { rollup = f; return nest; }
};
}
function createObject() {
return {};
}
function setObject(object, key, value) {
object[key] = value;
}
function createMap() {
return map();
}
function setMap(map, key, value) {
map.set(key, value);
}
function Set() {}
var proto = map.prototype;
Set.prototype = set.prototype = {
constructor: Set,
has: proto.has,
add: function(value) {
value += "";
this[prefix + value] = value;
return this;
},
remove: proto.remove,
clear: proto.clear,
values: proto.keys,
size: proto.size,
empty: proto.empty,
each: proto.each
};
function set(object, f) {
var set = new Set;
// Copy constructor.
if (object instanceof Set) object.each(function(value) { set.add(value); });
// Otherwise, assume it’s an array.
else if (object) {
var i = -1, n = object.length;
if (f == null) while (++i < n) set.add(object[i]);
else while (++i < n) set.add(f(object[i], i, object));
}
return set;
}
function keys(map) {
var keys = [];
for (var key in map) keys.push(key);
return keys;
}
function values(map) {
var values = [];
for (var key in map) values.push(map[key]);
return values;
}
function entries(map) {
var entries = [];
for (var key in map) entries.push({key: key, value: map[key]});
return entries;
}
exports.nest = nest;
exports.set = set;
exports.map = map;
exports.keys = keys;
exports.values = values;
exports.entries = entries;
Object.defineProperty(exports, '__esModule', { value: true });
}));
},{}],4:[function(require,module,exports){
// https://d3js.org/d3-color/ Version 1.0.1. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3 = global.d3 || {})));
}(this, function (exports) { 'use strict';
function define(constructor, factory, prototype) {
constructor.prototype = factory.prototype = prototype;
prototype.constructor = constructor;
}
function extend(parent, definition) {
var prototype = Object.create(parent.prototype);
for (var key in definition) prototype[key] = definition[key];
return prototype;
}
function Color() {}
var darker = 0.7;
var brighter = 1 / darker;
var reHex3 = /^#([0-9a-f]{3})$/;
var reHex6 = /^#([0-9a-f]{6})$/;
var reRgbInteger = /^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/;
var reRgbPercent = /^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;
var reRgbaInteger = /^rgba\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/;
var reRgbaPercent = /^rgba\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/;
var reHslPercent = /^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;
var reHslaPercent = /^hsla\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)\s*\)$/;
var named = {
aliceblue: 0xf0f8ff,
antiquewhite: 0xfaebd7,
aqua: 0x00ffff,
aquamarine: 0x7fffd4,
azure: 0xf0ffff,
beige: 0xf5f5dc,
bisque: 0xffe4c4,
black: 0x000000,
blanchedalmond: 0xffebcd,
blue: 0x0000ff,
blueviolet: 0x8a2be2,
brown: 0xa52a2a,
burlywood: 0xdeb887,
cadetblue: 0x5f9ea0,
chartreuse: 0x7fff00,
chocolate: 0xd2691e,
coral: 0xff7f50,
cornflowerblue: 0x6495ed,
cornsilk: 0xfff8dc,
crimson: 0xdc143c,
cyan: 0x00ffff,
darkblue: 0x00008b,
darkcyan: 0x008b8b,
darkgoldenrod: 0xb8860b,
darkgray: 0xa9a9a9,
darkgreen: 0x006400,
darkgrey: 0xa9a9a9,
darkkhaki: 0xbdb76b,
darkmagenta: 0x8b008b,
darkolivegreen: 0x556b2f,
darkorange: 0xff8c00,
darkorchid: 0x9932cc,
darkred: 0x8b0000,
darksalmon: 0xe9967a,
darkseagreen: 0x8fbc8f,
darkslateblue: 0x483d8b,
darkslategray: 0x2f4f4f,
darkslategrey: 0x2f4f4f,
darkturquoise: 0x00ced1,
darkviolet: 0x9400d3,
deeppink: 0xff1493,
deepskyblue: 0x00bfff,
dimgray: 0x696969,
dimgrey: 0x696969,
dodgerblue: 0x1e90ff,
firebrick: 0xb22222,
floralwhite: 0xfffaf0,
forestgreen: 0x228b22,
fuchsia: 0xff00ff,
gainsboro: 0xdcdcdc,
ghostwhite: 0xf8f8ff,
gold: 0xffd700,
goldenrod: 0xdaa520,
gray: 0x808080,
green: 0x008000,
greenyellow: 0xadff2f,
grey: 0x808080,
honeydew: 0xf0fff0,
hotpink: 0xff69b4,
indianred: 0xcd5c5c,
indigo: 0x4b0082,
ivory: 0xfffff0,
khaki: 0xf0e68c,
lavender: 0xe6e6fa,
lavenderblush: 0xfff0f5,
lawngreen: 0x7cfc00,
lemonchiffon: 0xfffacd,
lightblue: 0xadd8e6,
lightcoral: 0xf08080,
lightcyan: 0xe0ffff,
lightgoldenrodyellow: 0xfafad2,
lightgray: 0xd3d3d3,
lightgreen: 0x90ee90,
lightgrey: 0xd3d3d3,
lightpink: 0xffb6c1,
lightsalmon: 0xffa07a,
lightseagreen: 0x20b2aa,
lightskyblue: 0x87cefa,
lightslategray: 0x778899,
lightslategrey: 0x778899,
lightsteelblue: 0xb0c4de,
lightyellow: 0xffffe0,
lime: 0x00ff00,
limegreen: 0x32cd32,
linen: 0xfaf0e6,
magenta: 0xff00ff,
maroon: 0x800000,
mediumaquamarine: 0x66cdaa,
mediumblue: 0x0000cd,
mediumorchid: 0xba55d3,
mediumpurple: 0x9370db,
mediumseagreen: 0x3cb371,
mediumslateblue: 0x7b68ee,
mediumspringgreen: 0x00fa9a,
mediumturquoise: 0x48d1cc,
mediumvioletred: 0xc71585,
midnightblue: 0x191970,
mintcream: 0xf5fffa,
mistyrose: 0xffe4e1,
moccasin: 0xffe4b5,
navajowhite: 0xffdead,
navy: 0x000080,
oldlace: 0xfdf5e6,
olive: 0x808000,
olivedrab: 0x6b8e23,
orange: 0xffa500,
orangered: 0xff4500,
orchid: 0xda70d6,
palegoldenrod: 0xeee8aa,
palegreen: 0x98fb98,
paleturquoise: 0xafeeee,
palevioletred: 0xdb7093,
papayawhip: 0xffefd5,
peachpuff: 0xffdab9,
peru: 0xcd853f,
pink: 0xffc0cb,
plum: 0xdda0dd,
powderblue: 0xb0e0e6,
purple: 0x800080,
rebeccapurple: 0x663399,
red: 0xff0000,
rosybrown: 0xbc8f8f,
royalblue: 0x4169e1,
saddlebrown: 0x8b4513,
salmon: 0xfa8072,
sandybrown: 0xf4a460,
seagreen: 0x2e8b57,
seashell: 0xfff5ee,
sienna: 0xa0522d,
silver: 0xc0c0c0,
skyblue: 0x87ceeb,
slateblue: 0x6a5acd,
slategray: 0x708090,
slategrey: 0x708090,
snow: 0xfffafa,
springgreen: 0x00ff7f,
steelblue: 0x4682b4,
tan: 0xd2b48c,
teal: 0x008080,
thistle: 0xd8bfd8,
tomato: 0xff6347,
turquoise: 0x40e0d0,
violet: 0xee82ee,
wheat: 0xf5deb3,
white: 0xffffff,
whitesmoke: 0xf5f5f5,
yellow: 0xffff00,
yellowgreen: 0x9acd32
};
define(Color, color, {
displayable: function() {
return this.rgb().displayable();
},
toString: function() {
return this.rgb() + "";
}
});
function color(format) {
var m;
format = (format + "").trim().toLowerCase();
return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1)) // #f00
: (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
: (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
: named.hasOwnProperty(format) ? rgbn(named[format])
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
: null;
}
function rgbn(n) {
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
}
function rgba(r, g, b, a) {
if (a <= 0) r = g = b = NaN;
return new Rgb(r, g, b, a);
}
function rgbConvert(o) {
if (!(o instanceof Color)) o = color(o);
if (!o) return new Rgb;
o = o.rgb();
return new Rgb(o.r, o.g, o.b, o.opacity);
}
function rgb(r, g, b, opacity) {
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
}
function Rgb(r, g, b, opacity) {
this.r = +r;
this.g = +g;
this.b = +b;
this.opacity = +opacity;
}
define(Rgb, rgb, extend(Color, {
brighter: function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
darker: function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
},
rgb: function() {
return this;
},
displayable: function() {
return (0 <= this.r && this.r <= 255)
&& (0 <= this.g && this.g <= 255)
&& (0 <= this.b && this.b <= 255)
&& (0 <= this.opacity && this.opacity <= 1);
},
toString: function() {
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
return (a === 1 ? "rgb(" : "rgba(")
+ Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
+ Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
+ Math.max(0, Math.min(255, Math.round(this.b) || 0))
+ (a === 1 ? ")" : ", " + a + ")");
}
}));
function hsla(h, s, l, a) {
if (a <= 0) h = s = l = NaN;
else if (l <= 0 || l >= 1) h = s = NaN;
else if (s <= 0) h = NaN;
return new Hsl(h, s, l, a);
}
function hslConvert(o) {
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
if (!(o instanceof Color)) o = color(o);
if (!o) return new Hsl;
if (o instanceof Hsl) return o;
o = o.rgb();
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
min = Math.min(r, g, b),
max = Math.max(r, g, b),
h = NaN,
s = max - min,
l = (max + min) / 2;
if (s) {
if (r === max) h = (g - b) / s + (g < b) * 6;
else if (g === max) h = (b - r) / s + 2;
else h = (r - g) / s + 4;
s /= l < 0.5 ? max + min : 2 - max - min;
h *= 60;
} else {
s = l > 0 && l < 1 ? 0 : h;
}
return new Hsl(h, s, l, o.opacity);
}
function hsl(h, s, l, opacity) {
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
}
function Hsl(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
define(Hsl, hsl, extend(Color, {
brighter: function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
darker: function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Hsl(this.h, this.s, this.l * k, this.opacity);
},
rgb: function() {
var h = this.h % 360 + (this.h < 0) * 360,
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
l = this.l,
m2 = l + (l < 0.5 ? l : 1 - l) * s,
m1 = 2 * l - m2;
return new Rgb(
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
hsl2rgb(h, m1, m2),
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
this.opacity
);
},
displayable: function() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
&& (0 <= this.l && this.l <= 1)
&& (0 <= this.opacity && this.opacity <= 1);
}
}));
/* From FvD 13.37, CSS Color Module Level 3 */
function hsl2rgb(h, m1, m2) {
return (h < 60 ? m1 + (m2 - m1) * h / 60
: h < 180 ? m2
: h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
: m1) * 255;
}
var deg2rad = Math.PI / 180;
var rad2deg = 180 / Math.PI;
var Kn = 18;
var Xn = 0.950470;
var Yn = 1;
var Zn = 1.088830;
var t0 = 4 / 29;
var t1 = 6 / 29;
var t2 = 3 * t1 * t1;
var t3 = t1 * t1 * t1;
function labConvert(o) {
if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
if (o instanceof Hcl) {
var h = o.h * deg2rad;
return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
}
if (!(o instanceof Rgb)) o = rgbConvert(o);
var b = rgb2xyz(o.r),
a = rgb2xyz(o.g),
l = rgb2xyz(o.b),
x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn),
y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn),
z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn);
return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
}
function lab(l, a, b, opacity) {
return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
}
function Lab(l, a, b, opacity) {
this.l = +l;
this.a = +a;
this.b = +b;
this.opacity = +opacity;
}
define(Lab, lab, extend(Color, {
brighter: function(k) {
return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
darker: function(k) {
return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
},
rgb: function() {
var y = (this.l + 16) / 116,
x = isNaN(this.a) ? y : y + this.a / 500,
z = isNaN(this.b) ? y : y - this.b / 200;
y = Yn * lab2xyz(y);
x = Xn * lab2xyz(x);
z = Zn * lab2xyz(z);
return new Rgb(
xyz2rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z),
xyz2rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z),
this.opacity
);
}
}));
function xyz2lab(t) {
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
}
function lab2xyz(t) {
return t > t1 ? t * t * t : t2 * (t - t0);
}
function xyz2rgb(x) {
return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
}
function rgb2xyz(x) {
return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
}
function hclConvert(o) {
if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
if (!(o instanceof Lab)) o = labConvert(o);
var h = Math.atan2(o.b, o.a) * rad2deg;
return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
}
function hcl(h, c, l, opacity) {
return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
}
function Hcl(h, c, l, opacity) {
this.h = +h;
this.c = +c;
this.l = +l;
this.opacity = +opacity;
}
define(Hcl, hcl, extend(Color, {
brighter: function(k) {
return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity);
},
darker: function(k) {
return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity);
},
rgb: function() {
return labConvert(this).rgb();
}
}));
var A = -0.14861;
var B = +1.78277;
var C = -0.29227;
var D = -0.90649;
var E = +1.97294;
var ED = E * D;
var EB = E * B;
var BC_DA = B * C - D * A;
function cubehelixConvert(o) {
if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
if (!(o instanceof Rgb)) o = rgbConvert(o);
var r = o.r / 255,
g = o.g / 255,
b = o.b / 255,
l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
bl = b - l,
k = (E * (g - l) - C * bl) / D,
s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
}
function cubehelix(h, s, l, opacity) {
return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
}
function Cubehelix(h, s, l, opacity) {
this.h = +h;
this.s = +s;
this.l = +l;
this.opacity = +opacity;
}
define(Cubehelix, cubehelix, extend(Color, {
brighter: function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
darker: function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
},
rgb: function() {
var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
l = +this.l,
a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
cosh = Math.cos(h),
sinh = Math.sin(h);
return new Rgb(
255 * (l + a * (A * cosh + B * sinh)),
255 * (l + a * (C * cosh + D * sinh)),
255 * (l + a * (E * cosh)),
this.opacity
);
}
}));
exports.color = color;
exports.rgb = rgb;
exports.hsl = hsl;
exports.lab = lab;
exports.hcl = hcl;
exports.cubehelix = cubehelix;
Object.defineProperty(exports, '__esModule', { value: true });
}));
},{}],5:[function(require,module,exports){
// http://geoexamples.com/d3-composite-projections/ Version 1.0.0. Copyright 2016 Roger Veciana i Rovira.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-geo'), require('d3-path')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-geo', 'd3-path'], factory) :
(factory((global.d3 = global.d3 || {}),global.d3,global.d3));
}(this, function (exports,d3Geo,d3Path) { 'use strict';
var epsilon = 1e-6;
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); },
sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); },
lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); },
lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); },
polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); },
polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); }
};
}
// A composite projection for the United States, configured by default for
// 960×500. Also works quite well at 960×600 with scale 1285. The set of
// standard parallels for each region comes from USGS, which is published here:
// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
function albersUsa() {
var cache,
cacheStream,
lower48 = d3Geo.geoAlbers(), lower48Point,
alaska = d3Geo.geoConicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, // EPSG:3338
hawaii = d3Geo.geoConicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, // ESRI:102007
point, pointStream = {point: function(x, y) { point = [x, y]; }};
function albersUsa(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(lower48Point.point(x, y), point)
|| (alaskaPoint.point(x, y), point)
|| (hawaiiPoint.point(x, y), point);
}
albersUsa.invert = function(coordinates) {
var k = lower48.scale(),
t = lower48.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska
: y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii
: lower48).invert(coordinates);
};
albersUsa.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]);
};
albersUsa.precision = function(_) {
if (!arguments.length) return lower48.precision();
lower48.precision(_), alaska.precision(_), hawaii.precision(_);
return albersUsa;
};
albersUsa.scale = function(_) {
if (!arguments.length) return lower48.scale();
lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_);
return albersUsa.translate(lower48.translate());
};
albersUsa.translate = function(_) {
if (!arguments.length) return lower48.translate();
var k = lower48.scale(), x = +_[0], y = +_[1];
lower48Point = lower48
.translate(_)
.clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]])
.stream(pointStream);
alaskaPoint = alaska
.translate([x - 0.307 * k, y + 0.201 * k])
.clipExtent([[x - 0.425 * k + epsilon, y + 0.120 * k + epsilon], [x - 0.214 * k - epsilon, y + 0.234 * k - epsilon]])
.stream(pointStream);
hawaiiPoint = hawaii
.translate([x - 0.205 * k, y + 0.212 * k])
.clipExtent([[x - 0.214 * k + epsilon, y + 0.166 * k + epsilon], [x - 0.115 * k - epsilon, y + 0.234 * k - epsilon]])
.stream(pointStream);
return albersUsa;
};
albersUsa.drawCompositionBorders = function(context) {
var hawaii1 = lower48([-102.91, 26.3]);
var hawaii2 = lower48([-104.0, 27.5]);
var hawaii3 = lower48([-108.0, 29.1]);
var hawaii4 = lower48([-110.0, 29.1]);
var alaska1 = lower48([-110.0, 26.7]);
var alaska2 = lower48([-112.8, 27.6]);
var alaska3 = lower48([-114.3, 30.6]);
var alaska4 = lower48([-119.3, 30.1]);
context.moveTo(hawaii1[0], hawaii1[1]);
context.lineTo(hawaii2[0], hawaii2[1]);
context.lineTo(hawaii3[0], hawaii3[1]);
context.lineTo(hawaii4[0], hawaii4[1]);
context.moveTo(alaska1[0], alaska1[1]);
context.lineTo(alaska2[0], alaska2[1]);
context.lineTo(alaska3[0], alaska3[1]);
context.lineTo(alaska4[0], alaska4[1]);
};
albersUsa.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return albersUsa.scale(1070);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$1(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); },
sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); },
lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); },
lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); },
polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); },
polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); }
};
}
// A composite projection for the United States, configured by default for
// 960×500. Also works quite well at 960×600 with scale 1285. The set of
// standard parallels for each region comes from USGS, which is published here:
// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
function albersUsaTerritories() {
var cache,
cacheStream,
lower48 = d3Geo.geoAlbers(), lower48Point,
alaska = d3Geo.geoConicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, // EPSG:3338
hawaii = d3Geo.geoConicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, // ESRI:102007
puertoRico = d3Geo.geoConicEqualArea().rotate([66, 0]).center([0, 18]).parallels([8, 18]), puertoRicoPoint, //Taken from https://bl.ocks.org/mbostock/5629120
samoa = d3Geo.geoEquirectangular().rotate([173, 14]), samoaPoint, // EPSG:4169
guam = d3Geo.geoEquirectangular().rotate([-145, -16.8]), guamPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var puertoRicoBbox = [[-68.3, 19], [-63.9, 17]];
var samoaBbox = [[-171, -14], [-168, -14.8]];
var guamBbox = [[144, 20.8], [146.5, 12.7]];
*/
function albersUsa(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(lower48Point.point(x, y), point) ||
(alaskaPoint.point(x, y), point) ||
(hawaiiPoint.point(x, y), point) ||
(puertoRicoPoint.point(x, y), point) ||
(samoaPoint.point(x, y), point) ||
(guamPoint.point(x, y), point);
}
albersUsa.invert = function(coordinates) {
var k = lower48.scale(),
t = lower48.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
console.info("******");
var c0 = puertoRico(puertoRicoBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 puertoRico", x0 + ' - ' + y0);
var c1 = puertoRico(puertoRicoBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 puertoRico", x1 + ' - ' + y1);
c0 = samoa(samoaBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 samoa", x0 + ' - ' + y0);
c1 = samoa(samoaBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 samoa", x1 + ' - ' + y1);
c0 = guam(guamBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 guam", x0 + ' - ' + y0);
c1 = guam(guamBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 guam", x1 + ' - ' + y1);
*/
return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska
: y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii
: y >= 0.2064 && y < 0.2413 && x >= 0.312 && x < 0.385 ? puertoRico
: y >= 0.09 && y < 0.1197 && x >= -0.4243 && x < -0.3232 ? samoa
: y >= -0.0518 && y < 0.0895 && x >= -0.4243 && x < -0.3824 ? guam
: lower48).invert(coordinates);
};
albersUsa.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$1([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream), puertoRico.stream(stream), samoa.stream(stream), guam.stream(stream)]);
};
albersUsa.precision = function(_) {
if (!arguments.length) {return lower48.precision();}
lower48.precision(_);
alaska.precision(_);
hawaii.precision(_);
puertoRico.precision(_);
samoa.precision(_);
guam.precision(_);
return albersUsa;
};
albersUsa.scale = function(_) {
if (!arguments.length) {return lower48.scale();}
lower48.scale(_);
alaska.scale(_ * 0.35);
hawaii.scale(_);
puertoRico.scale(_);
samoa.scale(_* 2);
guam.scale(_);
return albersUsa.translate(lower48.translate());
};
albersUsa.translate = function(_) {
if (!arguments.length) {return lower48.translate();}
var k = lower48.scale(), x = +_[0], y = +_[1];
/*
var c0 = puertoRico.translate([x + 0.350 * k, y + 0.224 * k])(puertoRicoBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = puertoRico.translate([x + 0.350 * k, y + 0.224 * k])(puertoRicoBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('puertoRico: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = samoa.translate([x - 0.492 * k, y + 0.09 * k])(samoaBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = samoa.translate([x - 0.492 * k, y + 0.09 * k])(samoaBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('samoa: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = guam.translate([x - 0.408 * k, y + 0.018 * k])(guamBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = guam.translate([x - 0.408 * k, y + 0.018 * k])(guamBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('guam: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
*/
lower48Point = lower48
.translate(_)
.clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]])
.stream(pointStream);
alaskaPoint = alaska
.translate([x - 0.307 * k, y + 0.201 * k])
.clipExtent([[x - 0.425 * k + epsilon, y + 0.120 * k + epsilon], [x - 0.214 * k - epsilon, y + 0.233 * k - epsilon]])
.stream(pointStream);
hawaiiPoint = hawaii
.translate([x - 0.205 * k, y + 0.212 * k])
.clipExtent([[x - 0.214 * k + epsilon, y + 0.166 * k + epsilon], [x - 0.115 * k - epsilon, y + 0.233 * k - epsilon]])
.stream(pointStream);
puertoRicoPoint = puertoRico
.translate([x + 0.350 * k, y + 0.224 * k])
.clipExtent([[x + 0.312 * k + epsilon, y + 0.2064 * k + epsilon],[x + 0.385 * k - epsilon, y + 0.233 * k - epsilon]])
.stream(pointStream);
samoaPoint = samoa
.translate([x - 0.492 * k, y + 0.09 * k])
.clipExtent([[x - 0.4243 * k + epsilon, y + 0.0903 * k + epsilon],[x - 0.3233 * k - epsilon, y + 0.1197 * k - epsilon]])
.stream(pointStream);
guamPoint = guam
.translate([x - 0.408 * k, y + 0.018 * k])
.clipExtent([[x - 0.4244 * k + epsilon, y - 0.0519 * k + epsilon],[x - 0.3824 * k - epsilon, y + 0.0895 * k - epsilon]])
.stream(pointStream);
return albersUsa;
};
albersUsa.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT hawaii: ", hawaii.clipExtent());
console.info("UL BBOX:", lower48.invert([hawaii.clipExtent()[0][0], hawaii.clipExtent()[0][1]]));
console.info("UR BBOX:", lower48.invert([hawaii.clipExtent()[1][0], hawaii.clipExtent()[0][1]]));
console.info("LD BBOX:", lower48.invert([hawaii.clipExtent()[1][0], hawaii.clipExtent()[1][1]]));
console.info("LL BBOX:", lower48.invert([hawaii.clipExtent()[0][0], hawaii.clipExtent()[1][1]]));
console.info("CLIP EXTENT alaska: ", alaska.clipExtent());
console.info("UL BBOX:", lower48.invert([alaska.clipExtent()[0][0], alaska.clipExtent()[0][1]]));
console.info("UR BBOX:", lower48.invert([alaska.clipExtent()[1][0], alaska.clipExtent()[0][1]]));
console.info("LD BBOX:", lower48.invert([alaska.clipExtent()[1][0], alaska.clipExtent()[1][1]]));
console.info("LL BBOX:", lower48.invert([alaska.clipExtent()[0][0], alaska.clipExtent()[1][1]]));
console.info("CLIP EXTENT puertoRico: ", puertoRico.clipExtent());
console.info("UL BBOX:", lower48.invert([puertoRico.clipExtent()[0][0], puertoRico.clipExtent()[0][1]]));
console.info("UR BBOX:", lower48.invert([puertoRico.clipExtent()[1][0], puertoRico.clipExtent()[0][1]]));
console.info("LD BBOX:", lower48.invert([puertoRico.clipExtent()[1][0], puertoRico.clipExtent()[1][1]]));
console.info("LL BBOX:", lower48.invert([puertoRico.clipExtent()[0][0], puertoRico.clipExtent()[1][1]]));
console.info("CLIP EXTENT samoa: ", samoa.clipExtent());
console.info("UL BBOX:", lower48.invert([samoa.clipExtent()[0][0], samoa.clipExtent()[0][1]]));
console.info("UR BBOX:", lower48.invert([samoa.clipExtent()[1][0], samoa.clipExtent()[0][1]]));
console.info("LD BBOX:", lower48.invert([samoa.clipExtent()[1][0], samoa.clipExtent()[1][1]]));
console.info("LL BBOX:", lower48.invert([samoa.clipExtent()[0][0], samoa.clipExtent()[1][1]]));
console.info("CLIP EXTENT guam: ", guam.clipExtent());
console.info("UL BBOX:", lower48.invert([guam.clipExtent()[0][0], guam.clipExtent()[0][1]]));
console.info("UR BBOX:", lower48.invert([guam.clipExtent()[1][0], guam.clipExtent()[0][1]]));
console.info("LD BBOX:", lower48.invert([guam.clipExtent()[1][0], guam.clipExtent()[1][1]]));
console.info("LL BBOX:", lower48.invert([guam.clipExtent()[0][0], guam.clipExtent()[1][1]]));
*/
var ulhawaii = lower48([-110.4641, 28.2805]);
var urhawaii = lower48([-104.0597, 28.9528]);
var ldhawaii = lower48([-103.7049, 25.1031]);
var llhawaii = lower48([-109.8337, 24.4531]);
var ulalaska = lower48([ -124.4745, 28.1407]);
var uralaska = lower48([ -110.931, 30.8844]);
var ldalaska = lower48([-109.8337, 24.4531]);
var llalaska = lower48([-122.4628, 21.8562]);
var ulpuertoRico = lower48([-76.8579, 25.1544]);
var urpuertoRico = lower48([-72.429, 24.2097]);
var ldpuertoRico = lower48([-72.8265, 22.7056]);
var llpuertoRico = lower48([-77.1852, 23.6392]);
var ulsamoa = lower48([-125.0093, 29.7791]);
var ursamoa = lower48([-118.5193, 31.3262]);
var ldsamoa = lower48([-118.064, 29.6912]);
var llsamoa = lower48([-124.4369, 28.169]);
var ulguam = lower48([-128.1314, 37.4582]);
var urguam = lower48([-125.2132, 38.214]);
var ldguam = lower48([-122.3616, 30.5115]);
var llguam = lower48([-125.0315, 29.8211]);
context.moveTo(ulhawaii[0], ulhawaii[1]);
context.lineTo(urhawaii[0], urhawaii[1]);
context.lineTo(ldhawaii[0], ldhawaii[1]);
context.lineTo(ldhawaii[0], ldhawaii[1]);
context.lineTo(llhawaii[0], llhawaii[1]);
context.closePath();
context.moveTo(ulalaska[0], ulalaska[1]);
context.lineTo(uralaska[0], uralaska[1]);
context.lineTo(ldalaska[0], ldalaska[1]);
context.lineTo(ldalaska[0], ldalaska[1]);
context.lineTo(llalaska[0], llalaska[1]);
context.closePath();
context.moveTo(ulpuertoRico[0], ulpuertoRico[1]);
context.lineTo(urpuertoRico[0], urpuertoRico[1]);
context.lineTo(ldpuertoRico[0], ldpuertoRico[1]);
context.lineTo(ldpuertoRico[0], ldpuertoRico[1]);
context.lineTo(llpuertoRico[0], llpuertoRico[1]);
context.closePath();
context.moveTo(ulsamoa[0], ulsamoa[1]);
context.lineTo(ursamoa[0], ursamoa[1]);
context.lineTo(ldsamoa[0], ldsamoa[1]);
context.lineTo(ldsamoa[0], ldsamoa[1]);
context.lineTo(llsamoa[0], llsamoa[1]);
context.closePath();
context.moveTo(ulguam[0], ulguam[1]);
context.lineTo(urguam[0], urguam[1]);
context.lineTo(ldguam[0], ldguam[1]);
context.lineTo(ldguam[0], ldguam[1]);
context.lineTo(llguam[0], llguam[1]);
context.closePath();
};
albersUsa.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return albersUsa.scale(1070);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$2(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Spain, configured by default for 960×500.
function conicConformalSpain() {
var cache,
cacheStream,
iberianPeninsule = d3Geo.geoConicConformal().rotate([5, -38.6]).parallels([0,60]), iberianPeninsulePoint,
canaryIslands = d3Geo.geoConicConformal().rotate([5, -38.6]).parallels([0,60]), canaryIslandsPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var iberianPeninsuleBbox = [[-11, 46], [4, 35]];
var canaryIslandsBbox = [[-19.0, 28.85], [-12.7, 28.1]];
*/
function conicConformalSpain(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(iberianPeninsulePoint.point(x, y), point) ||
(canaryIslandsPoint.point(x, y), point);
}
conicConformalSpain.invert = function(coordinates) {
var k = iberianPeninsule.scale(),
t = iberianPeninsule.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
var c0 = canaryIslands(canaryIslandsBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 canary islands", x0 + ' - ' + y0);
var c1 = canaryIslands(canaryIslandsBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 canary islands", x1 + ' - ' + y1);
*/
return (y >= 0.05346 && y< 0.0897 && x >= -0.13388 && x < -0.0322 ? canaryIslands
: iberianPeninsule).invert(coordinates);
};
conicConformalSpain.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$2([iberianPeninsule.stream(cacheStream = stream), canaryIslands.stream(stream)]);
};
conicConformalSpain.precision = function(_) {
if (!arguments.length) {return iberianPeninsule.precision();}
iberianPeninsule.precision(_);
canaryIslands.precision(_);
return conicConformalSpain;
};
conicConformalSpain.scale = function(_) {
if (!arguments.length) {return iberianPeninsule.scale();}
iberianPeninsule.scale(_);
canaryIslands.scale(_);
return conicConformalSpain.translate(iberianPeninsule.translate());
};
conicConformalSpain.translate = function(_) {
if (!arguments.length) {return iberianPeninsule.translate();}
var k = iberianPeninsule.scale(), x = +_[0], y = +_[1];
/*
var c0 = iberianPeninsule(iberianPeninsuleBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = iberianPeninsule(iberianPeninsuleBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('Iberian Peninsula: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
c0 = canaryIslands.translate([x + 0.1 * k, y - 0.094 * k])(canaryIslandsBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = canaryIslands.translate([x + 0.1 * k, y - 0.094 * k])(canaryIslandsBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('Canry Islands: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
*/
iberianPeninsulePoint = iberianPeninsule
.translate(_)
.clipExtent([[x - 0.06857 * k, y - 0.1288 * k],[x + 0.13249 * k, y + 0.05292 * k]])
.stream(pointStream);
canaryIslandsPoint = canaryIslands
.translate([x + 0.1 * k, y - 0.094 * k])
.clipExtent([[x - 0.1331 * k + epsilon, y + 0.053457 * k + epsilon],[x - 0.0354 * k - epsilon, y + 0.08969 * k - epsilon]])
.stream(pointStream);
return conicConformalSpain;
};
conicConformalSpain.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT: ", canaryIslands.clipExtent());
console.info("UL BBOX:", iberianPeninsule.invert([canaryIslands.clipExtent()[0][0], canaryIslands.clipExtent()[0][1]]));
console.info("UR BBOX:", iberianPeninsule.invert([canaryIslands.clipExtent()[1][0], canaryIslands.clipExtent()[0][1]]));
console.info("LD BBOX:", iberianPeninsule.invert([canaryIslands.clipExtent()[1][0], canaryIslands.clipExtent()[1][1]]));
*/
var ulCanaryIslands = iberianPeninsule([-14.0346750522884, 34.96500729877966]);
var urCanaryIslands = iberianPeninsule([-7.4208899681602025, 35.53698899616862]);
var ldCanaryIslands = iberianPeninsule([-7.314827535125545, 33.54359498636456]);
context.moveTo(ulCanaryIslands[0], ulCanaryIslands[1]);
context.lineTo(urCanaryIslands[0], urCanaryIslands[1]);
context.lineTo(ldCanaryIslands[0], ldCanaryIslands[1]);
};
conicConformalSpain.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return conicConformalSpain.scale(2700);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$3(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Portugal, configured by default for 960×500.
function conicConformalPortugal() {
var cache,
cacheStream,
iberianPeninsule = d3Geo.geoConicConformal().rotate([10, -39.3]).parallels([0, 60]), iberianPeninsulePoint,
madeira = d3Geo.geoConicConformal().rotate([17, -32.7]).parallels([0, 60]), madeiraPoint,
azores = d3Geo.geoConicConformal().rotate([27.8, -38.6]).parallels([0, 60]), azoresPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var iberianPeninsuleBbox = [[-11, 46], [4, 34]];
var madeiraBbox = [[-17.85, 33.6], [-16, 32.02]];
var azoresBbox = [[-32, 40.529], [-23.98, 35.75]];
*/
function conicConformalPortugal(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(iberianPeninsulePoint.point(x, y), point) ||
(madeiraPoint.point(x, y), point) ||
(azoresPoint.point(x, y), point);
}
conicConformalPortugal.invert = function(coordinates) {
var k = iberianPeninsule.scale(),
t = iberianPeninsule.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
console.info("******");
var c0 = madeira(madeiraBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 madeira", x0 + ' - ' + y0);
var c1 = madeira(madeiraBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 madeira", x1 + ' - ' + y1);
c0 = azores(azoresBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 azores", x0 + ' - ' + y0);
c1 = azores(azoresBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 azores", x1 + ' - ' + y1);
*/
return (y >= 0.0093 && y< 0.03678 && x >= -0.03875 && x < -0.0116 ? madeira
: y >= -0.0412 && y< 0.0091 && x >= -0.07782 && x < -0.01166 ? azores
: iberianPeninsule).invert(coordinates);
};
conicConformalPortugal.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$3([iberianPeninsule.stream(cacheStream = stream), madeira.stream(stream), azores.stream(stream)]);
};
conicConformalPortugal.precision = function(_) {
if (!arguments.length) {return iberianPeninsule.precision();}
iberianPeninsule.precision(_);
madeira.precision(_);
azores.precision(_);
return conicConformalPortugal;
};
conicConformalPortugal.scale = function(_) {
if (!arguments.length) {return iberianPeninsule.scale();}
iberianPeninsule.scale(_);
madeira.scale(_);
azores.scale(_ * 0.6);
return conicConformalPortugal.translate(iberianPeninsule.translate());
};
conicConformalPortugal.translate = function(_) {
if (!arguments.length) {return iberianPeninsule.translate();}
var k = iberianPeninsule.scale(), x = +_[0], y = +_[1];
/*
var c0 = iberianPeninsule(iberianPeninsuleBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = iberianPeninsule(iberianPeninsuleBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('Iberian Peninsula: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k]])');
c0 = madeira.translate([x - 0.0265 * k, y + 0.025 * k])(madeiraBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = madeira.translate([x - 0.0265 * k, y + 0.025 * k])(madeiraBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('Madeira: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = azores.translate([x - 0.045 * k, y + -0.02 * k])(azoresBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = azores.translate([x - 0.045 * k, y + -0.02 * k])(azoresBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('Azores: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
*/
iberianPeninsulePoint = iberianPeninsule
.translate(_)
.clipExtent([[x - 0.0115 * k, y - 0.1138 * k],[x +0.2105 * k, y +0.0673 * k]])
.stream(pointStream);
madeiraPoint = madeira
.translate([x - 0.0265 * k, y + 0.025 * k])
.clipExtent([[x - 0.0388 * k + epsilon, y + 0.0093 * k + epsilon],[x - 0.0116 * k - epsilon, y + 0.0368 * k - epsilon]])
.stream(pointStream);
azoresPoint = azores
.translate([x - 0.045 * k, y + -0.02 * k])
.clipExtent([[x - 0.0778 * k + epsilon, y - 0.0413 * k + epsilon],[x - 0.0117 * k - epsilon, y + 0.0091 * k - epsilon]])
.stream(pointStream);
return conicConformalPortugal;
};
conicConformalPortugal.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT MADEIRA: ", madeira.clipExtent());
console.info("UL BBOX:", iberianPeninsule.invert([madeira.clipExtent()[0][0], madeira.clipExtent()[0][1]]));
console.info("UR BBOX:", iberianPeninsule.invert([madeira.clipExtent()[1][0], madeira.clipExtent()[0][1]]));
console.info("LD BBOX:", iberianPeninsule.invert([madeira.clipExtent()[1][0], madeira.clipExtent()[1][1]]));
console.info("LL BBOX:", iberianPeninsule.invert([madeira.clipExtent()[0][0], madeira.clipExtent()[1][1]]));
console.info("CLIP EXTENT AZORES: ", azores.clipExtent());
console.info("UL BBOX:", iberianPeninsule.invert([azores.clipExtent()[0][0], azores.clipExtent()[0][1]]));
console.info("UR BBOX:", iberianPeninsule.invert([azores.clipExtent()[1][0], azores.clipExtent()[0][1]]));
console.info("LD BBOX:", iberianPeninsule.invert([azores.clipExtent()[1][0], azores.clipExtent()[1][1]]));
console.info("LL BBOX:", iberianPeninsule.invert([azores.clipExtent()[0][0], azores.clipExtent()[1][1]]));
*/
var ulmadeira = iberianPeninsule([-12.8351, 38.7113]);
var urmadeira = iberianPeninsule([-10.8482, 38.7633]);
var ldmadeira = iberianPeninsule([-10.8181, 37.2072]);
var llmadeira = iberianPeninsule([-12.7345, 37.1573]);
var ulazores = iberianPeninsule([-16.0753, 41.4436]);
var urazores = iberianPeninsule([-10.9168, 41.6861]);
var ldazores = iberianPeninsule([-10.8557, 38.7747]);
var llazores = iberianPeninsule([-15.6728, 38.5505]);
context.moveTo(ulmadeira[0], ulmadeira[1]);
context.lineTo(urmadeira[0], urmadeira[1]);
context.lineTo(ldmadeira[0], ldmadeira[1]);
context.lineTo(ldmadeira[0], ldmadeira[1]);
context.lineTo(llmadeira[0], llmadeira[1]);
context.closePath();
context.moveTo(ulazores[0], ulazores[1]);
context.lineTo(urazores[0], urazores[1]);
context.lineTo(ldazores[0], ldazores[1]);
context.lineTo(ldazores[0], ldazores[1]);
context.lineTo(llazores[0], llazores[1]);
context.closePath();
};
conicConformalPortugal.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return conicConformalPortugal.scale(4200);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$4(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Ecuador, configured by default for 960×500.
function mercatorEcuador() {
var cache,
cacheStream,
mainland = d3Geo.geoMercator().rotate([80, 1.5]), mainlandPoint,
galapagos = d3Geo.geoMercator().rotate([90.73, 1]), galapagosPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var mainlandBbox = [[-81.5, 2.7], [-70.0, -6.0]];
var galapagosBbox = [[-92.2, 0.58], [-88.8, -1.8]];
*/
function mercatorEcuador(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(mainlandPoint.point(x, y), point) ||
(galapagosPoint.point(x, y), point);
}
mercatorEcuador.invert = function(coordinates) {
var k = mainland.scale(),
t = mainland.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
var c0 = galapagos(galapagosBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 galapagos", x0 + ' - ' + y0);
var c1 = galapagos(galapagosBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 galapagos", x1 + ' - ' + y1);
*/
return (y >= -0.0676 && y< -0.026 && x >= -0.0857 && x < -0.0263 ? galapagos
: mainland).invert(coordinates);
};
mercatorEcuador.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$4([mainland.stream(cacheStream = stream), galapagos.stream(stream)]);
};
mercatorEcuador.precision = function(_) {
if (!arguments.length) {return mainland.precision();}
mainland.precision(_);
galapagos.precision(_);
return mercatorEcuador;
};
mercatorEcuador.scale = function(_) {
if (!arguments.length) {return mainland.scale();}
mainland.scale(_);
galapagos.scale(_);
return mercatorEcuador.translate(mainland.translate());
};
mercatorEcuador.translate = function(_) {
if (!arguments.length) {return mainland.translate();}
var k = mainland.scale(), x = +_[0], y = +_[1];
/*
var c0 = mainland(mainlandBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = mainland(mainlandBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('mainland: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k]])');
c0 = galapagos.translate([x - 0.06 * k, y - 0.04 * k])(galapagosBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = galapagos.translate([x - 0.06 * k, y - 0.04 * k])(galapagosBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('galapagos: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');*/
mainlandPoint = mainland
.translate(_)
.clipExtent([[x - 0.0262 * k, y - 0.0734 * k],[x + 0.1741 * k, y + 0.079 * k]])
.stream(pointStream);
galapagosPoint = galapagos
.translate([x - 0.06 * k, y - 0.04 * k])
.clipExtent([[x - 0.0857 * k + epsilon, y - 0.0676 * k + epsilon],[x - 0.0263 * k - epsilon, y - 0.026 * k - epsilon]])
.stream(pointStream);
return mercatorEcuador;
};
mercatorEcuador.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT: ", galapagos.clipExtent());
console.info("UL BBOX:", mainland.invert([galapagos.clipExtent()[0][0], galapagos.clipExtent()[0][1]]));
console.info("UR BBOX:", mainland.invert([galapagos.clipExtent()[1][0], galapagos.clipExtent()[0][1]]));
console.info("LD BBOX:", mainland.invert([galapagos.clipExtent()[1][0], galapagos.clipExtent()[1][1]]));
console.info("LL BBOX:", mainland.invert([galapagos.clipExtent()[0][0], galapagos.clipExtent()[1][1]]));
*/
var ulgalapagos = mainland([-84.9032, 2.3757]);
var urgalapagos = mainland([-81.5047, 2.3708]);
var ldgalapagos = mainland([-81.5063, -0.01]);
var llgalapagos = mainland([-84.9086, -0.005]);
context.moveTo(ulgalapagos[0], ulgalapagos[1]);
context.lineTo(urgalapagos[0], urgalapagos[1]);
context.lineTo(ldgalapagos[0], ldgalapagos[1]);
context.lineTo(llgalapagos[0], llgalapagos[1]);
context.closePath();
};
mercatorEcuador.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return mercatorEcuador.scale(3500);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$5(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Chile, configured by default for 960×500.
function transverseMercatorChile() {
var cache,
cacheStream,
mainland = d3Geo.geoTransverseMercator().rotate([72, 37]), mainlandPoint,
antarctic = d3Geo.geoStereographic().rotate([72, 0]), antarcticPoint,
juanFernandez = d3Geo.geoMercator().rotate([80, 33.5]), juanFernandezPoint,
pascua = d3Geo.geoMercator().rotate([110, 25]), pascuaPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var mainlandBbox = [[-75.5, -15.0], [-32, -49.0]];
var antarcticBbox = [[-91.0, -60.0], [-43.0, -90.0]];
var juanFernandezBbox = [[-81.0, -33.0], [-78.5, -34.0]];
var pascuaBbox = [[-110, -26.6], [-108.7, -27.5]];
*/
function transverseMercatorChile(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(mainlandPoint.point(x, y), point) ||
(antarcticPoint.point(x, y), point) ||
(juanFernandezPoint.point(x, y), point) ||
(pascuaPoint.point(x, y), point);
}
transverseMercatorChile.invert = function(coordinates) {
var k = mainland.scale(),
t = mainland.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
console.info("******");
var c0 = antarctic(antarcticBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 antarctic", x0 + ' - ' + y0);
var c1 = antarctic(antarcticBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 antarctic", x1 + ' - ' + y1);
c0 = juanFernandez(juanFernandezBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 juanFernandez", x0 + ' - ' + y0);
c1 = juanFernandez(juanFernandezBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 juanFernandez", x1 + ' - ' + y1);
c0 = pascua(pascuaBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 pascua", x0 + ' - ' + y0);
c1 = pascua(pascuaBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 pascua", x1 + ' - ' + y1);
*/
return (y >= 0.2582 && y< 0.32 && x >= -0.1036 && x < -0.087 ? antarctic
: y >= -0.01298 && y< 0.0133 && x >= -0.11396 && x < -0.05944 ? juanFernandez
: y >= 0.01539 && y< 0.03911 && x >= -0.089 && x < -0.0588 ? pascua
: mainland).invert(coordinates);
};
transverseMercatorChile.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$5([mainland.stream(cacheStream = stream), antarctic.stream(stream), juanFernandez.stream(stream), pascua.stream(stream)]);
};
transverseMercatorChile.precision = function(_) {
if (!arguments.length) {return mainland.precision();}
mainland.precision(_);
antarctic.precision(_);
juanFernandez.precision(_);
pascua.precision(_);
return transverseMercatorChile;
};
transverseMercatorChile.scale = function(_) {
if (!arguments.length) {return mainland.scale();}
mainland.scale(_);
antarctic.scale(_ * 0.15);
juanFernandez.scale(_ * 1.5);
pascua.scale(_ * 1.5);
return transverseMercatorChile.translate(mainland.translate());
};
transverseMercatorChile.translate = function(_) {
if (!arguments.length) {return mainland.translate();}
var k = mainland.scale(), x = +_[0], y = +_[1];
/*
var c0 = mainland(mainlandBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = mainland(mainlandBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('Mainland: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k]])');
c0 = antarctic.translate([x - 0.1 * k, y + 0.17 * k])(antarcticBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = antarctic.translate([x - 0.1 * k, y + 0.17 * k])(antarcticBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('antarctic: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('Doesn t work due to -90 latitude!' + '.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = juanFernandez.translate([x - 0.092 * k, y -0 * k])(juanFernandezBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = juanFernandez.translate([x - 0.092 * k, y -0 * k])(juanFernandezBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('juanFernandez: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = pascua.translate([x - 0.089 * k, y -0.0265 * k])(pascuaBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = pascua.translate([x - 0.089 * k, y -0.0265 * k])(pascuaBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('pascua: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
*/
mainlandPoint = mainland
.translate(_)
.clipExtent([[x - 0.059 * k, y - 0.3835 * k],[x + 0.4498 * k, y + 0.3375 * k]])
.stream(pointStream);
antarcticPoint = antarctic
.translate([x - 0.087 * k, y + 0.17 * k])
.clipExtent([[x - 0.1166 * k + epsilon, y + 0.2582 * k + epsilon],[x - 0.06 * k - epsilon, y + 0.32 * k - epsilon]])
.stream(pointStream);
juanFernandezPoint = juanFernandez
.translate([x - 0.092 * k, y - 0 * k])
.clipExtent([[x - 0.114 * k + epsilon, y - 0.013 * k + epsilon],[x - 0.0594 * k - epsilon, y + 0.0133 * k - epsilon]])
.stream(pointStream);
pascuaPoint = pascua
.translate([x - 0.089 * k, y - 0.0265 * k])
.clipExtent([[x - 0.089 * k + epsilon, y + 0.0154 * k + epsilon],[x - 0.0588 * k - epsilon, y + 0.0391 * k - epsilon]])
.stream(pointStream);
return transverseMercatorChile;
};
transverseMercatorChile.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT antarctic: ", antarctic.clipExtent());
console.info("UL BBOX:", mainland.invert([antarctic.clipExtent()[0][0], antarctic.clipExtent()[0][1]]));
console.info("UR BBOX:", mainland.invert([antarctic.clipExtent()[1][0], antarctic.clipExtent()[0][1]]));
console.info("LD BBOX:", mainland.invert([antarctic.clipExtent()[1][0], antarctic.clipExtent()[1][1]]));
console.info("LL BBOX:", mainland.invert([antarctic.clipExtent()[0][0], antarctic.clipExtent()[1][1]]));
console.info("CLIP EXTENT juanFernandez: ", juanFernandez.clipExtent());
console.info("UL BBOX:", mainland.invert([juanFernandez.clipExtent()[0][0], juanFernandez.clipExtent()[0][1]]));
console.info("UR BBOX:", mainland.invert([juanFernandez.clipExtent()[1][0], juanFernandez.clipExtent()[0][1]]));
console.info("LD BBOX:", mainland.invert([juanFernandez.clipExtent()[1][0], juanFernandez.clipExtent()[1][1]]));
console.info("LL BBOX:", mainland.invert([juanFernandez.clipExtent()[0][0], juanFernandez.clipExtent()[1][1]]));
console.info("CLIP EXTENT pascua: ", pascua.clipExtent());
console.info("UL BBOX:", mainland.invert([pascua.clipExtent()[0][0], pascua.clipExtent()[0][1]]));
console.info("UR BBOX:", mainland.invert([pascua.clipExtent()[1][0], pascua.clipExtent()[0][1]]));
console.info("LD BBOX:", mainland.invert([pascua.clipExtent()[1][0], pascua.clipExtent()[1][1]]));
console.info("LL BBOX:", mainland.invert([pascua.clipExtent()[0][0], pascua.clipExtent()[1][1]]));
*/
var ulantarctic = mainland([-82.6999, -51.3043]);
var urantarctic = mainland([-77.5442, -51.6631]);
var ldantarctic = mainland([-78.0254, -55.1860]);
var llantarctic = mainland([-83.6106, -54.7785]);
var uljuanFernandez = mainland([-80.0638, -35.9840]);
var urjuanFernandez = mainland([-76.2153, -36.1811]);
var ldjuanFernandez = mainland([-76.2994, -37.6839]);
var lljuanFernandez = mainland([-80.2231, -37.4757]);
var ulpascua = mainland([-78.442, -37.706]);
var urpascua = mainland([-76.263, -37.8054]);
var ldpascua = mainland([-76.344, -39.1595]);
var llpascua = mainland([-78.5638, -39.0559]);
context.moveTo(ulantarctic[0], ulantarctic[1]);
context.lineTo(urantarctic[0], urantarctic[1]);
context.lineTo(ldantarctic[0], ldantarctic[1]);
context.lineTo(ldantarctic[0], ldantarctic[1]);
context.lineTo(llantarctic[0], llantarctic[1]);
context.closePath();
context.moveTo(uljuanFernandez[0], uljuanFernandez[1]);
context.lineTo(urjuanFernandez[0], urjuanFernandez[1]);
context.lineTo(ldjuanFernandez[0], ldjuanFernandez[1]);
context.lineTo(ldjuanFernandez[0], ldjuanFernandez[1]);
context.lineTo(lljuanFernandez[0], lljuanFernandez[1]);
context.closePath();
context.moveTo(ulpascua[0], ulpascua[1]);
context.lineTo(urpascua[0], urpascua[1]);
context.lineTo(ldpascua[0], ldpascua[1]);
context.lineTo(ldpascua[0], ldpascua[1]);
context.lineTo(llpascua[0], llpascua[1]);
context.closePath();
};
transverseMercatorChile.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return transverseMercatorChile.scale(700);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$6(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Portugal, configured by default for 960×500.
function conicEquidistantJapan() {
var cache,
cacheStream,
mainland = d3Geo.geoConicEquidistant().rotate([-136, -22]).parallels([40, 34]), mainlandPoint, //gis.stackexchange.com/a/73135
hokkaido = d3Geo.geoConicEquidistant().rotate([-146, -26]).parallels([40, 34]), hokkaidoPoint,
okinawa = d3Geo.geoConicEquidistant().rotate([-126, -19]).parallels([40, 34]), okinawaPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var mainlandBbox = [[126.0, 41.606], [142.97, 29.97]];
var hokkaidoBbox = [[138.7, 45.61], [146.2, 41.2]];
var okinawaBbox = [[122.6, 29.0], [130, 23.7]];
*/
function conicEquidistantJapan(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(mainlandPoint.point(x, y), point) ||
(hokkaidoPoint.point(x, y), point) ||
(okinawaPoint.point(x, y), point);
}
conicEquidistantJapan.invert = function(coordinates) {
var k = mainland.scale(),
t = mainland.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
/*
//How are the return values calculated:
console.info("******");
var c0 = hokkaido(hokkaidoBbox[0]);
var x0 = (c0[0] - t[0]) / k;
var y0 = (c0[1] - t[1]) / k;
console.info("p0 hokkaido", x0 + ' - ' + y0);
var c1 = hokkaido(hokkaidoBbox[1]);
var x1 = (c1[0] - t[0]) / k;
var y1 = (c1[1] - t[1]) / k;
console.info("p1 hokkaido", x1 + ' - ' + y1);
c0 = okinawa(okinawaBbox[0]);
x0 = (c0[0] - t[0]) / k;
y0 = (c0[1] - t[1]) / k;
console.info("p0 okinawa", x0 + ' - ' + y0);
c1 = okinawa(okinawaBbox[1]);
x1 = (c1[0] - t[0]) / k;
y1 = (c1[1] - t[1]) / k;
console.info("p1 okinawa", x1 + ' - ' + y1);
*/
return (y >= -0.10925 && y< -0.02701 && x >= -0.135 && x < -0.0397 ? hokkaido
: y >= 0.04713 && y< 0.11138 && x >= -0.03986 && x < 0.051 ? okinawa
: mainland).invert(coordinates);
};
conicEquidistantJapan.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$6([mainland.stream(cacheStream = stream), hokkaido.stream(stream), okinawa.stream(stream)]);
};
conicEquidistantJapan.precision = function(_) {
if (!arguments.length) {return mainland.precision();}
mainland.precision(_);
hokkaido.precision(_);
okinawa.precision(_);
return conicEquidistantJapan;
};
conicEquidistantJapan.scale = function(_) {
if (!arguments.length) {return mainland.scale();}
mainland.scale(_);
hokkaido.scale(_);
okinawa.scale(_ * 0.7);
return conicEquidistantJapan.translate(mainland.translate());
};
conicEquidistantJapan.translate = function(_) {
if (!arguments.length) {return mainland.translate();}
var k = mainland.scale(), x = +_[0], y = +_[1];
/*
var c0 = mainland(mainlandBbox[0]);
var x0 = (x - c0[0]) / k;
var y0 = (y - c0[1]) / k;
var c1 = mainland(mainlandBbox[1]);
var x1 = (x - c1[0]) / k;
var y1 = (y - c1[1]) / k;
console.info('Main: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k]])');
c0 = hokkaido.translate([x - 0.0425 * k, y - 0.005 * k])(hokkaidoBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = hokkaido.translate([x - 0.0425 * k, y - 0.005 * k])(hokkaidoBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('hokkaido: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
c0 = okinawa.translate([x - 0 * k, y + 0 * k])(okinawaBbox[0]);
x0 = (x - c0[0]) / k;
y0 = (y - c0[1]) / k;
c1 = okinawa.translate([x - 0 * k, y + 0 * k])(okinawaBbox[1]);
x1 = (x - c1[0]) / k;
y1 = (y - c1[1]) / k;
console.info('okinawa: p0: ' + x0 + ', ' + y0 + ' , p1: ' + x1 + ' - ' + y1);
console.info('.clipExtent([[x '+
(x0<0?'+ ':'- ') + Math.abs(x0.toFixed(4))+
' * k + epsilon, y '+
(y0<0?'+ ':'- ') + Math.abs(y0.toFixed(4))+
' * k + epsilon],[x '+
(x1<0?'+ ':'- ') + Math.abs(x1.toFixed(4))+
' * k - epsilon, y '+
(y1<0?'+ ':'- ') + Math.abs(y1.toFixed(4))+
' * k - epsilon]])');
*/
mainlandPoint = mainland
.translate(_)
.clipExtent([[x - 0.1352 * k, y - 0.1091 * k],[x + 0.117 * k, y + 0.098 * k]])
.stream(pointStream);
hokkaidoPoint = hokkaido
.translate([x - 0.0425 * k, y - 0.005 * k])
.clipExtent([[x - 0.135 * k + epsilon, y - 0.1093 * k + epsilon],[x - 0.0397 * k - epsilon, y - 0.027 * k - epsilon]])
.stream(pointStream);
okinawaPoint = okinawa
.translate(_)
.clipExtent([[x - 0.0399 * k + epsilon, y + 0.0471 * k + epsilon],[x + 0.051 * k - epsilon, y + 0.1114 * k - epsilon]])
.stream(pointStream);
return conicEquidistantJapan;
};
conicEquidistantJapan.drawCompositionBorders = function(context) {
/*
console.info("CLIP EXTENT hokkaido: ", hokkaido.clipExtent());
console.info("UL BBOX:", mainland.invert([hokkaido.clipExtent()[0][0], hokkaido.clipExtent()[0][1]]));
console.info("UR BBOX:", mainland.invert([hokkaido.clipExtent()[1][0], hokkaido.clipExtent()[0][1]]));
console.info("LD BBOX:", mainland.invert([hokkaido.clipExtent()[1][0], hokkaido.clipExtent()[1][1]]));
console.info("LL BBOX:", mainland.invert([hokkaido.clipExtent()[0][0], hokkaido.clipExtent()[1][1]]));
*/
var ulhokkaido = mainland([ 126.01320483689143, 41.621090310215585 ]);
var urhokkaido = mainland([ 133.04304387025903, 42.15087523707186 ]);
var ldhokkaido = mainland([ 133.3021766080688, 37.43975444725098 ]);
var llhokkaido = mainland([ 126.87889168628224, 36.95488945159779 ]);
var llokinawa = mainland([132.9, 29.8]);
var lmokinawa = mainland([134, 33]);
var lrokinawa = mainland([139.3, 33.2]);
var llrokinawa = mainland([139.16, 30.5]);
context.moveTo(ulhokkaido[0], ulhokkaido[1]);
context.lineTo(urhokkaido[0], urhokkaido[1]);
context.lineTo(ldhokkaido[0], ldhokkaido[1]);
context.lineTo(llhokkaido[0], llhokkaido[1]);
context.closePath();
context.moveTo(llokinawa[0], llokinawa[1]);
context.lineTo(lmokinawa[0], lmokinawa[1]);
context.lineTo(lrokinawa[0], lrokinawa[1]);
context.lineTo(llrokinawa[0], llrokinawa[1]);
};
conicEquidistantJapan.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return conicEquidistantJapan.scale(2200);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$7(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Portugal, configured by default for 960×500.
function conicConformalFrance() {
var cache,
cacheStream,
europe = d3Geo.geoConicConformal().rotate([-3, -46.2]).parallels([0, 60]), europePoint,
guyane = d3Geo.geoMercator().center([-53.2, 3.9]), guyanePoint,
martinique = d3Geo.geoMercator().center([-61.03, 14.67]), martiniquePoint,
guadeloupe = d3Geo.geoMercator().center([-61.46, 16.14]), guadeloupePoint,
saintBarthlemy = d3Geo.geoMercator().center([-62.85, 17.92]), saintBarthlemyPoint,
stPierreMichelon = d3Geo.geoMercator().center([-56.23, 46.93]), stPierreMichelonPoint,
mayotte = d3Geo.geoMercator().center([45.16, -12.8]), mayottePoint,
reunion = d3Geo.geoMercator().center([55.52, -21.13]), reunionPoint,
nouvelleCaledonie = d3Geo.geoMercator().center([165.8, -21.07]), nouvelleCaledoniePoint,
wallisFutuna = d3Geo.geoMercator().center([-178.1, -14.3]), wallisFutunaPoint,
polynesie = d3Geo.geoMercator().center([-150.55, -17.11]), polynesiePoint,
polynesie2 = d3Geo.geoMercator().center([-150.55, -17.11]), polynesie2Point,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var europeBbox = [[-6.5, 51], [10, 41]];
var guyaneBbox = [[-54.5, 6.29], [-50.9, 1.48]];
*/
function conicConformalFrance(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(europePoint.point(x, y), point) ||
(guyanePoint.point(x, y), point) ||
(martiniquePoint.point(x, y), point) ||
(guadeloupePoint.point(x, y), point) ||
(saintBarthlemyPoint.point(x, y), point) ||
(stPierreMichelonPoint.point(x, y), point) ||
(mayottePoint.point(x, y), point) ||
(reunionPoint.point(x, y), point) ||
(nouvelleCaledoniePoint.point(x, y), point) ||
(wallisFutunaPoint.point(x, y), point) ||
(polynesiePoint.point(x, y), point) ||
(polynesie2Point.point(x, y), point);
}
conicConformalFrance.invert = function(coordinates) {
var k = europe.scale(),
t = europe.translate(),
x = (coordinates[0] - t[0]) / k,
y = (coordinates[1] - t[1]) / k;
return (y >= 0.029 && y< 0.0864 && x >= -0.14 && x < -0.0996 ? guyane
: y >= 0 && y< 0.029 && x >= -0.14 && x < -0.0996 ? martinique
: y >= -0.032 && y< 0 && x >= -0.14 && x < -0.0996 ? guadeloupe
: y >= -0.052 && y< -0.032 && x >= -0.14 && x < -0.0996 ? saintBarthlemy
: y >= -0.076 && y< 0.052 && x >= -0.14 && x < -0.0996 ? stPierreMichelon
: y >= -0.076 && y< -0.052 && x >= 0.0967 && x < 0.1371 ? mayotte
: y >= -0.052 && y< -0.02 && x >= 0.0967 && x < 0.1371 ? reunion
: y >= -0.02 && y< 0.012 && x >= 0.0967 && x < 0.1371 ? nouvelleCaledonie
: y >= 0.012 && y< 0.033 && x >= 0.0967 && x < 0.1371 ? wallisFutuna
: y >= 0.033 && y< 0.0864 && x >= 0.0967 && x < 0.1371 ? polynesie
: europe).invert(coordinates);
};
conicConformalFrance.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$7([europe.stream(cacheStream = stream), guyane.stream(stream), martinique.stream(stream), guadeloupe.stream(stream), saintBarthlemy.stream(stream), stPierreMichelon.stream(stream), mayotte.stream(stream), reunion.stream(stream), nouvelleCaledonie.stream(stream), wallisFutuna.stream(stream), polynesie.stream(stream), polynesie2.stream(stream)]);
};
conicConformalFrance.precision = function(_) {
if (!arguments.length) {return europe.precision();}
europe.precision(_);
guyane.precision(_);
martinique.precision(_);
guadeloupe.precision(_);
saintBarthlemy.precision(_);
stPierreMichelon.precision(_);
mayotte.precision(_);
reunion.precision(_);
nouvelleCaledonie.precision(_);
wallisFutuna.precision(_);
polynesie.precision(_);
polynesie2.precision(_);
return conicConformalFrance;
};
conicConformalFrance.scale = function(_) {
if (!arguments.length) {return europe.scale();}
europe.scale(_);
guyane.scale(_ * 0.6);
martinique.scale(_ * 1.6);
guadeloupe.scale(_ * 1.4);
saintBarthlemy.scale(_ * 5);
stPierreMichelon.scale(_ * 1.3);
mayotte.scale(_ * 1.6);
reunion.scale(_ * 1.2);
nouvelleCaledonie.scale(_ * 0.3);
wallisFutuna.scale(_ * 2.7);
polynesie.scale(_ * 0.5);
polynesie2.scale(_ * 0.06);
return conicConformalFrance.translate(europe.translate());
};
conicConformalFrance.translate = function(_) {
if (!arguments.length) {return europe.translate();}
var k = europe.scale(), x = +_[0], y = +_[1];
europePoint = europe
.translate(_)
.clipExtent([[x - 0.0996 * k, y - 0.0908 * k],[x + 0.0967 * k, y + 0.0864 * k]])
.stream(pointStream);
guyanePoint = guyane
.translate([x - 0.12 * k, y + 0.0575 * k])
.clipExtent([[x - 0.14 * k + epsilon, y + 0.029 * k + epsilon],[x - 0.0996 * k - epsilon, y + 0.0864 * k - epsilon]])
.stream(pointStream);
martiniquePoint = martinique
.translate([x - 0.12 * k, y + 0.013 * k])
.clipExtent([[x - 0.14 * k + epsilon, y + 0 * k + epsilon],[x - 0.0996 * k - epsilon, y + 0.029 * k - epsilon]])
.stream(pointStream);
guadeloupePoint = guadeloupe
.translate([x - 0.12 * k, y -0.014 * k])
.clipExtent([[x - 0.14 * k + epsilon, y - 0.032 * k + epsilon],[x - 0.0996 * k - epsilon, y + 0 * k - epsilon]])
.stream(pointStream);
saintBarthlemyPoint = saintBarthlemy
.translate([x - 0.12 * k, y - 0.044 * k])
.clipExtent([[x - 0.14 * k + epsilon, y - 0.052 * k + epsilon],[x - 0.0996 * k - epsilon, y - 0.032 * k - epsilon]])
.stream(pointStream);
stPierreMichelonPoint = stPierreMichelon
.translate([x - 0.12 * k, y - 0.065 * k])
.clipExtent([[x - 0.14 * k + epsilon, y - 0.076 * k + epsilon],[x - 0.0996 * k - epsilon, y - 0.052 * k - epsilon]])
.stream(pointStream);
mayottePoint = mayotte
.translate([x + 0.117 * k, y - 0.064 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y - 0.076 * k + epsilon],[x + 0.1371 * k - epsilon, y - 0.052 * k - epsilon]])
.stream(pointStream);
reunionPoint = reunion
.translate([x + 0.116 * k, y - 0.0355 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y - 0.052 * k + epsilon],[x + 0.1371 * k - epsilon, y - 0.02 * k - epsilon]])
.stream(pointStream);
nouvelleCaledoniePoint = nouvelleCaledonie
.translate([x + 0.116 * k, y - 0.0048 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y - 0.02 * k + epsilon],[x + 0.1371 * k - epsilon, y + 0.012 * k - epsilon]])
.stream(pointStream);
wallisFutunaPoint = wallisFutuna
.translate([x + 0.116 * k, y + 0.022 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y + 0.012 * k + epsilon],[x + 0.1371 * k - epsilon, y + 0.033 * k - epsilon]])
.stream(pointStream);
polynesie2Point = polynesie2
.translate([x + 0.11 * k, y + 0.045 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y + 0.033 * k + epsilon],[x + 0.1371 * k - epsilon, y + 0.06 * k - epsilon]])
.stream(pointStream);
polynesiePoint = polynesie
.translate([x + 0.115 * k, y + 0.075 * k])
.clipExtent([[x + 0.0967 * k + epsilon, y + 0.06 * k + epsilon],[x + 0.1371 * k - epsilon, y + 0.0864 * k - epsilon]])
.stream(pointStream);
return conicConformalFrance;
};
conicConformalFrance.drawCompositionBorders = function(context) {
/*
console.log("var ul, ur, ld, ll;");
var projs = [guyane, martinique, guadeloupe, saintBarthlemy, stPierreMichelon, mayotte, reunion, nouvelleCaledonie, wallisFutuna, polynesie, polynesie2];
for (var i in projs){
var ul = europe.invert([projs[i].clipExtent()[0][0], projs[i].clipExtent()[0][1]]);
var ur = europe.invert([projs[i].clipExtent()[1][0], projs[i].clipExtent()[0][1]]);
var ld = europe.invert([projs[i].clipExtent()[1][0], projs[i].clipExtent()[1][1]]);
var ll = europe.invert([projs[i].clipExtent()[0][0], projs[i].clipExtent()[1][1]]);
console.log("ul = europe(["+ul+"]);");
console.log("ur = europe(["+ur+"]);");
console.log("ld = europe(["+ld+"]);");
console.log("ll = europe(["+ll+"]);");
console.log("context.moveTo(ul[0], ul[1]);");
console.log("context.lineTo(ur[0], ur[1]);");
console.log("context.lineTo(ld[0], ld[1]);");
console.log("context.lineTo(ll[0], ll[1]);");
console.log("context.closePath();");
}*/
var ul, ur, ld, ll;
ul = europe([-7.938886725111036,43.7219460918835]);
ur = europe([-4.832080896458295,44.12930268549372]);
ld = europe([-4.205299743793263,40.98096346967365]);
ll = europe([-7.071796453126152,40.610037319181444]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([-8.42751373617692,45.32889452553031]);
ur = europe([-5.18599305777107,45.7566442062976]);
ld = europe([-4.832080905154431,44.129302726751426]);
ll = europe([-7.938886737126192,43.72194613263854]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([-9.012656899657046,47.127733821030176]);
ur = europe([-5.6105244772793155,47.579777861410626]);
ld = europe([-5.185993067168585,45.756644248170346]);
ll = europe([-8.427513749141811,45.32889456686326]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([-9.405747558985553,48.26506375557457]);
ur = europe([-5.896175018439575,48.733352850851624]);
ld = europe([-5.610524487556043,47.57977790393761]);
ll = europe([-9.012656913808351,47.127733862971255]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([-9.908436061346974,49.642448789505856]);
ur = europe([-6.262026716233124,50.131426841787174]);
ld = europe([-5.896175029331232,48.73335289377258]);
ll = europe([-9.40574757396393,48.26506379787767]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([11.996907706504462,50.16039028163579]);
ur = europe([15.649907879773343,49.68279246765253]);
ld = europe([15.156712840526632,48.30371557625831]);
ll = europe([11.64122661754411,48.761078240546816]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([11.641226606955788,48.7610781975889]);
ur = europe([15.156712825832164,48.30371553390465]);
ld = europe([14.549932166241172,46.4866532486199]);
ll = europe([11.204443787952183,46.91899233914248]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([11.204443778297161,46.918992296823646]);
ur = europe([14.549932152815039,46.486653206856396]);
ld = europe([13.994409796764009,44.695833444323256]);
ll = europe([10.805306599253848,45.105133870684924]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([10.805306590412085,45.10513382903308]);
ur = europe([13.99440978444733,44.695833403183606]);
ld = europe([13.654633799024392,43.53552468558152]);
ll = europe([10.561516803980956,43.930671459798624]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([10.561516795617383,43.93067141859757]);
ur = europe([13.654633787361952,43.5355246448671]);
ld = europe([12.867691604239901,40.640701985019405]);
ll = europe([9.997809515987688,41.00288343254471]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([10.8,42.4]);
ur = europe([12.8,42.13]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
};
conicConformalFrance.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return conicConformalFrance.scale(2700);
}
// The projections must have mutually exclusive clip regions on the sphere,
// as this will avoid emitting interleaving lines and polygons.
function multiplex$8(streams) {
var n = streams.length;
return {
point: function(x, y) { var i = -1; while (++i < n) {streams[i].point(x, y); }},
sphere: function() { var i = -1; while (++i < n) {streams[i].sphere(); }},
lineStart: function() { var i = -1; while (++i < n) {streams[i].lineStart(); }},
lineEnd: function() { var i = -1; while (++i < n) {streams[i].lineEnd(); }},
polygonStart: function() { var i = -1; while (++i < n) {streams[i].polygonStart(); }},
polygonEnd: function() { var i = -1; while (++i < n) {streams[i].polygonEnd(); }}
};
}
// A composite projection for Portugal, configured by default for 960×500.
function conicConformalEurope() {
var cache,
cacheStream,
europe = d3Geo.geoConicConformal().rotate([-10, -53]).parallels([0, 60]), europePoint,
guadeloupe = d3Geo.geoMercator().center([-61.46, 16.14]), guadeloupePoint,
guyane = d3Geo.geoMercator().center([-53.2, 3.9]), guyanePoint,
azores = d3Geo.geoConicConformal().rotate([27.8, -38.9]).parallels([0, 60]), azoresPoint,
azores2 = d3Geo.geoConicConformal().rotate([25.43, -37.398]).parallels([0, 60]), azores2Point,
azores3 = d3Geo.geoConicConformal().rotate([31.17, -39.539]).parallels([0, 60]), azores3Point,
madeira = d3Geo.geoConicConformal().rotate([17, -32.7]).parallels([0, 60]), madeiraPoint,
canaryIslands = d3Geo.geoConicConformal().rotate([16, -28.5]).parallels([0,60]), canaryIslandsPoint,
martinique = d3Geo.geoMercator().center([-61.03, 14.67]), martiniquePoint,
mayotte = d3Geo.geoMercator().center([45.16, -12.8]), mayottePoint,
reunion = d3Geo.geoMercator().center([55.52, -21.13]), reunionPoint,
malta = d3Geo.geoConicConformal().rotate([-14.4, -35.95]).parallels([0, 60]), maltaPoint,
point, pointStream = {point: function(x, y) { point = [x, y]; }};
/*
var europeBbox = [[-6.5, 51], [10, 41]];
var guyaneBbox = [[-54.5, 6.29], [-50.9, 1.48]];
*/
function conicConformalEurope(coordinates) {
var x = coordinates[0], y = coordinates[1];
return point = null,
(europePoint.point(x, y), point) ||
(guyanePoint.point(x, y), point) ||
(martiniquePoint.point(x, y), point) ||
(guadeloupePoint.point(x, y), point) ||
(canaryIslandsPoint.point(x, y), point) ||
(madeiraPoint.point(x, y), point) ||
(mayottePoint.point(x, y), point) ||
(reunionPoint.point(x, y), point) ||
(maltaPoint.point(x, y), point) ||
(azoresPoint.point(x, y), point) ||
(azores2Point.point(x, y), point) ||
(azores3Point.point(x, y), point);
}
conicConformalEurope.invert = function(coordinates) {
var k = europe.scale(),
t = europe.translate(),
x = (coordinates[0] - (t[0] + 0.08 * k)) / k,
y = (coordinates[1] - t[1]) / k;
return (y >= -0.31 && y< -0.24 && x >= 0.14 && x < 0.24 ? guadeloupe
: y >= -0.24 && y< -0.17 && x >= 0.14 && x < 0.24 ? guyane
: y >= -0.17 && y< -0.12 && x >= 0.21 && x < 0.24 ? azores2
: y >= -0.17 && y< -0.14 && x >= 0.14 && x < 0.165 ? azores3
: y >= -0.17 && y< -0.1 && x >= 0.14 && x < 0.24 ? azores
: y >= -0.1 && y< -0.03 && x >= 0.14 && x < 0.24 ? madeira
: y >= -0.03 && y< 0.04 && x >= 0.14 && x < 0.24 ? canaryIslands
: y >= -0.31 && y< -0.24 && x >= 0.24 && x < 0.34 ? martinique
: y >= -0.24 && y< -0.17 && x >= 0.24 && x < 0.34 ? mayotte
: y >= -0.17 && y< -0.1 && x >= 0.24 && x < 0.34 ? reunion
: y >= -0.1 && y< -0.03 && x >= 0.24 && x < 0.34 ? malta
: europe).invert(coordinates);
};
conicConformalEurope.stream = function(stream) {
return cache && cacheStream === stream ? cache : cache = multiplex$8([europe.stream(cacheStream = stream), guyane.stream(stream), martinique.stream(stream), guadeloupe.stream(stream), canaryIslands.stream(stream), madeira.stream(stream), mayotte.stream(stream), reunion.stream(stream), malta.stream(stream), azores.stream(stream), azores2.stream(stream), azores3.stream(stream)]);
};
conicConformalEurope.precision = function(_) {
if (!arguments.length) {return europe.precision();}
europe.precision(_);
guyane.precision(_);
martinique.precision(_);
guadeloupe.precision(_);
canaryIslands.precision(_);
madeira.precision(_);
mayotte.precision(_);
reunion.precision(_);
malta.precision(_);
azores.precision(_);
azores2.precision(_);
azores3.precision(_);
return conicConformalEurope;
};
conicConformalEurope.scale = function(_) {
if (!arguments.length) {return europe.scale();}
europe.scale(_);
guadeloupe.scale(_ * 3);
guyane.scale(_ * 0.8);
martinique.scale(_ * 3.5);
reunion.scale(_ * 2.7);
azores.scale(_ * 2);
azores2.scale(_ * 2);
azores3.scale(_ * 2);
madeira.scale(_ * 3);
canaryIslands.scale(_);
mayotte.scale(_ * 5.5);
malta.scale(_ * 6);
return conicConformalEurope.translate(europe.translate());
};
conicConformalEurope.translate = function(_) {
if (!arguments.length) {return europe.translate();}
var k = europe.scale(), x = +_[0], y = +_[1];
europePoint = europe
.translate([x - 0.08 * k, y])
.clipExtent([[x - 0.51 * k, y - 0.33 * k],[x + 0.5 * k, y + 0.33 * k]])
.stream(pointStream);
guadeloupePoint = guadeloupe
.translate([x + 0.19 * k, y - 0.275 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.31 * k + epsilon],[x + 0.24 * k - epsilon, y - 0.24 * k - epsilon]])
.stream(pointStream);
guyanePoint = guyane
.translate([x + 0.19 * k, y - 0.205 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.24 * k + epsilon],[x + 0.24 * k - epsilon, y - 0.17 * k - epsilon]])
.stream(pointStream);
azoresPoint = azores
.translate([x + 0.19 * k, y - 0.135 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.17 * k + epsilon],[x + 0.24 * k - epsilon, y - 0.1 * k - epsilon]])
.stream(pointStream);
azores2Point = azores2
.translate([x + 0.225 * k, y - 0.147 * k])
.clipExtent([[x + 0.21 * k + epsilon, y - 0.17 * k + epsilon],[x + 0.24 * k - epsilon, y - 0.12 * k - epsilon]])
.stream(pointStream);
azores3Point = azores3
.translate([x + 0.153 * k, y - 0.15 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.17 * k + epsilon],[x + 0.165 * k - epsilon, y - 0.14 * k - epsilon]])
.stream(pointStream);
madeiraPoint = madeira
.translate([x + 0.19 * k, y - 0.065 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.1 * k + epsilon],[x + 0.24 * k - epsilon, y - 0.03 * k - epsilon]])
.stream(pointStream);
canaryIslandsPoint = canaryIslands
.translate([x + 0.19 * k, y + 0.005 * k])
.clipExtent([[x + 0.14 * k + epsilon, y - 0.03 * k + epsilon],[x + 0.24 * k - epsilon, y + 0.04 * k - epsilon]])
.stream(pointStream);
martiniquePoint = martinique
.translate([x + 0.29 * k, y - 0.275 * k])
.clipExtent([[x + 0.24 * k + epsilon, y - 0.31 * k + epsilon],[x + 0.34 * k - epsilon, y - 0.24 * k - epsilon]])
.stream(pointStream);
mayottePoint = mayotte
.translate([x + 0.29 * k, y - 0.205 * k])
.clipExtent([[x + 0.24 * k + epsilon, y - 0.24 * k + epsilon],[x + 0.34 * k - epsilon, y - 0.17 * k - epsilon]])
.stream(pointStream);
reunionPoint = reunion
.translate([x + 0.29 * k, y - 0.135 * k])
.clipExtent([[x + 0.24 * k + epsilon, y - 0.17 * k + epsilon],[x + 0.34 * k - epsilon, y - 0.1 * k - epsilon]])
.stream(pointStream);
maltaPoint = malta
.translate([x + 0.29 * k, y - 0.065 * k])
.clipExtent([[x + 0.24 * k + epsilon, y - 0.1 * k + epsilon],[x + 0.34 * k - epsilon, y - 0.03 * k - epsilon]])
.stream(pointStream);
return conicConformalEurope;
};
conicConformalEurope.drawCompositionBorders = function(context) {
/*
console.log("var ul, ur, ld, ll;");
var projs = [guyane, martinique, guadeloupe, canaryIslands, madeira, mayotte, reunion, malta, azores, azores2, azores3];
for (var i in projs){
var ul = europe.invert([projs[i].clipExtent()[0][0], projs[i].clipExtent()[0][1]]);
var ur = europe.invert([projs[i].clipExtent()[1][0], projs[i].clipExtent()[0][1]]);
var ld = europe.invert([projs[i].clipExtent()[1][0], projs[i].clipExtent()[1][1]]);
var ll = europe.invert([projs[i].clipExtent()[0][0], projs[i].clipExtent()[1][1]]);
console.log("ul = europe(["+ul+"]);");
console.log("ur = europe(["+ur+"]);");
console.log("ld = europe(["+ld+"]);");
console.log("ll = europe(["+ll+"]);");
console.log("context.moveTo(ul[0], ul[1]);");
console.log("context.lineTo(ur[0], ur[1]);");
console.log("context.lineTo(ld[0], ld[1]);");
console.log("context.lineTo(ll[0], ll[1]);");
console.log("context.closePath();");
}*/
var ul, ur, ld, ll;
ul = europe([42.45755610828648,63.343658547914934]);
ur = europe([52.65837266667029,59.35045080290929]);
ld = europe([47.19754502247785,56.12653496548117]);
ll = europe([37.673034273363044,59.61638268506111]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([59.41110754003403,62.35069727399336]);
ur = europe([66.75050228640794,57.11797303636038]);
ld = europe([60.236065725110436,54.63331433818992]);
ll = europe([52.65837313153311,59.350450804599355]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([48.81091130080243,66.93353402634641]);
ur = europe([59.41110730654679,62.35069740653086]);
ld = europe([52.6583728974441,59.3504509222445]);
ll = europe([42.45755631675751,63.34365868805821]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([31.054198418446475,52.1080673766184]);
ur = europe([39.09869284884117,49.400700047190554]);
ld = europe([36.0580811499175,46.02944174908498]);
ll = europe([28.690508588835726,48.433126979386415]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([33.977877745912025,55.849945501331]);
ur = europe([42.75328432167726,52.78455122462353]);
ld = europe([39.09869297540224,49.400700176148625]);
ll = europe([31.05419851807008,52.10806751810923]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([52.658372900759296,59.35045068526415]);
ur = europe([60.23606549583304,54.63331423800264]);
ld = europe([54.6756370953122,51.892298789399455]);
ll = europe([47.19754524788189,56.126534861222794]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([47.19754506082455,56.126534735591456]);
ur = europe([54.675636900123514,51.892298681337095]);
ld = europe([49.94448648951486,48.98775484983285]);
ll = europe([42.75328468716108,52.78455126060818]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([42.75328453416769,52.78455113209101]);
ur = europe([49.94448632339758,48.98775473706457]);
ld = europe([45.912339990394315,45.99361784987003]);
ll = europe([39.09869317356607,49.40070009378711]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([37.673034114296634,59.61638254183119]);
ur = europe([47.197544835420544,56.126534839849846]);
ld = europe([42.75328447467064,52.78455135314068]);
ll = europe([33.977877870363905,55.849945644671145]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([44.56748486446032,57.26489367845818]);
ld = europe([43.9335791193588,53.746540942601726]);
ll = europe([43,56]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
ul = europe([37.673034114296634,59.61638254183119]);
ur = europe([40.25902691953466,58.83002044222639]);
ld = europe([38.458270492742024,57.26232178028002]);
ll = europe([35.97754948030156,58.00266637992386]);
context.moveTo(ul[0], ul[1]);
context.lineTo(ur[0], ur[1]);
context.lineTo(ld[0], ld[1]);
context.lineTo(ll[0], ll[1]);
context.closePath();
};
conicConformalEurope.getCompositionBorders = function() {
var context = d3Path.path();
this.drawCompositionBorders(context);
return context.toString();
};
return conicConformalEurope.scale(750);
}
exports.geoAlbersUsa = albersUsa;
exports.geoAlbersUsaTerritories = albersUsaTerritories;
exports.geoConicConformalSpain = conicConformalSpain;
exports.geoConicConformalPortugal = conicConformalPortugal;
exports.geoMercatorEcuador = mercatorEcuador;
exports.geoTransverseMercatorChile = transverseMercatorChile;
exports.geoConicEquidistantJapan = conicEquidistantJapan;
exports.geoConicConformalFrance = conicConformalFrance;
exports.geoConicConformalEurope = conicConformalEurope;
Object.defineProperty(exports, '__esModule', { value: true });
}));
},{"d3-geo":6,"d3-path":12}],6:[function(require,module,exports){
// https://d3js.org/d3-geo/ Version 1.2.4. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-array'], factory) :
(factory((global.d3 = global.d3 || {}),global.d3));
}(this, (function (exports,d3Array) { 'use strict';
// Adds floating point numbers with twice the normal precision.
// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
// 305–363 (1997).
// Code adapted from GeographicLib by Charles F. F. Karney,
// http://geographiclib.sourceforge.net/
function adder() {
return new Adder;
}
function Adder() {
this.reset();
}
Adder.prototype = {
constructor: Adder,
reset: function() {
this.s = // rounded value
this.t = 0; // exact error
},
add: function(y) {
add(temp, y, this.t);
add(this, temp.s, this.s);
if (this.s) this.t += temp.t;
else this.s = temp.t;
},
valueOf: function() {
return this.s;
}
};
var temp = new Adder;
function add(adder, a, b) {
var x = adder.s = a + b,
bv = x - a,
av = x - bv;
adder.t = (a - av) + (b - bv);
}
var epsilon = 1e-6;
var epsilon2 = 1e-12;
var pi = Math.PI;
var halfPi = pi / 2;
var quarterPi = pi / 4;
var tau = pi * 2;
var degrees = 180 / pi;
var radians = pi / 180;
var abs = Math.abs;
var atan = Math.atan;
var atan2 = Math.atan2;
var cos = Math.cos;
var ceil = Math.ceil;
var exp = Math.exp;
var log = Math.log;
var pow = Math.pow;
var sin = Math.sin;
var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
var sqrt = Math.sqrt;
var tan = Math.tan;
function acos(x) {
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
}
function asin(x) {
return x > 1 ? halfPi : x < -1 ? -halfPi : Math.asin(x);
}
function haversin(x) {
return (x = sin(x / 2)) * x;
}
function noop() {}
function streamGeometry(geometry, stream) {
if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
streamGeometryType[geometry.type](geometry, stream);
}
}
var streamObjectType = {
Feature: function(feature, stream) {
streamGeometry(feature.geometry, stream);
},
FeatureCollection: function(object, stream) {
var features = object.features, i = -1, n = features.length;
while (++i < n) streamGeometry(features[i].geometry, stream);
}
};
var streamGeometryType = {
Sphere: function(object, stream) {
stream.sphere();
},
Point: function(object, stream) {
object = object.coordinates;
stream.point(object[0], object[1], object[2]);
},
MultiPoint: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
},
LineString: function(object, stream) {
streamLine(object.coordinates, stream, 0);
},
MultiLineString: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) streamLine(coordinates[i], stream, 0);
},
Polygon: function(object, stream) {
streamPolygon(object.coordinates, stream);
},
MultiPolygon: function(object, stream) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;