/*! Planetary.js 0.0.0 | (c) 2013 Brandon Tilley | Released under MIT License */ !function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=e.onInit.length?r(n,t,e):f(h)};f(h)}else r(n,t,e)},u={plugins:{},noConflict:function(){return o.planetaryjs=e,u},loadPlugin:function(n,t){i.push([n,t||{}])},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={draw:function(n){l(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n,o){t.push([n,o||{}])},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return u.plugins.topojson=function(t,o){t.onInit(function(e){if(o.world)t.world=o.world,setTimeout(e,0);else{var i=o.file||"world-110m.json";n.json(i,function(n,o){if(n)throw new Error("Could not load JSON "+i);t.world=o,e()})}})},u.plugins.oceans=function(n,t){n.onDraw(function(){n.withSavedContext(function(o){o.beginPath(),n.path.context(o)({type:"Sphere"}),o.fillStyle=t.fill||"black",o.fill(),0!=t.stroke&&(o.strokeStyle=t.stroke,o.stroke())})})},u.plugins.land=function(n,o){var e=null;n.onInit(function(){e=t.feature(n.world,n.world.objects.land)}),n.onDraw(function(){n.withSavedContext(function(t){t.beginPath(),n.path.context(t)(e),0!=o.fill&&(t.fillStyle=o.fill||"white",t.fill()),o.stroke&&(t.strokeStyle=o.stroke,t.stroke())})})},u.plugins.borders=function(n,o){var e=null;n.onInit(function(){var o=n.world.objects.countries;e=t.mesh(n.world,o,function(n,t){return n.id!==t.id})}),n.onDraw(function(){n.withSavedContext(function(t){t.beginPath(),n.path.context(t)(e),t.strokeStyle=o.stroke||"gray",t.stroke()})})},u.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){u.plugins.topojson(n,t),u.plugins.oceans(n,o),u.plugins.land(n,e),u.plugins.borders(n,i)}},u});