From 7a997a2f852c1b58ae5411d7260ce8a711c8abb1 Mon Sep 17 00:00:00 2001 From: Robin Hawkes Date: Mon, 3 Nov 2014 01:28:38 +0000 Subject: [PATCH] Updated readme --- README.md | 4 ++-- build/vizi.js | 2 +- build/vizi.min.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8a47bcc..63fc604 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Numerous lessons were learnt after releasing 0.1.0-pre to the public, so much so ### Blueprint API -Data input and visualisation output is now controlled by the [Blueprint API](http://dev.vizicities.com). It's based on the concept of triggers and actions; much like Zapier or IFTTT, just instead for geographic data visualisation. It underpins the entire system for 0.2.0 and it completely changes the way you pull data into ViziCities and how you output it. A lot of hard work went into formulating and constructing it — we're incredibly proud of it! +Data input and visualisation output is now controlled by the [Blueprint API](http://dev.vizicities.com/v0.2.0/docs/using-the-blueprint-api). It's based on the concept of triggers and actions; much like Zapier or IFTTT, just instead for geographic data visualisation. It underpins the entire system for 0.2.0 and it completely changes the way you pull data into ViziCities and how you output it. A lot of hard work went into formulating and constructing it — we're incredibly proud of it! In short, the Blueprint API has 3 parts; an input, an output and a mapping configuration. Neither the input nor the output know about each other or care about each others data structure. Everything is neatly brought together by a configuration object that describes which input to use, which output to use, as well as how and, more importantly, when to map the data between them. @@ -51,7 +51,7 @@ By default, ViziCites now supports: * Choropleth (heatmap-like) output * Dynamic building output from a vector tile source ([like Mapzen](https://github.com/mapzen/vector-datasource/wiki/Mapzen-Vector-Tile-Service)) -Make sure to read the [documentation on the Blueprint API](http://dev.vizicities.com) to learn how to use it. +Make sure to read the [documentation on the Blueprint API](http://dev.vizicities.com/v0.2.0/docs/using-the-blueprint-api) to learn how to use it. ### Easier setup and customisation diff --git a/build/vizi.js b/build/vizi.js index b50ca22..9d805b3 100644 --- a/build/vizi.js +++ b/build/vizi.js @@ -1,4 +1,4 @@ -/*! ViziCities - v0.2.0 - 2014-11-02 */ +/*! ViziCities - v0.2.0 - 2014-11-03 */ !function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===la||n[0]===sa?sa+n:n}function l(n){return(n+="")[0]===sa?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object.create(null)}function d(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function m(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=fa.length;r>e;++e){var u=fa[e]+t;if(u in n)return u}}function y(){}function x(){}function M(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function H(n){return ga(n,Ma),n}function O(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var l=ba.get(n);return l&&(n=l,c=V),a?t?u:r:t?y:i}function Z(n,t){return function(e){var r=Bo.event;Bo.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Bo.event=r}}}function V(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function X(){var n=".dragsuppress-"+ ++Sa,t="click"+n,e=Bo.select(Qo).on("touchmove"+n,_).on("dragstart"+n,_).on("selectstart"+n,_);if(wa){var r=Ko.style,u=r[wa];r[wa]="none"}return function(i){function o(){e.on(t,null)}e.on(n,null),wa&&(r[wa]=u),i&&(e.on(t,function(){_(),o()},!0),setTimeout(o,0))}}function $(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>ka&&(Qo.scrollX||Qo.scrollY)){e=Bo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();ka=!(u.f||u.e),e.remove()}return ka?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function B(){return Bo.event.changedTouches[0].identifier}function W(){return Bo.event.target}function J(){return Qo}function G(n){return n>0?1:0>n?-1:0}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?0:-1>n?Ea:Math.acos(n)}function nt(n){return n>1?Ca:-1>n?-Ca:Math.asin(n)}function tt(n){return((n=Math.exp(n))-1/n)/2}function et(n){return((n=Math.exp(n))+1/n)/2}function rt(n){return((n=Math.exp(2*n))-1)/(n+1)}function ut(n){return(n=Math.sin(n/2))*n}function it(){}function ot(n,t,e){return this instanceof ot?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ot?new ot(n.h,n.s,n.l):Mt(""+n,_t,ot):new ot(n,t,e)}function at(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dt(u(n+120),u(n),u(n-120))}function ct(n,t,e){return this instanceof ct?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof ct?new ct(n.h,n.c,n.l):n instanceof st?ht(n.l,n.a,n.b):ht((n=bt((n=Bo.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new ct(n,t,e)}function lt(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new st(e,Math.cos(n*=La)*t,Math.sin(n)*t)}function st(n,t,e){return this instanceof st?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof st?new st(n.l,n.a,n.b):n instanceof ct?lt(n.h,n.c,n.l):bt((n=dt(n)).r,n.g,n.b):new st(n,t,e)}function ft(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=gt(u)*Ya,r=gt(r)*Ia,i=gt(i)*Za,new dt(vt(3.2404542*u-1.5371385*r-.4985314*i),vt(-.969266*u+1.8760108*r+.041556*i),vt(.0556434*u-.2040259*r+1.0572252*i))}function ht(n,t,e){return n>0?new ct(Math.atan2(e,t)*Ta,Math.sqrt(t*t+e*e),n):new ct(0/0,0/0,n)}function gt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function pt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function vt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dt(n,t,e){return this instanceof dt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dt?new dt(n.r,n.g,n.b):Mt(""+n,dt,at):new dt(n,t,e)}function mt(n){return new dt(n>>16,255&n>>8,255&n)}function yt(n){return mt(n)+""}function xt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function Mt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(St(u[0]),St(u[1]),St(u[2]))}return(i=$a.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function _t(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new ot(r,u,c)}function bt(n,t,e){n=wt(n),t=wt(t),e=wt(e);var r=pt((.4124564*n+.3575761*t+.1804375*e)/Ya),u=pt((.2126729*n+.7151522*t+.072175*e)/Ia),i=pt((.0193339*n+.119192*t+.9503041*e)/Za);return st(116*u-16,500*(r-u),200*(u-i))}function wt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function St(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kt(n){return"function"==typeof n?n:function(){return n}}function Et(n){return n}function At(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Ct(t,e,n,r)}}function Ct(n,t,e,r){function u(){var n,t=c.status;if(!t&&zt(c)||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=Bo.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,l=null;return!Qo.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=Bo.event;Bo.event=n;try{o.progress.call(i,c)}finally{Bo.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(l=n,i):l},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Jo(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var s in a)c.setRequestHeader(s,a[s]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},Bo.rebind(i,o,"on"),null==r?i:i.get(Nt(r))}function Nt(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zt(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function Lt(){var n=Tt(),t=qt()-n;t>24?(isFinite(t)&&(clearTimeout(Ga),Ga=setTimeout(Lt,t)),Ja=0):(Ja=1,Qa(Lt))}function Tt(){var n=Date.now();for(Ka=Ba;Ka;)n>=Ka.t&&(Ka.f=Ka.c(n-Ka.t)),Ka=Ka.n;return n}function qt(){for(var n,t=Ba,e=1/0;t;)t.f?t=n?n.n=t.n:Ba=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Pt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],c=0;u>0&&a>0&&(c+a+1>t&&(a=Math.max(1,t-c)),i.push(n.substring(u-=a,u+a)),!((c+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:Et;return function(n){var e=tc.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",c=e[4]||"",l=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(l||"0"===r&&"="===o)&&(l=r="0",o="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=ec.get(g)||Ut;var x=l&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var c=Bo.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var M,_,b=n.lastIndexOf(".");if(0>b){var w=y?n.lastIndexOf("e"):-1;0>w?(M=n,_=""):(M=n.substring(0,w),_=n.substring(w))}else M=n.substring(0,b),_=t+n.substring(b+1);!l&&f&&(M=i(M,1/0));var S=v.length+M.length+_.length+(x?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return x&&(M=i(k+M,k.length?s-_.length:1/0)),u+=v,n=M+_,("<"===o?u+n+k:">"===o?k+u+n:"^"===o?k.substring(0,S>>=1)+u+n+k.substring(S):u+(x?n:k+n))+e}}}function Ut(n){return n+""}function jt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ft(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new uc(e-1)),1),e}function i(n,e){return t(n=new uc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{uc=jt;var r=new jt;return r._=n,o(r,t,e)}finally{uc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Ht(n);return c.floor=c,c.round=Ht(r),c.ceil=Ht(u),c.offset=Ht(i),c.range=a,n}function Ht(n){return function(t,e){try{uc=jt;var r=new jt;return r._=t,n(r,e)._}finally{uc=Date}}}function Ot(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=l)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=N[o in oc?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){b.lastIndex=0;var r=b.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){M.lastIndex=0;var r=M.exec(t.slice(e));return r?(n.w=_.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.slice(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,C.c.toString(),t,r)}function c(n,t,r){return e(n,C.x.toString(),t,r)}function l(n,t,r){return e(n,C.X.toString(),t,r)}function s(n,t,e){var r=x.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{uc=jt;var t=new uc;return t._=n,r(t)}finally{uc=Date}}var r=t(n);return e.parse=function(n){try{uc=jt;var t=r.parse(n);return t&&t._}finally{uc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ae;var x=Bo.map(),M=It(v),_=Zt(v),b=It(d),w=Zt(d),S=It(m),k=Zt(m),E=It(y),A=Zt(y);p.forEach(function(n,t){x.set(n.toLowerCase(),t)});var C={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return Yt(n.getDate(),t,2)},e:function(n,t){return Yt(n.getDate(),t,2)},H:function(n,t){return Yt(n.getHours(),t,2)},I:function(n,t){return Yt(n.getHours()%12||12,t,2)},j:function(n,t){return Yt(1+rc.dayOfYear(n),t,3)},L:function(n,t){return Yt(n.getMilliseconds(),t,3)},m:function(n,t){return Yt(n.getMonth()+1,t,2)},M:function(n,t){return Yt(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return Yt(n.getSeconds(),t,2)},U:function(n,t){return Yt(rc.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Yt(rc.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return Yt(n.getFullYear()%100,t,2)},Y:function(n,t){return Yt(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},N={a:r,A:u,b:i,B:o,c:a,d:Qt,e:Qt,H:te,I:te,j:ne,L:ue,m:Kt,M:ee,p:s,S:re,U:Xt,w:Vt,W:$t,x:c,X:l,y:Wt,Y:Bt,Z:Jt,"%":oe};return t}function Yt(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function It(n){return new RegExp("^(?:"+n.map(Bo.requote).join("|")+")","i")}function Zt(n){for(var t=new a,e=-1,r=n.length;++e68?1900:2e3)}function Kt(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Qt(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function ne(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function te(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ee(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function re(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ue(n,t,e){ac.lastIndex=0;var r=ac.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=0|ca(t)/60,u=ca(t)%60;return e+Yt(r,"0",2)+Yt(u,"0",2)}function oe(n,t,e){cc.lastIndex=0;var r=cc.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ae(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),l=Math.sin(t),s=i*l,f=u*c+s*Math.cos(a),h=s*o*Math.sin(a);pc.add(Math.atan2(h,f)),r=n,u=c,i=l}var t,e,r,u,i;vc.point=function(o,a){vc.point=n,r=(t=o)*La,u=Math.cos(a=(e=a)*La/2+Ea/4),i=Math.sin(a)},vc.lineEnd=function(){n(t,e)}}function pe(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ve(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function de(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function me(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function ye(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function xe(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function Me(n){return[Math.atan2(n[1],n[0]),nt(n[2])]}function _e(n,t){return ca(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new ze(e,n,null,!0),l=new ze(e,null,c,!1);c.o=l,i.push(c),o.push(l),c=new ze(r,n,null,!1),l=new ze(r,null,c,!0),c.o=l,i.push(c),o.push(l)}}),o.sort(t),Ne(i),Ne(o),i.length){for(var a=0,c=e,l=o.length;l>a;++a)o[a].e=c=!c;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,l=s.length;l>a;++a)u.point((f=s[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var a=s.length-1;a>=0;--a)u.point((f=s[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function Ne(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(_||(i.polygonStart(),_=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Te))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:l,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=l,g=Bo.merge(g);var n=je(m,p);g.length?(_||(i.polygonStart(),_=!0),Ce(g,Re,n,e,i)):n&&(_||(i.polygonStart(),_=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),_&&(i.polygonEnd(),_=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},x=qe(),M=t(x),_=!1;return y}}function Te(n){return n.length>1}function qe(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:y,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Re(n,t){return((n=n.x)[0]<0?n[1]-Ca-Na:Ca-n[1])-((t=t.x)[0]<0?t[1]-Ca-Na:Ca-t[1])}function De(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?Ea:-Ea,c=ca(i-e);ca(c-Ea)0?Ca:-Ca),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=Ea&&(ca(e-u)Na?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function Ue(n,t,e,r){var u;if(null==n)u=e*Ca,r.point(-Ea,u),r.point(0,u),r.point(Ea,u),r.point(Ea,0),r.point(Ea,-u),r.point(0,-u),r.point(-Ea,-u),r.point(-Ea,0),r.point(-Ea,u);else if(ca(n[0]-t[0])>Na){var i=n[0]a;++a){var l=t[a],s=l.length;if(s)for(var f=l[0],h=f[0],g=f[1]/2+Ea/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=l[d];var m=n[0],y=n[1]/2+Ea/4,x=Math.sin(y),M=Math.cos(y),_=m-h,b=_>=0?1:-1,w=b*_,S=w>Ea,k=p*x;if(pc.add(Math.atan2(k*b*Math.sin(w),v*M+k*Math.cos(w))),i+=S?_+b*Aa:_,S^h>=e^m>=e){var E=de(pe(f),pe(n));xe(E);var A=de(u,E);xe(A);var C=(S^_>=0?-1:1)*nt(A[2]);(r>C||r===C&&(E[0]||E[1]))&&(o+=S^_>=0?1:-1)}if(!d++)break;h=m,p=x,v=M,f=n}}return(-Na>i||Na>i&&0>pc)^1&o}function Fe(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,c,l,s;return{lineStart:function(){l=c=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?Ea:-Ea),h):0;if(!e&&(l=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(_e(e,g)||_e(p,g))&&(p[0]+=Na,p[1]+=Na,v=t(p[0],p[1]))),v!==c)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(s=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&_e(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return s|(l&&c)<<1}}}function r(n,t,e){var r=pe(n),u=pe(t),o=[1,0,0],a=de(r,u),c=ve(a,a),l=a[0],s=c-l*l;if(!s)return!e&&n;var f=i*c/s,h=-i*l/s,g=de(o,a),p=ye(o,f),v=ye(a,h);me(p,v);var d=g,m=ve(p,d),y=ve(d,d),x=m*m-y*(ve(p,p)-1);if(!(0>x)){var M=Math.sqrt(x),_=ye(d,(-m-M)/y);if(me(_,p),_=Me(_),!e)return _;var b,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(b=w,w=S,S=b);var A=S-w,C=ca(A-Ea)A;if(!C&&k>E&&(b=k,k=E,E=b),N?C?k+E>0^_[1]<(ca(_[0]-w)Ea^(w<=_[0]&&_[0]<=S)){var z=ye(d,(-m+M)/y);return me(z,p),[_,Me(z)]}}}function u(t,e){var r=o?n:Ea-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=ca(i)>Na,c=gr(n,6*La);return Le(t,e,c,o?[0,-n]:[-Ea,n-Ea])}function He(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,l=o.y,s=a.x,f=a.y,h=0,g=1,p=s-c,v=f-l;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-l,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-l,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:l+h*v}),1>g&&(u.b={x:c+g*p,y:l+g*v}),u}}}}}}function Oe(n,t,e,r){function u(r,u){return ca(r[0]-n)0?0:3:ca(r[0]-e)0?2:1:ca(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&K(l,i,n)>0&&++t:i[1]<=r&&K(l,i,n)<0&&--t,l=i;return 0!==t}function l(i,a,c,l){var s=0,f=0;if(null==i||(s=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do l.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+c+4)%4)!==f)}else l.point(a[0],a[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&a.point(n,t)}function h(){N.point=p,d&&d.push(m=[]),S=!0,w=!1,_=b=0/0}function g(){v&&(p(y,x),M&&w&&A.rejoin(),v.push(A.buffer())),N.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-Nc,Math.min(Nc,n)),t=Math.max(-Nc,Math.min(Nc,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,x=t,M=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:_,y:b},b:{x:n,y:t}};C(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}_=n,b=t,w=e}var v,d,m,y,x,M,_,b,w,S,k,E=a,A=qe(),C=He(n,t,e,r),N={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=Bo.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Ce(v,i,t,l,a),a.polygonEnd()),v=d=m=null}};return N}}function Ye(n,t){function e(e,r){return e=n(e,r),t(e[0],e[1])}return n.invert&&t.invert&&(e.invert=function(e,r){return e=t.invert(e,r),e&&n.invert(e[0],e[1])}),e}function Ie(n){var t=0,e=Ea/3,r=ir(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*Ea/180,e=n[1]*Ea/180):[180*(t/Ea),180*(e/Ea)]},u}function Ze(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,nt((i-(n*n+e*e)*u*u)/(2*u))]},e}function Ve(){function n(n,t){Lc+=u*n-r*t,r=n,u=t}var t,e,r,u;Pc.point=function(i,o){Pc.point=n,t=r=i,e=u=o},Pc.lineEnd=function(){n(t,e)}}function Xe(n,t){Tc>n&&(Tc=n),n>Rc&&(Rc=n),qc>t&&(qc=t),t>Dc&&(Dc=t)}function $e(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Be(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Be(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Be(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function We(n,t){yc+=n,xc+=t,++Mc}function Je(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);_c+=o*(t+n)/2,bc+=o*(e+r)/2,wc+=o,We(t=n,e=r)}var t,e;jc.point=function(r,u){jc.point=n,We(t=r,e=u)}}function Ge(){jc.point=We}function Ke(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);_c+=o*(r+n)/2,bc+=o*(u+t)/2,wc+=o,o=u*n-r*t,Sc+=o*(r+n),kc+=o*(u+t),Ec+=3*o,We(r=n,u=t)}var t,e,r,u;jc.point=function(i,o){jc.point=n,We(t=r=i,e=u=o)},jc.lineEnd=function(){n(t,e)}}function Qe(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,o,0,Aa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:y};return a}function nr(n){function t(n){return(a?r:e)(n)}function e(t){return rr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){x=0/0,S.point=i,t.lineStart()}function i(e,r){var i=pe([e,r]),o=n(e,r);u(x,M,y,_,b,w,x=o[0],M=o[1],y=e,_=i[0],b=i[1],w=i[2],a,t),t.point(x,M)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=l,S.lineEnd=s}function l(n,t){i(f=n,h=t),g=x,p=M,v=_,d=b,m=w,S.point=i}function s(){u(x,M,y,_,b,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,x,M,_,b,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,l,s,f,h,g,p,v,d,m){var y=s-t,x=f-e,M=y*y+x*x;if(M>4*i&&d--){var _=a+g,b=c+p,w=l+v,S=Math.sqrt(_*_+b*b+w*w),k=Math.asin(w/=S),E=ca(ca(w)-1)i||ca((y*z+x*L)/M-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,C,N,E,_/=S,b/=S,w,d,m),m.point(C,N),u(C,N,E,_,b,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*La),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Ta,e*Ta])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*La,n[1]*La),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ta,n[1]*Ta]}function r(){a=Ye(o=lr(m,y,x),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,x=0,M=Cc,_=Et,b=null,w=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(M(o,f(_(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(M=null==n?(b=n,Cc):Fe((b=+n)*La),u()):b},t.clipExtent=function(n){return arguments.length?(w=n,_=n?Oe(n[0][0],n[0][1],n[1][0],n[1][1]):Et,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*La,d=n[1]%360*La,r()):[v*Ta,d*Ta]},t.rotate=function(n){return arguments.length?(m=n[0]%360*La,y=n[1]%360*La,x=n.length>2?n[2]%360*La:0,r()):[m*Ta,y*Ta,x*Ta]},Bo.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*La,e*La)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>Ea?n-Aa:-Ea>n?n+Aa:n,t]}function lr(n,t,e){return n?t||e?Ye(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>Ea?t-Aa:-Ea>t?t+Aa:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),nt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),nt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*Aa)):(u=n+o*Aa,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=Me([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,xe(e);var r=Q(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Na)%(2*Math.PI)}function vr(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function xr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(ut(r-t)+u*o*ut(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ta,Math.atan2(o,Math.sqrt(r*r+u*u))*Ta]}:function(){return[n*Ta,t*Ta]};return p.distance=h,p}function Mr(){function n(n,u){var i=Math.sin(u*=La),o=Math.cos(u),a=ca((n*=La)-t),c=Math.cos(a);Fc+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Hc.point=function(u,i){t=u*La,e=Math.sin(i*=La),r=Math.cos(i),Hc.point=n},Hc.lineEnd=function(){Hc.point=Hc.lineEnd=y}}function _r(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function br(n,t){function e(n,t){o>0?-Ca+Na>t&&(t=-Ca+Na):t>Ca-Na&&(t=Ca-Na);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(Ea/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=G(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ca]},e):Sr}function wr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return ca(u)u;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function zr(n,t){return n[0]-t[0]||n[1]-t[1]}function Lr(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Tr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],l=e[1],s=t[1]-c,f=r[1]-l,h=(a*(c-l)-f*(u-i))/(f*o-a*s);return[u+h*o,c+h*s]}function qr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Rr(){tu(this),this.edge=this.site=this.circle=null}function Dr(n){var t=Kc.pop()||new Rr;return t.site=n,t}function Pr(n){Xr(n),Wc.remove(n),Kc.push(n),tu(n)}function Ur(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Pr(n);for(var c=i;c.circle&&ca(e-c.circle.x)s;++s)l=a[s],c=a[s-1],Kr(l.edge,c.site,l.site,u);c=a[0],l=a[f-1],l.edge=Jr(c.site,l.site,null,u),Vr(c),Vr(l)}function jr(n){for(var t,e,r,u,i=n.x,o=n.y,a=Wc._;a;)if(r=Fr(a,o)-i,r>Na)a=a.L;else{if(u=i-Hr(a,o),!(u>Na)){r>-Na?(t=a.P,e=a):u>-Na?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Dr(n);if(Wc.insert(t,c),t||e){if(t===e)return Xr(t),e=Dr(t.site),Wc.insert(c,e),c.edge=e.edge=Jr(t.site,c.site),Vr(t),Vr(e),void 0;if(!e)return c.edge=Jr(t.site,c.site),void 0;Xr(t),Xr(e);var l=t.site,s=l.x,f=l.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,x=v*v+d*d,M={x:(d*y-g*x)/m+s,y:(h*x-v*y)/m+f};Kr(e.edge,l,p,M),c.edge=Jr(l,n,null,M),e.edge=Jr(n,p,null,M),Vr(t),Vr(e)}}function Fr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,l=c-t;if(!l)return a;var s=a-r,f=1/i-1/l,h=s/l;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*l)-c+l/2+u-i/2)))/f+r:(r+a)/2}function Hr(n,t){var e=n.N;if(e)return Fr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Or(n){this.site=n,this.edges=[]}function Yr(n){for(var t,e,r,u,i,o,a,c,l,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=Bc,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)s=a[o].end(),r=s.x,u=s.y,l=a[++o%c].start(),t=l.x,e=l.y,(ca(r-t)>Na||ca(u-e)>Na)&&(a.splice(o,0,new Qr(Gr(i.site,s,ca(r-f)Na?{x:f,y:ca(t-f)Na?{x:ca(e-p)Na?{x:h,y:ca(t-h)Na?{x:ca(e-g)=-za)){var g=c*c+l*l,p=s*s+f*f,v=(f*g-l*p)/h,d=(c*p-s*g)/h,f=d+a,m=Qc.pop()||new Zr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,x=Gc._;x;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=l)return}else i={x:d,y:c};e={x:d,y:l}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=l)return}else i={x:(c-u)/r,y:c};e={x:(l-u)/r,y:l}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:pu(e,r)})),i=el.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function du(n,t){for(var e,r=Bo.interpolators.length;--r>=0&&!(e=Bo.interpolators[r](n,t)););return e}function mu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(du(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function yu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function xu(n){return function(t){return 1-n(1-t)}}function Mu(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function _u(n){return n*n}function bu(n){return n*n*n}function wu(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Su(n){return function(t){return Math.pow(t,n)}}function ku(n){return 1-Math.cos(n*Ca)}function Eu(n){return Math.pow(2,10*(n-1))}function Au(n){return 1-Math.sqrt(1-n*n)}function Cu(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Aa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Aa/t)}}function Nu(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function zu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Lu(n,t){n=Bo.hcl(n),t=Bo.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return lt(e+i*n,r+o*n,u+a*n)+""}}function Tu(n,t){n=Bo.hsl(n),t=Bo.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return at(e+i*n,r+o*n,u+a*n)+""}}function qu(n,t){n=Bo.lab(n),t=Bo.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ft(e+i*n,r+o*n,u+a*n)+""}}function Ru(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Du(n){var t=[n.a,n.b],e=[n.c,n.d],r=Uu(t),u=Pu(t,e),i=Uu(ju(e,t,-u))||0;t[0]*e[1]180?s+=360:s-l>180&&(l+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:pu(l,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:pu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:pu(g[0],p[0])},{i:e-2,x:pu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Ku(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function li(n){return n.reduce(si,0)}function si(n,t){return n+t[1]}function fi(n,t){return hi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function hi(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function gi(n){return[Bo.min(n),Bo.max(n)]}function pi(n,t){return n.value-t.value}function vi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function di(n,t){n._pack_next=t,t._pack_prev=n}function mi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function yi(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,u,i,o,a,c,l,s=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(xi),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(u=e[1],u.x=u.r,u.y=0,t(u),l>2))for(i=e[2],bi(r,u,i),t(i),vi(r,i),r._pack_prev=i,vi(i,u),u=r._pack_next,o=3;l>o;o++){bi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(mi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!mi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(Mi)}}function xi(n){n._pack_next=n._pack_prev=n}function Mi(n){delete n._pack_next,delete n._pack_prev}function _i(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Ci(n,t,e){return n.a.parent===t.parent?n.a:e}function Ni(n){return 1+Bo.max(n,function(n){return n.y})}function zi(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Li(n){var t=n.children;return t&&t.length?Li(t[0]):n}function Ti(n){var t,e=n.children;return e&&(t=e.length)?Ti(e[t-1]):n}function qi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ri(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Di(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Pi(n){return n.rangeExtent?n.rangeExtent():Di(n.range())}function Ui(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function ji(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Fi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:gl}function Hi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Hi:Ui,c=r?Ou:Hu;return o=u(n,t,c,e),a=u(t,n,c,du),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Ru)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Vi(n,t)},i.tickFormat=function(t,e){return Xi(n,t,e)},i.nice=function(t){return Ii(n,t),u()},i.copy=function(){return Oi(n,t,e,r)},u()}function Yi(n,t){return Bo.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Ii(n,t){return ji(n,Fi(Zi(n,t)[2]))}function Zi(n,t){null==t&&(t=10);var e=Di(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Vi(n,t){return Bo.range.apply(Bo,Zi(n,t))}function Xi(n,t,e){var r=Zi(n,t);if(e){var u=tc.exec(e);if(u.shift(),"s"===u[8]){var i=Bo.formatPrefix(Math.max(ca(r[0]),ca(r[1])));return u[7]||(u[7]="."+$i(i.scale(r[2]))),u[8]="f",e=Bo.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Bi(u[8],r)),e=u.join("")}else e=",."+$i(r[2])+"f";return Bo.format(e)}function $i(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Bi(n,t){var e=$i(t[2]);return n in pl?Math.abs(e-$i(Math.max(ca(t[0]),ca(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Wi(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=ji(r.map(u),e?Math:dl);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Di(r),o=[],a=n[0],c=n[1],l=Math.floor(u(a)),s=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(s-l)){if(e){for(;s>l;l++)for(var h=1;f>h;h++)o.push(i(l)*h);o.push(i(l))}else for(o.push(i(l));l++0;h--)o.push(i(l)*h);for(l=0;o[l]c;s--);o=o.slice(l,s)}return o},o.tickFormat=function(n,t){if(!arguments.length)return vl;arguments.length<2?t=vl:"function"!=typeof t&&(t=Bo.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Wi(n.copy(),t,e,r)},Yi(o,n)}function Ji(n,t,e){function r(t){return n(u(t))}var u=Gi(t),i=Gi(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Vi(e,n)},r.tickFormat=function(n,t){return Xi(e,n,t)},r.nice=function(n){return r.domain(Ii(e,n))},r.exponent=function(o){return arguments.length?(u=Gi(t=o),i=Gi(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Ji(n.copy(),t,e)},Yi(r,n)}function Gi(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Ki(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return Bo.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new a;for(var i,o=-1,c=r.length;++on?[0/0,0/0]:[n>0?a[n-1]:r[0],nt?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return no(n,t,e)},u()}function to(n,t){function e(e){return e>=e?t[Bo.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return to(n,t)},e}function eo(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Vi(n,t)},t.tickFormat=function(t,e){return Xi(n,t,e)},t.copy=function(){return eo(n)},t}function ro(n){return n.innerRadius}function uo(n){return n.outerRadius}function io(n){return n.startAngle}function oo(n){return n.endAngle}function ao(n){function t(t){function o(){l.push("M",i(n(s),a))}for(var c,l=[],s=[],f=-1,h=t.length,g=kt(e),p=kt(r);++f1&&u.push("H",r[0]),u.join("")}function fo(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var l=2;l9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function Co(n){return n.length<3?co(n):n[0]+mo(n,Ao(n))}function No(n){for(var t,e,r,u=-1,i=n.length;++ue?l():(u.active=e,i.event&&i.event.start.call(n,s,t),i.tween.forEach(function(e,r){(r=r.call(n,s,t))&&v.push(r) }),Bo.timer(function(){return p.c=c(r||1)?Ae:c,1},0,o),void 0)}function c(r){if(u.active!==e)return l();for(var o=r/g,a=f(o),c=v.length;c>0;)v[--c].call(n,a);return o>=1?(i.event&&i.event.end.call(n,s,t),l()):void 0}function l(){return--u.count?delete u[e]:delete n.__transition__,1}var s=n.__data__,f=i.ease,h=i.delay,g=i.duration,p=Ka,v=[];return p.t=h+o,r>=h?a(r-h):(p.c=a,void 0)},0,o)}}function Oo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Yo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Io(n){return n.toISOString()}function Zo(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Bo.bisect(Ol,u);return i==Ol.length?[t.year,Zi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Ol[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Vo(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Vo(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Di(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Vo(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Zo(n.copy(),t,e)},Yi(r,n)}function Vo(n){return new Date(n)}function Xo(n){return JSON.parse(n.responseText)}function $o(n){var t=Go.createRange();return t.selectNode(Go.body),t.createContextualFragment(n.responseText)}var Bo={version:"3.4.13"};Date.now||(Date.now=function(){return+new Date});var Wo=[].slice,Jo=function(n){return Wo.call(n)},Go=document,Ko=Go.documentElement,Qo=window;try{Jo(Ko.childNodes)[0].nodeType}catch(na){Jo=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{Go.createElement("div").style.setProperty("opacity",0,"")}catch(ta){var ea=Qo.Element.prototype,ra=ea.setAttribute,ua=ea.setAttributeNS,ia=Qo.CSSStyleDeclaration.prototype,oa=ia.setProperty;ea.setAttribute=function(n,t){ra.call(this,n,t+"")},ea.setAttributeNS=function(n,t,e){ua.call(this,n,t,e+"")},ia.setProperty=function(n,t,e){oa.call(this,n,t+"",e)}}Bo.ascending=n,Bo.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},Bo.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ur&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ur&&(e=r)}return e},Bo.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ue&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ue&&(e=r)}return e},Bo.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=e);)e=u=void 0;for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=e);)e=void 0;for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Bo.sum=function(n,t){var r,u=0,i=n.length,o=-1;if(1===arguments.length)for(;++or?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Bo.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=Bo.min(arguments,u),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ca=Math.abs;Bo.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/e)throw new Error("infinite range");var r,u=[],o=i(ca(e)),a=-1;if(n*=o,t*=o,e*=o,0>e)for(;(r=n+e*++a)>t;)u.push(r/o);else for(;(r=n+e*++a)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,s,f,h,g=-1,p=o.length,v=i[c++],d=new a;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(Bo.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},Bo.set=function(n){var t=new v;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},o(v,{has:s,add:function(n){return this._[c(n+="")]=!0,n},remove:f,values:h,size:g,empty:p,forEach:function(n){for(var t in this._)n.call(this,l(t))}}),Bo.behavior={},Bo.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Bo.event=null,Bo.requote=function(n){return n.replace(ha,"\\$&")};var ha=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ga={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},pa=function(n,t){return t.querySelector(n)},va=function(n,t){return t.querySelectorAll(n)},da=Ko.matches||Ko[m(Ko,"matchesSelector")],ma=function(n,t){return da.call(n,t)};"function"==typeof Sizzle&&(pa=function(n,t){return Sizzle(n,t)[0]||null},va=Sizzle,ma=Sizzle.matchesSelector),Bo.selection=function(){return _a};var ya=Bo.selection.prototype=[];ya.select=function(n){var t,e,r,u,i=[];n=k(n);for(var o=-1,a=this.length;++o=0&&(e=n.slice(0,t),n=n.slice(t+1)),xa.hasOwnProperty(e)?{space:xa[e],local:n}:n}},ya.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Bo.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(A(t,n[t]));return this}return this.each(A(n,t))},ya.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(q(e,n[e],t));return this}if(2>r)return Qo.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(q(n,t,e))},ya.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(R(t,n[t]));return this}return this.each(R(n,t))},ya.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},ya.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},ya.append=function(n){return n=D(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},ya.insert=function(n,t){return n=D(n),t=k(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},ya.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},ya.data=function(n,t){function e(n,e){var r,u,i,o=n.length,f=e.length,h=Math.min(o,f),g=new Array(f),p=new Array(f),v=new Array(o);if(t){var d,m=new a,y=new Array(o);for(r=-1;++rr;++r)p[r]=P(e[r]);for(;o>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),l.push(g),s.push(v)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return S(u)},ya.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},ya.sort=function(n){n=j.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},ya.size=function(){var n=0;return F(this,function(){++n}),n};var Ma=[];Bo.selection.enter=H,Bo.selection.enter.prototype=Ma,Ma.append=ya.append,Ma.empty=ya.empty,Ma.node=ya.node,Ma.call=ya.call,Ma.size=ya.size,Ma.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(I(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(I(n,t,e))};var ba=Bo.map({mouseenter:"mouseover",mouseleave:"mouseout"});ba.forEach(function(n){"on"+n in Go&&ba.remove(n)});var wa="onselectstart"in Go?null:m(Ko.style,"userSelect"),Sa=0;Bo.mouse=function(n){return $(n,b())};var ka=/WebKit/.test(Qo.navigator.userAgent)?-1:0;Bo.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=b().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return $(n,r)},Bo.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",i)}function t(n,t,u,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-x[0],e=r[1]-x[1],p|=n|e,x=r,g({type:"drag",x:r[0]+l[0],y:r[1]+l[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&Bo.event.target===f),g({type:"dragend"}))}var l,s=this,f=Bo.event.target,h=s.parentNode,g=e.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=Bo.select(u()).on(i+d,a).on(o+d,c),y=X(),x=t(h,v);r?(l=r.apply(s,arguments),l=[l.x-x[0],l.y-x[1]]):l=[0,0],g({type:"dragstart"})}}var e=w(n,"drag","dragstart","dragend"),r=null,u=t(y,Bo.mouse,J,"mousemove","mouseup"),i=t(B,Bo.touch,W,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},Bo.rebind(n,e,"on")},Bo.touches=function(n,t){return arguments.length<2&&(t=b().touches),t?Jo(t).map(function(t){var e=$(n,t);return e.identifier=t.identifier,e}):[]};var Ea=Math.PI,Aa=2*Ea,Ca=Ea/2,Na=1e-6,za=Na*Na,La=Ea/180,Ta=180/Ea,qa=Math.SQRT2,Ra=2,Da=4;Bo.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=et(v),o=i/(Ra*h)*(e*rt(qa*t+v)-tt(v));return[r+o*l,u+o*s,i*e/et(qa*t+v)]}return[r+n*l,u+n*s,i*Math.exp(qa*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],l=o-r,s=a-u,f=l*l+s*s,h=Math.sqrt(f),g=(c*c-i*i+Da*f)/(2*i*Ra*h),p=(c*c-i*i-Da*f)/(2*c*Ra*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/qa;return e.duration=1e3*y,e},Bo.behavior.zoom=function(){function n(n){n.on(A,l).on(ja+".zoom",f).on("dblclick.zoom",h).on(z,s)}function t(n){return[(n[0]-S.x)/S.k,(n[1]-S.y)/S.k]}function e(n){return[n[0]*S.k+S.x,n[1]*S.k+S.y]}function r(n){S.k=Math.max(E[0],Math.min(E[1],n))}function u(n,t){t=e(t),S.x+=n[0]-t[0],S.y+=n[1]-t[1]}function i(){x&&x.domain(y.range().map(function(n){return(n-S.x)/S.k}).map(y.invert)),b&&b.domain(M.range().map(function(n){return(n-S.y)/S.k}).map(M.invert))}function o(n){n({type:"zoomstart"})}function a(n){i(),n({type:"zoom",scale:S.k,translate:[S.x,S.y]})}function c(n){n({type:"zoomend"})}function l(){function n(){s=1,u(Bo.mouse(r),h),a(l)}function e(){f.on(C,null).on(N,null),g(s&&Bo.event.target===i),c(l)}var r=this,i=Bo.event.target,l=L.of(r,arguments),s=0,f=Bo.select(Qo).on(C,n).on(N,e),h=t(Bo.mouse(r)),g=X();Y.call(r),o(l)}function s(){function n(){var n=Bo.touches(g);return h=S.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=t(n))}),n}function e(){var t=Bo.event.target;Bo.select(t).on(x,i).on(M,f),b.push(t);for(var e=Bo.event.changedTouches,o=0,c=e.length;c>o;++o)v[e[o].identifier]=null;var l=n(),s=Date.now();if(1===l.length){if(500>s-m){var h=l[0],g=v[h.identifier];r(2*S.k),u(h,g),_(),a(p)}m=s}else if(l.length>1){var h=l[0],y=l[1],w=h[0]-y[0],k=h[1]-y[1];d=w*w+k*k}}function i(){for(var n,t,e,i,o=Bo.touches(g),c=0,l=o.length;l>c;++c,i=null)if(e=o[c],i=v[e.identifier]){if(t)break;n=e,t=i}if(i){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=d&&Math.sqrt(s/d);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*h)}m=null,u(n,t),a(p)}function f(){if(Bo.event.touches.length){for(var t=Bo.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var u in v)return void n()}Bo.selectAll(b).on(y,null),w.on(A,l).on(z,s),k(),c(p)}var h,g=this,p=L.of(g,arguments),v={},d=0,y=".zoom-"+Bo.event.changedTouches[0].identifier,x="touchmove"+y,M="touchend"+y,b=[],w=Bo.select(g),k=X();Y.call(g),e(),o(p),w.on(A,null).on(z,e)}function f(){var n=L.of(this,arguments);d?clearTimeout(d):(g=t(p=v||Bo.mouse(this)),Y.call(this),o(n)),d=setTimeout(function(){d=null,c(n)},50),_(),r(Math.pow(2,.002*Pa())*S.k),u(p,g),a(n)}function h(){var n=L.of(this,arguments),e=Bo.mouse(this),i=t(e),l=Math.log(S.k)/Math.LN2;o(n),r(Math.pow(2,Bo.event.shiftKey?Math.ceil(l)-1:Math.floor(l)+1)),u(e,i),a(n),c(n)}var g,p,v,d,m,y,x,M,b,S={x:0,y:0,k:1},k=[960,500],E=Ua,A="mousedown.zoom",C="mousemove.zoom",N="mouseup.zoom",z="touchstart.zoom",L=w(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=L.of(this,arguments),t=S;Cl?Bo.select(this).transition().each("start.zoom",function(){S=this.__chart__||{x:0,y:0,k:1},o(n)}).tween("zoom:zoom",function(){var e=k[0],r=k[1],u=e/2,i=r/2,o=Bo.interpolateZoom([(u-S.x)/S.k,(i-S.y)/S.k,e/S.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),c=e/r[2];this.__chart__=S={x:u-r[0]*c,y:i-r[1]*c,k:c},a(n)}}).each("end.zoom",function(){c(n)}):(this.__chart__=S,o(n),a(n),c(n))})},n.translate=function(t){return arguments.length?(S={x:+t[0],y:+t[1],k:S.k},i(),n):[S.x,S.y]},n.scale=function(t){return arguments.length?(S={x:S.x,y:S.y,k:+t},i(),n):S.k},n.scaleExtent=function(t){return arguments.length?(E=null==t?Ua:[+t[0],+t[1]],n):E},n.center=function(t){return arguments.length?(v=t&&[+t[0],+t[1]],n):v},n.size=function(t){return arguments.length?(k=t&&[+t[0],+t[1]],n):k},n.x=function(t){return arguments.length?(x=t,y=t.copy(),S={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(b=t,M=t.copy(),S={x:0,y:0,k:1},n):b},Bo.rebind(n,L,"on")};var Pa,Ua=[0,1/0],ja="onwheel"in Go?(Pa=function(){return-Bo.event.deltaY*(Bo.event.deltaMode?120:1)},"wheel"):"onmousewheel"in Go?(Pa=function(){return Bo.event.wheelDelta},"mousewheel"):(Pa=function(){return-Bo.event.detail},"MozMousePixelScroll");Bo.color=it,it.prototype.toString=function(){return this.rgb()+""},Bo.hsl=ot;var Fa=ot.prototype=new it;Fa.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,this.l/n)},Fa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,n*this.l)},Fa.rgb=function(){return at(this.h,this.s,this.l)},Bo.hcl=ct;var Ha=ct.prototype=new it;Ha.brighter=function(n){return new ct(this.h,this.c,Math.min(100,this.l+Oa*(arguments.length?n:1)))},Ha.darker=function(n){return new ct(this.h,this.c,Math.max(0,this.l-Oa*(arguments.length?n:1)))},Ha.rgb=function(){return lt(this.h,this.c,this.l).rgb()},Bo.lab=st;var Oa=18,Ya=.95047,Ia=1,Za=1.08883,Va=st.prototype=new it;Va.brighter=function(n){return new st(Math.min(100,this.l+Oa*(arguments.length?n:1)),this.a,this.b)},Va.darker=function(n){return new st(Math.max(0,this.l-Oa*(arguments.length?n:1)),this.a,this.b)},Va.rgb=function(){return ft(this.l,this.a,this.b)},Bo.rgb=dt;var Xa=dt.prototype=new it;Xa.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dt(u,u,u)},Xa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dt(n*this.r,n*this.g,n*this.b)},Xa.hsl=function(){return _t(this.r,this.g,this.b)},Xa.toString=function(){return"#"+xt(this.r)+xt(this.g)+xt(this.b)};var $a=Bo.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});$a.forEach(function(n,t){$a.set(n,mt(t))}),Bo.functor=kt,Bo.xhr=At(Et),Bo.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=Ct(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=l)return o;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++a);else if(r!==c)continue;return n.slice(t,s-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],l=n.length,s=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,f++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new v,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},Bo.csv=Bo.dsv(",","text/csv"),Bo.tsv=Bo.dsv(" ","text/tab-separated-values");var Ba,Wa,Ja,Ga,Ka,Qa=Qo[m(Qo,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Bo.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};Wa?Wa.n=i:Ba=i,Wa=i,Ja||(Ga=clearTimeout(Ga),Ja=1,Qa(Lt))},Bo.timer.flush=function(){Tt(),qt()},Bo.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var nc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Dt);Bo.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=Bo.round(n,Rt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),nc[8+e/3]};var tc=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ec=Bo.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Bo.round(n,Rt(n,t))).toFixed(Math.max(0,Math.min(20,Rt(n*(1+1e-15),t))))}}),rc=Bo.time={},uc=Date;jt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ic.setUTCDate.apply(this._,arguments)},setDay:function(){ic.setUTCDay.apply(this._,arguments)},setFullYear:function(){ic.setUTCFullYear.apply(this._,arguments)},setHours:function(){ic.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ic.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ic.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ic.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ic.setUTCSeconds.apply(this._,arguments)},setTime:function(){ic.setTime.apply(this._,arguments)}};var ic=Date.prototype;rc.year=Ft(function(n){return n=rc.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),rc.years=rc.year.range,rc.years.utc=rc.year.utc.range,rc.day=Ft(function(n){var t=new uc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),rc.days=rc.day.range,rc.days.utc=rc.day.utc.range,rc.dayOfYear=function(n){var t=rc.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=rc[n]=Ft(function(n){return(n=rc.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=rc.year(n).getDay();return Math.floor((rc.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});rc[n+"s"]=e.range,rc[n+"s"].utc=e.utc.range,rc[n+"OfYear"]=function(n){var e=rc.year(n).getDay();return Math.floor((rc.dayOfYear(n)+(e+t)%7)/7)}}),rc.week=rc.sunday,rc.weeks=rc.sunday.range,rc.weeks.utc=rc.sunday.utc.range,rc.weekOfYear=rc.sundayOfYear;var oc={"-":"",_:" ",0:"0"},ac=/^\s*\d+/,cc=/^%/;Bo.locale=function(n){return{numberFormat:Pt(n),timeFormat:Ot(n)}};var lc=Bo.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});Bo.format=lc.numberFormat,Bo.geo={},ce.prototype={s:0,t:0,add:function(n){le(n,this.t,sc),le(sc.s,this.s,this),this.s?this.t+=sc.t:this.s=sc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var sc=new ce;Bo.geo.stream=function(n,t){n&&fc.hasOwnProperty(n.type)?fc[n.type](n,t):se(n,t)};var fc={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*Ea+n:n,vc.lineStart=vc.lineEnd=vc.point=y}};Bo.geo.bounds=function(){function n(n,t){x.push(M=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*La,e*La]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);xe(o),o=Me(o);var c=t-p,l=c>0?1:-1,v=o[0]*Ta*l,d=ca(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Ta;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Ta;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){_.point=t}function r(){M[0]=s,M[1]=h,_.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=ca(r)>180?r+(r>0?360:-360):r}else v=n,d=e;vc.point(n,e),t(n,e)}function i(){vc.lineStart()}function o(){u(v,d),vc.lineEnd(),ca(y)>Na&&(s=-(h=180)),M[0]=s,M[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:npc?(s=-(h=180),f=-(g=90)):y>Na?g=90:-Na>y&&(f=-90),M[0]=s,M[1]=h}};return function(n){g=h=-(s=f=1/0),x=[],Bo.geo.stream(n,_); diff --git a/build/vizi.min.js b/build/vizi.min.js index f191ab5..7513b8e 100644 --- a/build/vizi.min.js +++ b/build/vizi.min.js @@ -948,7 +948,7 @@ WildEmitter.prototype.getWildcardCallbacks = function (eventName) { return result; }; -/*! ViziCities - v0.2.0 - 2014-11-02 */ +/*! ViziCities - v0.2.0 - 2014-11-03 */ if(void 0===typeof window)var VIZI;!function(){"use strict";var a={VERSION:"0.2.0",DEBUG:!1};console.log("═════════════════════════════════════════════════════════════"),console.log("██╗ ██╗██╗███████╗██╗ ██████╗██╗████████╗██╗███████╗███████╗"),console.log("██║ ██║██║╚══███╔╝██║██╔════╝██║╚══██╔══╝██║██╔════╝██╔════╝"),console.log("██║ ██║██║ ███╔╝ ██║██║ ██║ ██║ ██║█████╗ ███████╗"),console.log("╚██╗ ██╔╝██║ ███╔╝ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║"),console.log(" ╚████╔╝ ██║███████╗██║╚██████╗██║ ██║ ██║███████╗███████║"),console.log(" ╚═══╝ ╚═╝╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝"),console.log("═══════════════════════════ "+a.VERSION+" ═══════════════════════════"),void 0===typeof window?window.VIZI=a:VIZI=a}(),function(){"use strict";VIZI.Attribution=function(a){var b=this;if(VIZI.DEBUG&&console.log("Initialising VIZI.Attribution"),b.options=a||{},_.defaults(b.options,{}),!b.options.element)throw new Error("Required element option missing");b.defaultMessage="Powered by ViziCities",b.container=b.createContainer(b.options.element),b.add(b.defaultMessage)},VIZI.Attribution.prototype.createContainer=function(a){var b=document.createElement("div");return b.classList.add("vizicities-attribution"),a.appendChild(b),b},VIZI.Attribution.prototype.add=function(a){var b=this,c="";b.container.innerHTML.length>0&&(c=" | "),b.container.innerHTML+=c+a}}(),function(){"use strict";VIZI.Clock=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Clock");var a=this;THREE.Clock.call(a)},VIZI.Clock.prototype=Object.create(THREE.Clock.prototype)}(),function(){"use strict";VIZI.EventEmitter=function(){WildEmitter.call(this)},VIZI.EventEmitter.prototype=Object.create(WildEmitter.prototype)}(),function(){"use strict";VIZI.Messenger=function(){var a=new VIZI.EventEmitter;return a}()}(),function(){"use strict";VIZI.World=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.World");var b=this;if(b.options=a||{},_.defaults(b.options,{crs:VIZI.CRS.EPSG3857,center:new VIZI.LatLon(51.50358,-.01924),zoom:16,suppressRenderer:!1}),!b.options.viewport)throw new Error("Required viewport option missing");b.crs=b.options.crs,b.attribution=new VIZI.Attribution({element:b.options.viewport}),b.switchboards=[],b.layers=[],b.scene=new VIZI.Scene({viewport:b.options.viewport,suppressRenderer:b.options.suppressRenderer}),b.camera=b.options.camera||new VIZI.Camera({aspect:b.options.viewport.clientWidth/b.options.viewport.clientHeight}),b.camera.addToScene(b.scene),b.origin=new VIZI.LatLon(b.options.center),b.originZoom=b.options.zoom,b.zoom=void 0,b.center=void 0,b.updateView(b.options.center,b.options.zoom),window.addEventListener("resize",function(){b.resizeView(b.options.viewport.clientWidth,b.options.viewport.clientHeight)}),VIZI.Messenger.on("controls:move",function(a){b.moveToPoint(a)}),VIZI.Messenger.on("controls:zoom",function(a){var c=Math.ceil(b.crs.altitudeToZoom(a));b.zoomTo(c)})},VIZI.World.prototype.project=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0}),e=c.crs.latLonToPoint(a,b,{round:!0});return e.subtract(d)},VIZI.World.prototype.unproject=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0});return c.crs.pointToLatLon(a.add(d),b)},VIZI.World.prototype.pixelsPerMeter=function(a,b){var c=this;return b=b||c.originZoom,c.crs.pixelsPerMeter(a,b)},VIZI.World.prototype.addLayer=function(a){var b=this;b.layers.push(a),b.scene.add(a.object)},VIZI.World.prototype.addSwitchboard=function(a){var b=this;b.switchboards.push(a)},VIZI.World.prototype.onTick=function(a){var b=this;_.each(b.switchboards,function(b){b.onTick(a)})},VIZI.World.prototype.render=function(){var a=this;a.scene.render(a.camera)},VIZI.World.prototype.updateView=function(a,b){var c=this;b&&(c.zoom=b),c.center=a,VIZI.Messenger.emit("world:updateView",c.center,c.zoom)},VIZI.World.prototype.resizeView=function(a,b){var c=this,d=a/b;c.camera.changeAspect(d),c.scene.resize(a,b)},VIZI.World.prototype.moveToLatLon=function(a){var b=this;b.updateView(a)},VIZI.World.prototype.moveToPoint=function(a){var b=this,c=b.unproject(a);b.updateView(c)},VIZI.World.prototype.moveBy=function(a){var b=this,c=b.crs.latLonToPoint(b.center,b.zoom),d=c.add(a);b.updateView(b.crs.pointToLatLon(d,b.zoom))},VIZI.World.prototype.zoomTo=function(a){var b=this;b.updateView(b.center,a)},VIZI.World.prototype.zoomIn=function(a){var b=this;b.updateView(b.center,b.zoom+a)},VIZI.World.prototype.zoomOut=function(a){var b=this;b.updateView(b.center,b.zoom-a)},VIZI.World.prototype.lookAtLatLon=function(a){var b=this,c=b.project(a);b.camera.lookAt(c)},VIZI.World.prototype.lookAtPoint=function(a){var b=this;b.camera.lookAt(a)}}(),function(){"use strict";var a=12756274,b=Math.PI*a,c=b/2;VIZI.CRS={code:void 0,tileSize:256,latLonToPoint:function(a,b,d){var e=this;d=d||{},_.defaults(d,{convert:!0,round:!1});var f,g=e.project(a),h=e.resolution(b);if(f=d.round===!0?new VIZI.Point(Math.round((g[0]+c)/h),Math.round((g[1]+c)/h)):new VIZI.Point((g[0]+c)/h,(g[1]+c)/h),d.convert!==!1){var i=e.tileSize<b?0:b>20?20:b}}}(),function(){"use strict";VIZI.Camera=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Camera");var b=this;if(b.options=a||{},_.defaults(b.options,{fov:40,near:2,far:4e4,position:new VIZI.Point(260,600,550),target:new VIZI.Point}),!b.options.aspect)throw new Error("Required aspect option missing");b.camera=new THREE.PerspectiveCamera(b.options.fov,b.options.aspect,b.options.near,b.options.far),b.moveTo(b.options.position),b.lookAt(b.options.target)},VIZI.Camera.prototype.addToScene=function(a){var b=this;a.add(b.camera)},VIZI.Camera.prototype.moveTo=function(a){var b=this;b.camera.position.x=a.x,b.camera.position.y=a.y,b.camera.position.z=a.z},VIZI.Camera.prototype.moveBy=function(a){var b=this;b.camera.position.x+=a.x,b.camera.position.y+=a.y,b.camera.position.z+=a.z},VIZI.Camera.prototype.lookAt=function(a){var b=this;b.camera.lookAt(new THREE.Vector3(a.x,a.y,a.z))},VIZI.Camera.prototype.changeAspect=function(a){var b=this;b.camera.aspect=a,b.camera.updateProjectionMatrix()}}(),function(){"use strict";VIZI.Layer=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Layer");var a=this;VIZI.EventEmitter.call(a),a.object=new THREE.Object3D},VIZI.Layer.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.Layer.prototype.addToWorld=function(a){var b=this;b.beforeAdd(a),a.addLayer(b),b.onAdd(a)},VIZI.Layer.prototype.beforeAdd=function(){},VIZI.Layer.prototype.onAdd=function(){},VIZI.Layer.prototype.add=function(a){var b=this;b.object.add(a)},VIZI.Layer.prototype.remove=function(a){var b=this;b.object.remove(a)},VIZI.Layer.prototype.applyVertexColors=function(a,b){a.faces.forEach(function(a){for(var c=a instanceof THREE.Face3?3:4,d=0;c>d;d++)a.vertexColors[d]=b})}}(),function(){"use strict";VIZI.Scene=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Scene");var b=this;if(b.options=a||{},_.defaults(b.options,{antialias:!1,fogColour:16777215,suppressRenderer:!1}),!b.options.viewport)throw new Error("Required viewport option missing");b.scene=b.createScene(),b.renderer=b.createRenderer()},VIZI.Scene.prototype.createScene=function(){var a=this,b=new THREE.Scene;b.fog=new THREE.Fog(a.options.fogColour,1,15e3);var c=new THREE.DirectionalLight(10066329);c.intesity=.1,c.position.x=1,c.position.y=1,c.position.z=1,b.add(c);var d=new THREE.DirectionalLight(10066329);return d.intesity=.1,d.position.x=-1,d.position.y=1,d.position.z=-1,b.add(d),b},VIZI.Scene.prototype.createRenderer=function(){var a,b=this;return a=b.options.suppressRenderer?{setSize:function(){},setClearColor:function(){},render:function(){},domElement:document.createElement("canvas")}:new THREE.WebGLRenderer({antialias:b.options.antialias}),a.setSize(b.options.viewport.clientWidth,b.options.viewport.clientHeight),a.setClearColor(b.scene.fog.color,1),a.gammaInput=!0,a.gammaOutput=!0,b.options.viewport.appendChild(a.domElement),a},VIZI.Scene.prototype.add=function(a){var b=this;b.scene.add(a)},VIZI.Scene.prototype.remove=function(a){var b=this;b.scene.remove(a)},VIZI.Scene.prototype.render=function(a){var b=this;if(!b.scene)throw new Error("Scene is required for render");if(!a)throw new Error("Camera is required for render");b.renderer.render(b.scene,a.camera)},VIZI.Scene.prototype.resize=function(a,b){var c=this;c.renderer.setSize(a,b)}}(),function(){"use strict";VIZI.Controls=function(a,b){var c=this;if(VIZI.EventEmitter.call(c),c.options=b||{},_.defaults(c.options,{}),!a)throw new Error("Required camera missing")},VIZI.Controls.prototype=Object.create(VIZI.EventEmitter.prototype)}(),function(){"use strict";VIZI.BlueprintHelperTileGrid=function(a,b){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintHelperTileGrid");var c=this;if(VIZI.EventEmitter.call(c),!(a&&a instanceof VIZI.World))throw new Error("Required world property missing");if(c.world=a,c.options=b||{},_.defaults(c.options,{}),!c.options.zoom)throw new Error("Required options zoom property missing");if(!c.options.cullZoom)throw new Error("Required options cull zoom property missing");if(void 0===c.options.tilesPerDirection)throw new Error("Required options tiles per direction property missing");c.disable=!1,c.centerTile=new VIZI.Point,c.centerTileLatLon=new VIZI.LatLon,c.tileZoom=c.options.zoom,c.cullZoom=c.options.cullZoom,c.tilesPerDirection=c.options.tilesPerDirection,c.bounds,c.boundsLatLon,c.tileCount,c.tiles=[],c.gridDiffSinceMouseUp=new VIZI.Point},VIZI.BlueprintHelperTileGrid.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintHelperTileGrid.prototype.init=function(){var a=this,b=a.world.center;VIZI.DEBUG&&console.log("coords",b),a.centerTile=a.world.crs.latLonToTile(b,a.tileZoom),VIZI.DEBUG&&console.log("centerTile",a.centerTile),a.centerTileLatLon=new VIZI.LatLon(a.world.center),VIZI.DEBUG&&console.log("centerTileLatLon",a.centerTileLatLon);var c=a.world.crs.tileBoundsPoint(a.centerTile,a.tileZoom);return VIZI.DEBUG&&console.log("centerTileBoundsPoint",c),a.bounds=a.getBounds(a.tilesPerDirection),a.boundsLatLon=a.getBoundsLatLon(a.bounds),VIZI.DEBUG&&console.log("bounds",a.bounds),VIZI.DEBUG&&console.log("boundsLatLon",a.boundsLatLon),a.tileCount=new VIZI.Point(a.bounds.e-a.bounds.w+1,a.bounds.s-a.bounds.n+1),VIZI.DEBUG&&console.log("tileCount",a.tileCount),document.body.addEventListener("mouseup",function(b){a.onMouseUp(b)},!1),VIZI.Messenger.on("world:updateView",function(b,c){a.onWorldUpdate(b,c)}),a.collectTiles(),a.tiles},VIZI.BlueprintHelperTileGrid.prototype.collectTiles=function(){for(var a=this,b=[],c=0;cb.distance?1:0}),a.tiles=b},VIZI.BlueprintHelperTileGrid.prototype.getBounds=function(a){var b=this,c={n:Math.floor(b.centerTile.y)-a,e:Math.ceil(b.centerTile.x)+a,s:Math.ceil(b.centerTile.y)+a,w:Math.floor(b.centerTile.x)-a};return c},VIZI.BlueprintHelperTileGrid.prototype.getBoundsLatLon=function(a){var b=this,c=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.e,a.n),b.tileZoom),d=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.w,a.s),b.tileZoom),e={n:c.n,e:c.e,s:d.s,w:d.w};return e},VIZI.BlueprintHelperTileGrid.prototype.onWorldUpdate=function(a,b){var c=this,d=c.world.crs.latLonToTile(a,c.tileZoom),e=new VIZI.Point(Math.floor(d.x)-Math.floor(c.centerTile.x),Math.floor(d.y)-Math.floor(c.centerTile.y));(Math.abs(e.x)>0||Math.abs(e.y)>0)&&(c.centerTile=d,c.centerTileLatLon=new VIZI.LatLon(c.world.center),c.bounds=c.getBounds(c.tilesPerDirection),c.boundsLatLon=c.getBoundsLatLon(c.bounds),c.gridDiffSinceMouseUp.x+=e.x,c.gridDiffSinceMouseUp.y+=e.y,c.collectTiles()),b0||Math.abs(a.gridDiffSinceMouseUp.y)>0)&&(a.emit("moved",a.tiles,a.gridDiffSinceMouseUp),a.gridDiffSinceMouseUp=new VIZI.Point)},VIZI.BlueprintHelperTileGrid.prototype.globalToLocalTiles=function(a,b){var c=this;return new VIZI.Point(a-c.bounds.w,b-c.bounds.n)}}(),function(){"use strict";VIZI.BlueprintInput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintInput");var b=this;VIZI.EventEmitter.call(b),b.options=a||{},b.triggers=[],b.actions=[]},VIZI.BlueprintInput.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintInput.prototype.init=function(){}}(),function(){"use strict";VIZI.BlueprintInputGeoJSON=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["geoJSON"]},{name:"tileReceived",arguments:["geoJSON","tile"]}],b.actions=[{name:"requestData",arguments:[]},{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputGeoJSON.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputGeoJSON.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputGeoJSON.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.json(a.options.path,function(b,c){return b?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(b)):void a.emit("dataReceived",c)})},VIZI.BlueprintInputGeoJSON.prototype.requestTiles=function(a){var b=this;if(!b.options.tilePath)throw new Error("Required tile path option missing");VIZI.DEBUG&&console.log("Requesting tiles",a),_.each(a,function(a){var c=b.options.tilePath.replace(/\{([zxy])\}/g,function(b,c){return a[c]});d3.json(c,function(c,d){return c?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(c)):void b.emit("tileReceived",d,a)})})}}(),function(){"use strict";VIZI.BlueprintInputKML=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["kml"]}],b.actions=[{name:"requestData",arguments:[]}]},VIZI.BlueprintInputKML.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputKML.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputKML.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.xml(a.options.path,function(b,c){if(b)return VIZI.DEBUG&&console.log("Failed to request KML data"),void console.warn(b);var d=JXON.build(c.querySelector("kml"));a.processCoordinates(d),a.emit("dataReceived",d)})},VIZI.BlueprintInputKML.prototype.processCoordinates=function(a){var b=this;_.each(a,function(c,d){_.isObject(c)?b.processCoordinates(c):"coordinates"===d&&(a[d]=c.split(","))})}}(),function(){"use strict";VIZI.BlueprintInputMapTiles=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{tilePath:"https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"}),b.triggers=[{name:"initialised",arguments:[]},{name:"tileReceived",arguments:["image","tile"]}],b.actions=[{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputMapTiles.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputMapTiles.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputMapTiles.prototype.requestTiles=function(a){var b=this;VIZI.DEBUG&&console.log("Requesting tiles",a),_.each(a,function(a){var c=b.options.tilePath.replace(/\{([zxy])\}/g,function(b,c){return a[c]}),d=new Image;d.onload=function(){b.emit("tileReceived",d,a),d=void 0},d.crossOrigin="Anonymous",d.src=c})}}(),function(){"use strict";VIZI.BlueprintOutput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintOutput");var b=this;VIZI.Layer.call(b),b.options=a||{},b.triggers=[],b.actions=[]},VIZI.BlueprintOutput.prototype=Object.create(VIZI.Layer.prototype),VIZI.BlueprintOutput.prototype.init=function(){},VIZI.BlueprintOutput.prototype.onTick=function(){}}(),function(){"use strict";VIZI.BlueprintOutputBuildingTiles=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{workerURL:"vizi-worker.min.js"}),b.triggers=[{name:"initialised",arguments:["tiles"]},{name:"gridUpdated",arguments:["tiles"]}],b.actions=[{name:"outputBuildingTile",arguments:["buildings","tile"]}],b.grids={},b.world,b.worker},VIZI.BlueprintOutputBuildingTiles.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputBuildingTiles.prototype.init=function(){var a=this;a.worker=operative(a.outputBuildingTileWorker,[a.options.workerURL]),_.each(a.options.grids,function(b){a.grids[b.zoom]=a.createGrid(b)});var b=[];_.each(a.grids,function(a){b=b.concat(a.grid.tiles)}),a.emit("initialised",b)},VIZI.BlueprintOutputBuildingTiles.prototype.createGrid=function(a){var b=this,c={},d=new VIZI.BlueprintHelperTileGrid(b.world,a);d.on("moved",function(a,e){VIZI.DEBUG&&console.log("Grid moved",a,e),_.each(c.meshes,function(a){b.remove(a)}),c.meshes=[],d.disable||b.emit("gridUpdated",a)}),d.on("disabled",function(){VIZI.DEBUG&&console.log("Grid disabled"),_.each(c.meshes,function(a){a.visible=!1})}),d.on("enabled",function(){VIZI.DEBUG&&console.log("Grid enabled"),b.emit("gridUpdated",d.tiles),_.each(c.meshes,function(a){a.visible=!0})});var e=d.init();return VIZI.DEBUG&&console.log("Grid initialised",e),c.grid=d,c.meshes=[],c},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTile=function(a,b){var c=this,d=c.grids[b.z],e=new THREE.JSONLoader,f=new THREE.MeshLambertMaterial({color:15658734,ambient:16777215,emissive:13421772,shading:THREE.FlatShading});c.worker(c.world.origin,c.world.originZoom,a).then(function(a){var b=a.model,g=a.offset;b.vertices=Array.apply([],b.vertices),b.normals=Array.apply([],b.normals),b.uvs=[Array.apply([],b.uvs)];var h=[];_.each(b.faces,function(a){h.push(a)}),b.faces=h;var i=e.parse(b),j=new THREE.Mesh(i.geometry,f);j.position.x=-1*g.x,j.position.y=-1*g.y,j.position.z=-1*g.z,d.meshes.push(j),c.add(j)},function(){})},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTileWorker=function(a,b,c){var d,e=this,f=e.deferred(),g=VIZI.CRS.EPSG3857,h=function(c,d){d=d||b;var e=g.latLonToPoint(a,d,{round:!0}),f=g.latLonToPoint(c,d,{round:!0});return f.subtract(e)},i=function(a,c){return c=c||b,g.pixelsPerMeter(a,c)},j=new THREE.Geometry;_.each(c,function(a){var b=new VIZI.Point,c=new THREE.Shape;_.each(a.outline[0],function(a,e){var f=new VIZI.LatLon(a[1],a[0]),g=h(f);void 0===d&&(d=i(f)),0===b.length&&(b.x=-1*g.x,b.y=-1*g.y),0===e?c.moveTo(g.x+b.x,g.y+b.y):c.lineTo(g.x+b.x,g.y+b.y)});var e=a.height?a.height:5+10*Math.random();e*=d.y;var f={amount:e,bevelEnabled:!1},g=new THREE.ExtrudeGeometry(c,f);g.computeFaceNormals();var k=new THREE.Mesh(g);k.position.y=e,k.position.x=-1*b.x,k.position.z=-1*b.y,k.rotation.x=90*Math.PI/180,k.matrixAutoUpdate&&k.updateMatrix(),j.merge(k.geometry,k.matrix)});var k=j.center(),l=j.toJSON(),m=new Float64Array(l.data.vertices),n=new Float64Array(l.data.normals),o=new Float64Array(l.data.uvs[0]),p=new Float64Array(l.data.faces),q={metadata:l.metadata,colors:l.colors,vertices:m,normals:n,uvs:o,faces:p},r={model:q,offset:k};f.transferResolve(r,[q.vertices.buffer,q.normals.buffer,q.uvs.buffer,q.faces.buffer])},VIZI.BlueprintOutputBuildingTiles.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputChoropleth=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{colourRange:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],layer:10}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputChoropleth",arguments:["data"]}],b.world},VIZI.BlueprintOutputChoropleth.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputChoropleth.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputChoropleth.prototype.outputChoropleth=function(a){var b=this,c=new THREE.MeshLambertMaterial({vertexColors:THREE.VertexColors,ambient:16777215,emissive:13421772,shading:THREE.FlatShading,side:THREE.BackSide});if(b.options.colourRange)var d=a.sort(function(a,b){return d3.ascending(a.value,b.value)}),e=d[0].value,f=d[a.length-1].value,g=(d3.scale.linear().domain([e,f]).range([1,500]),d3.scale.quantile().domain([e,f]).range(b.options.colourRange));var h=new THREE.Geometry;_.each(a,function(a){var c=new VIZI.Point,d=new THREE.Shape;_.each(a.outline,function(a,e){var f=b.world.project(new VIZI.LatLon(a[1],a[0]));0===c.length&&(c.x=-1*f.x,c.y=-1*f.y),0===e?d.moveTo(f.x+c.x,f.y+c.y):d.lineTo(f.x+c.x,f.y+c.y)});var e=new THREE.ShapeGeometry(d),f=new THREE.Color(b.options.colourRange?g(a.value):16777215*Math.random());b.applyVertexColors(e,f);var i=new THREE.Mesh(e);i.position.x=-1*c.x,i.position.z=-1*c.y,i.rotation.x=90*Math.PI/180,i.matrixAutoUpdate&&i.updateMatrix(),h.merge(i.geometry,i.matrix)});var i=h.center(),j=new THREE.Mesh(h,c);b.options.layer.toString().length>0&&(j.renderDepth=-1*b.options.layer,j.material.depthWrite=!1,j.material.transparent=!0),j.position.x=-1*i.x,j.position.y=-1*i.y,j.position.z=-1*i.z,b.add(j)},VIZI.BlueprintOutputChoropleth.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputCollada=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputCollada",arguments:["collada"]}],b.world},VIZI.BlueprintOutputCollada.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputCollada.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputCollada.prototype.outputCollada=function(a){var b=this,c=new THREE.ColladaLoader;c.options.convertUpAxis=!0;var d;_.each(a,function(a){var e=b.options.modelPathPrefix?b.options.modelPathPrefix+a.modelPath:a.modelPath;c.load(e,function(c){var e=c.scene,f=new VIZI.LatLon(a.coordinates[1],a.coordinates[0]),g=b.world.project(f);void 0===d&&(d=b.world.pixelsPerMeter(f)),e.position.x=g.x,e.position.z=g.y,e.scale.x=e.scale.y=e.scale.z=e.scale.x*d.y,e.updateMatrix(),b.add(e)})})},VIZI.BlueprintOutputCollada.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputDebugPoints=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputPoints",arguments:["data"]}],b.world},VIZI.BlueprintOutputDebugPoints.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputDebugPoints.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputDebugPoints.prototype.outputPoints=function(a){for(var b=this,c=new THREE.MeshBasicMaterial({color:16711680,shading:THREE.FlatShading}),d=new THREE.BoxGeometry(40,1,40),e=d.vertices,f=0;fa)){var c=a/b.controls.offset.length();c>0?b.controls.dollyOut(c):0>c&&b.controls.dollyIn(c),b.controls.update()}},VIZI.ControlsMap.prototype.getZoom=function(){var a=this;return a.controls.offset.length()},VIZI.ControlsMap.prototype.onTick=function(a){var b=this;b.controls.update(a)}}(),function(){"use strict";VIZI.ControlsOrbit=function(a,b){var c=this;VIZI.Controls.call(c,a,b),c.controls=new THREE.OrbitControls(a.camera),c.controls.addEventListener("start",function(){c.onStart()}),c.controls.addEventListener("change",function(){c.onChange()}),c.controls.addEventListener("end",function(){c.onEnd()})},VIZI.ControlsOrbit.prototype=Object.create(VIZI.Controls.prototype),VIZI.ControlsOrbit.prototype.onStart=function(){},VIZI.ControlsOrbit.prototype.onChange=function(){var a=this,b=new VIZI.Point(a.controls.target.x,a.controls.target.z);VIZI.Messenger.emit("controls:move",b);var c=a.getZoom();VIZI.Messenger.emit("controls:zoom",c)},VIZI.ControlsOrbit.prototype.onEnd=function(){},VIZI.ControlsOrbit.prototype.moveTo=function(a){var b=this;b.controls.target.x=a.x,b.controls.target.z=a.y,b.controls.update()},VIZI.ControlsOrbit.prototype.moveBy=function(a){var b=this;b.controls.target.x+=a.x,b.controls.target.z+=a.y,b.controls.update()},VIZI.ControlsOrbit.prototype.zoomTo=function(a){var b=this;if(!(10>a)){var c=a/b.controls.offset.length();c>0?b.controls.dollyOut(c):0>c&&b.controls.dollyIn(c),b.controls.update()}},VIZI.ControlsOrbit.prototype.getZoom=function(){var a=this;return a.controls.offset.length()},VIZI.ControlsOrbit.prototype.onTick=function(a){var b=this;b.controls.update(a)}}(),function(){"use strict";VIZI.CRS.EPSG3857=_.extend({},VIZI.CRS,{code:"EPSG:3857"}),VIZI.CRS.EPSG900913=_.extend({},VIZI.CRS.EPSG3857,{code:"EPSG:900913"})}(),function(){"use strict";VIZI.LatLon=function(a,b,c){var d=this;d.lat=a||0,d.lon=b||0,d.alt=c||0,a instanceof VIZI.LatLon?(d.lat=a.lat,d.lon=a.lon,d.alt=a.alt):_.isArray(a)&&(d.lat=a[0],d.lon=a[1],d.alt=a[2]||0)}}(),function(){"use strict";VIZI.Point=function(a,b,c){var d=this;d.x=a||0,d.y=b||0,d.z=c||0,a instanceof VIZI.Point?(d.x=a.x,d.y=a.y,d.z=a.z):_.isArray(a)&&(d.x=a[0],d.y=a[1],d.z=a[2]||0)},VIZI.Point.prototype.add=function(a){var b=this,c=new VIZI.Point(b.x+a.x,b.y+a.y,b.z+a.z);return c},VIZI.Point.prototype.subtract=function(a){var b=this,c=new VIZI.Point(b.x-a.x,b.y-a.y,b.z-a.z);return c}}(),THREE.ColladaLoader=function(){function a(a,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4===f.readyState){if(0===f.status||200===f.status)if(f.responseXML)Qb=c,b(f.responseXML,void 0,a);else if(f.responseText){Qb=c;var g=new DOMParser,h=g.parseFromString(f.responseText,"application/xml");b(h,void 0,a)}else console.error("ColladaLoader: Empty or non-existing file ("+a+")")}else 3===f.readyState&&d&&(0===e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))},f.open("GET",a,!0),f.send(null)}else alert("Don't know how to parse XML!")}function b(a,b,c){if(Ob=a,b=b||Qb,void 0!==c){var i=c.split("/");i.pop(),Lb=(i.length<1?".":i.join("/"))+"/"}d(),zb(),Sb=e("library_images image",F,"image"),Wb=e("library_materials material",Z,"material"),Xb=e("library_effects effect",cb,"effect"),Vb=e("library_geometries geometry",P,"geometry"),Yb=e("library_cameras camera",ib,"camera"),Zb=e("library_lights light",kb,"light"),Ub=e("library_controllers controller",G,"controller"),Tb=e("library_animations animation",eb,"animation"),Kb=e("library_visual_scenes visual_scene",J,"visual_scene"),kinematicsModels=e("library_kinematics_models kinematics_model",mb,"kinematics_model"),Mb=[],Nb=[],Gb=f(),Pb=new THREE.Scene;for(var j=0;jh;h++){var i=d[h],j=(new b).parse(i);j.id&&0!==j.id.length||(j.id=c+f++),e[j.id]=j}return e}function f(){var a=Ob.querySelectorAll("scene instance_visual_scene")[0];if(a){var b=a.getAttribute("url").replace(/^#/,"");return Kb[b.length>0?b:"visual_scene0"]}return null}function g(){var a=Ob.querySelectorAll("instance_kinematics_model")[0];if(a){var b=a.getAttribute("url").replace(/^#/,"");return kinematicsModels[b.length>0?b:"kinematics_model0"]}return null}function h(){Ib=[],i(Pb)}function i(a){var b=Gb.getChildById(a.colladaId,!0),c=null;if(b&&b.keys){c={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0},Ib.push(c);for(var d=0,e=b.keys.length;e>d;d++)c.length=Math.max(c.length,b.keys[d].time)}else c={hierarchy:[{keys:[],sids:[]}]};for(var d=0,e=a.children.length;e>d;d++)for(var f=i(a.children[d]),g=0,h=f.hierarchy.length;h>g;g++)c.hierarchy.push({keys:[],sids:[]});return c}function k(){var a,b=1e6,c=-b,d=0;for(var e in Tb){var f=Tb[e];a=a||f.id;for(var g=0;g=0){var g=b.invBindMatrices[e];d.invBindMatrix=g,d.skinningMatrix=new THREE.Matrix4,d.skinningMatrix.multiplyMatrices(d.world,g),d.animatrix=new THREE.Matrix4,d.animatrix.copy(d.localworld),d.weights=[];for(var f=0;ff.limits.max||c1)for(C=new THREE.MeshFaceMaterial(s),e=0;e0?(C.morphTargets=!0,C.skinning=!1):(C.morphTargets=!1,C.skinning=!0),B=new THREE.SkinnedMesh(D,C,!1),B.name="skin_"+Nb.length,Nb.push(B)):void 0!==c?(l(D,c),C.morphTargets=!0,B=new THREE.Mesh(D,C),B.name="morph_"+Mb.length,Mb.push(B)):B=D.isLineStrip===!0?new THREE.Line(D):new THREE.Mesh(D,C),f.add(B)}}for(d=0;dd;d++){var f,g=a.channels[d],h=g.fullSid,i=g.sampler,j=i.input,k=a.getTransformBySid(g.sid);if(g.arrIndices){f=[];for(var l=0,m=g.arrIndices.length;m>l;l++)f[l]=Eb(g.arrIndices[l])}else f=Fb(g.member);if(k){-1===c.indexOf(h)&&c.push(h);for(var l=0,m=j.length;m>l;l++){var n=j[l],o=i.getData(k.type,l,f),p=A(b,n);if(!p){p=new hb(n);var q=B(b,n);b.splice(-1===q?b.length:q,0,p)}p.addTarget(h,k,f,o)}}else console.log('Could not find transform "'+g.sid+'" in node '+a.id)}for(var d=0;dd&&null===c;d++){var f=a[d];if(f.time===b)c=f;else if(f.time>b)break}return c}function B(a,b){for(var c=-1,d=0,e=a.length;e>d&&-1===c;d++){var f=a[d];f.time>=b&&(c=d)}return c}function C(a,b,c,d){var e=E(a,d,c?c-1:0),f=D(a,d,c+1);if(e&&f){var g,h=(b.time-e.time)/(f.time-e.time),i=e.getTarget(d),j=f.getTarget(d).data,k=i.data;if("matrix"===i.type)g=k;else if(k.length){g=[];for(var l=0;l=0?c:c+a.length;c>=0;c--){var d=a[c];if(d.hasTarget(b))return d}return null}function F(){this.id="",this.init_from=""}function G(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function I(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function J(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Scene}function K(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function L(){this.sid="",this.type="",this.data=[],this.obj=null}function M(){this.url="",this.skeleton=[],this.instance_material=[]}function N(){this.symbol="",this.target=""}function O(){this.url="",this.instance_material=[]}function P(){this.id="",this.mesh=null}function Q(a){this.geometry=a.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function R(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function S(){R.call(this),this.vcount=[]}function T(){R.call(this),this.vcount=1}function U(){R.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function W(){this.input={}}function X(){this.semantic="",this.offset=0,this.source="",this.set=0}function Y(a){this.id=a,this.type=null}function Z(){this.id="",this.name="",this.instance_effect=null}function $(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function _(a,b){this.type=a,this.effect=b,this.material=null}function ab(a){this.effect=a,this.init_from=null,this.format=null}function bb(a){this.effect=a,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function cb(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function db(){this.url=""}function eb(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function fb(a){this.animation=a,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function gb(a){this.id="",this.animation=a,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function hb(a){this.targets=[],this.time=a}function ib(){this.id="",this.name="",this.technique=""}function jb(){this.url=""}function kb(){this.id="",this.name="",this.technique=""}function lb(){this.url=""}function mb(){this.id="",this.name="",this.joints=[],this.links=[]}function nb(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ob(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function pb(){this.joint="",this.transforms=[],this.links=[]}function qb(a){var b=a.getAttribute("id");return void 0!=Rb[b]?Rb[b]:(Rb[b]=new Y(b).parse(a),Rb[b])}function rb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push("true"===b[d]||"1"===b[d]?!0:!1);return c}function sb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push(parseFloat(b[d]));return c}function tb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push(parseInt(b[d],10));return c}function ub(a){return a.length>0?vb(a).split(/\s+/):[]}function vb(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")}function wb(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function xb(a,b){loader=new THREE.ImageLoader,loader.load(b,function(b){a.image=b,a.needsUpdate=!0})}function yb(a,b){a.doubleSided=!1;var c=b.querySelectorAll("extra double_sided")[0];c&&c&&1===parseInt(c.textContent,10)&&(a.doubleSided=!0)}function zb(){if(_b.convertUpAxis!==!0||bc===_b.upAxis)cc=null;else switch(bc){case"X":cc="Y"===_b.upAxis?"XtoY":"XtoZ";break;case"Y":cc="X"===_b.upAxis?"YtoX":"YtoZ";break;case"Z":cc="X"===_b.upAxis?"ZtoX":"ZtoY"}}function Ab(a,b){if(_b.convertUpAxis===!0&&bc!==_b.upAxis)switch(cc){case"XtoY":var c=a[0];a[0]=b*a[1],a[1]=c;break;case"XtoZ":var c=a[2];a[2]=a[1],a[1]=a[0],a[0]=c;break;case"YtoX":var c=a[0];a[0]=a[1],a[1]=b*c;break;case"YtoZ":var c=a[1];a[1]=b*a[2],a[2]=c;break;case"ZtoX":var c=a[0];a[0]=a[1],a[1]=a[2],a[2]=c;break;case"ZtoY":var c=a[1];a[1]=a[2],a[2]=b*c}}function Bb(a,b){if(_b.convertUpAxis!==!0||bc===_b.upAxis)return b;switch(a){case"X":b="XtoY"===cc?-1*b:b;break;case"Y":b="YtoZ"===cc||"YtoX"===cc?-1*b:b;break;case"Z":b="ZtoY"===cc?-1*b:b}return b}function Cb(a,b){var c=[a[b],a[b+1],a[b+2]];return Ab(c,-1),new THREE.Vector3(c[0],c[1],c[2])}function Db(a){if(_b.convertUpAxis){var b=[a[0],a[4],a[8]];Ab(b,-1),a[0]=b[0],a[4]=b[1],a[8]=b[2],b=[a[1],a[5],a[9]],Ab(b,-1),a[1]=b[0],a[5]=b[1],a[9]=b[2],b=[a[2],a[6],a[10]],Ab(b,-1),a[2]=b[0],a[6]=b[1],a[10]=b[2],b=[a[0],a[1],a[2]],Ab(b,-1),a[0]=b[0],a[1]=b[1],a[2]=b[2],b=[a[4],a[5],a[6]],Ab(b,-1),a[4]=b[0],a[5]=b[1],a[6]=b[2],b=[a[8],a[9],a[10]],Ab(b,-1),a[8]=b[0],a[9]=b[1],a[10]=b[2],b=[a[3],a[7],a[11]],Ab(b,-1),a[3]=b[0],a[7]=b[1],a[11]=b[2]}return(new THREE.Matrix4).set(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}function Eb(a){if(a>-1&&3>a){var b=["X","Y","Z"],c={X:0,Y:1,Z:2};a=Fb(b[a]),a=c[a]}return a}function Fb(a){if(_b.convertUpAxis)switch(a){case"X":switch(cc){case"XtoY":case"XtoZ":case"YtoX":a="Y";break;case"ZtoX":a="Z"}break;case"Y":switch(cc){case"XtoY":case"YtoX":case"ZtoX":a="X";break;case"XtoZ":case"YtoZ":case"ZtoY":a="Z"}break;case"Z":switch(cc){case"XtoZ":a="X";break;case"YtoZ":case"ZtoX":case"ZtoY":a="Y"}}return a}var Gb,Hb,Ib,Jb,Kb,Hb,Lb,Mb,Nb,Ob=null,Pb=null,Qb=null,Rb={},Sb={},Tb={},Ub={},Vb={},Wb={},Xb={},Yb={},Zb={},$b=THREE.SmoothShading,_b={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},ac=1,bc="Y",cc=null;return F.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;bk;k++){for(var l={},m=0;m=0,i=g.indexOf("(")>=0;if(h)f=g.split("."),g=f.shift(),d=f.shift();else if(i){c=g.split("("),g=c.shift();for(var j=0;jn?p:n,e.semantic){case"TEXCOORD":o.push(e.set)}}for(var q=0;qc;c++)for(d=0;dx;x++)u.push(Cb(h.data,t[x]*i))}else b.calcNormals=!0;if(!v&&(v={},e=this.vertices.input.TEXCOORD)){o.push(e.set),h=Rb[e.source],i=h.accessor.params.length;for(var x=0,y=t.length;y>x;x++)g=t[x]*i,void 0===v[e.set]&&(v[e.set]=[]),v[e.set].push(new THREE.Vector2(h.data[g],1-h.data[g+1]))}if(0===w.length&&(e=this.vertices.input.COLOR)){h=Rb[e.source],i=h.accessor.params.length;for(var x=0,y=t.length;y>x;x++)g=t[x]*i,w.push((new THREE.Color).setRGB(h.data[g],h.data[g+1],h.data[g+2]))}var z,A,B=null,C=[];if(3===m)C.push(new THREE.Face3(t[0],t[1],t[2],u,w.length?w:new THREE.Color));else if(4===m)C.push(new THREE.Face3(t[0],t[1],t[3],[u[0],u[1],u[3]],w.length?[w[0],w[1],w[3]]:new THREE.Color)),C.push(new THREE.Face3(t[1],t[2],t[3],[u[1],u[2],u[3]],w.length?[w[1],w[2],w[3]]:new THREE.Color));else if(m>4&&_b.subdivideFaces){var D=w.length?w:new THREE.Color;for(d=1;m-1>d;)C.push(new THREE.Face3(t[0],t[d],t[d+1],[u[0],u[d++],u[d]],D))}if(C.length)for(var x=0,y=C.length;y>x;x++)for(B=C[x],B.daeMaterial=a.material,b.faces.push(B),d=0;d4?[z[0],z[x+1],z[x+2]]:4===m?0===x?[z[0],z[1],z[3]]:[z[1].clone(),z[2],z[3].clone()]:[z[0],z[1],z[2]],void 0===b.faceVertexUvs[d]&&(b.faceVertexUvs[d]=[]),b.faceVertexUvs[d].push(A);else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);s+=n*m}},R.prototype.setVertices=function(a){for(var b=0;b0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}return this.create(),this},_.prototype.create=function(){var a={},b=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var c=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);c>0&&(b=!0,a.transparent=!0,a.opacity=1-c)}var d={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var e in this)switch(e){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var f=this[e];if(f instanceof $)if(f.isTexture()){var g=f.texture,h=this.effect.sampler[g];if(void 0!==h&&void 0!==h.source){var i=this.effect.surface[h.source];if(void 0!==i){var j=Sb[i.init_from];if(j){var k,l=Lb+j.init_from,m=THREE.Loader.Handlers.get(l);null!==m?k=m.load(l):(k=new THREE.Texture,xb(k,l)),k.wrapS=f.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,k.wrapT=f.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,k.offset.x=f.texOpts.offsetU,k.offset.y=f.texOpts.offsetV,k.repeat.x=f.texOpts.repeatU,k.repeat.y=f.texOpts.repeatV,a[d[e]]=k,"emission"===e&&(a.emissive=16777215)}}}}else"diffuse"!==e&&b||("emission"===e?a.emissive=f.color.getHex():a[e]=f.color.getHex());break;case"shininess":a[e]=this[e];break;case"reflectivity":a[e]=this[e],a[e]>0&&(a.envMap=_b.defaultEnvMap),a.combine=THREE.MixOperation;break;case"index_of_refraction":a.refractionRatio=this[e],1!==this[e]&&(a.envMap=_b.defaultEnvMap);break;case"transparency":}switch(a.shading=$b,a.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,this.type){case"constant":void 0!=a.emissive&&(a.color=a.emissive),this.material=new THREE.MeshBasicMaterial(a);break;case"phong":case"blinn":void 0!=a.diffuse&&(a.color=a.diffuse),this.material=new THREE.MeshPhongMaterial(a);break;case"lambert":default:void 0!=a.diffuse&&(a.color=a.diffuse),this.material=new THREE.MeshLambertMaterial(a)}return this.material},ab.prototype.parse=function(a){for(var b=0;b=0,e=c.indexOf("(")>=0;if(d)b=c.split("."),this.sid=b.shift(),this.member=b.shift();else if(e){var f=c.split("(");this.sid=f.shift();for(var g=0;g1){d=[],b*=this.strideOut;for(var e=0;ec;c++){var e,f=this.targets[c],g=a.getTarget(f.sid);if("matrix"!==f.transform.type&&g){var h=(b-this.time)/(a.time-this.time),i=g.data,j=f.data;if(0>h&&(h=0),h>1&&(h=1),j.length){e=[];for(var k=0;k=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ob.prototype.parse=function(a){this.sid=a.getAttribute("sid"),this.name=a.getAttribute("name"),this.transforms=[],this.attachments=[];for(var b=0;bd;d++)f.faceVertexUvs[d]=[]}for(h=0,i=G.length;i>h;)v=new THREE.Vector3,v.x=G[h++]*b,v.y=G[h++]*b,v.z=G[h++]*b,f.vertices.push(v);for(h=0,i=F.length;i>h;)if(n=F[h++],o=c(n,0),p=c(n,1),q=c(n,3),r=c(n,4),s=c(n,5),t=c(n,6),u=c(n,7),o){if(x=new THREE.Face3,x.a=F[h],x.b=F[h+1],x.c=F[h+3],y=new THREE.Face3,y.a=F[h+1],y.b=F[h+2],y.c=F[h+3],h+=4,p&&(m=F[h++],x.materialIndex=m,y.materialIndex=m),g=f.faces.length,q)for(d=0;J>d;d++)for(B=a.uvs[d],f.faceVertexUvs[d][g]=[],f.faceVertexUvs[d][g+1]=[],e=0;4>e;e++)l=F[h++],D=B[2*l],E=B[2*l+1],C=new THREE.Vector2(D,E),2!==e&&f.faceVertexUvs[d][g].push(C),0!==e&&f.faceVertexUvs[d][g+1].push(C);if(r&&(k=3*F[h++],x.normal.set(H[k++],H[k++],H[k]),y.normal.copy(x.normal)),s)for(d=0;4>d;d++)k=3*F[h++],A=new THREE.Vector3(H[k++],H[k++],H[k]),2!==d&&x.vertexNormals.push(A),0!==d&&y.vertexNormals.push(A);if(t&&(j=F[h++],z=I[j],x.color.setHex(z),y.color.setHex(z)),u)for(d=0;4>d;d++)j=F[h++],z=I[j],2!==d&&x.vertexColors.push(new THREE.Color(z)),0!==d&&y.vertexColors.push(new THREE.Color(z));f.faces.push(x),f.faces.push(y)}else{if(w=new THREE.Face3,w.a=F[h++],w.b=F[h++],w.c=F[h++],p&&(m=F[h++],w.materialIndex=m),g=f.faces.length,q)for(d=0;J>d;d++)for(B=a.uvs[d],f.faceVertexUvs[d][g]=[],e=0;3>e;e++)l=F[h++],D=B[2*l],E=B[2*l+1],C=new THREE.Vector2(D,E),f.faceVertexUvs[d][g].push(C);if(r&&(k=3*F[h++],w.normal.set(H[k++],H[k++],H[k])),s)for(d=0;3>d;d++)k=3*F[h++],A=new THREE.Vector3(H[k++],H[k++],H[k]),w.vertexNormals.push(A);if(t&&(j=F[h++],w.color.setHex(I[j])),u)for(d=0;3>d;d++)j=F[h++],w.vertexColors.push(new THREE.Color(I[j]));f.faces.push(w)}}function d(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var c=0,d=a.skinWeights.length;d>c;c+=b){var e=a.skinWeights[c],g=b>1?a.skinWeights[c+1]:0,h=b>2?a.skinWeights[c+2]:0,i=b>3?a.skinWeights[c+3]:0;f.skinWeights.push(new THREE.Vector4(e,g,h,i))}if(a.skinIndices)for(var c=0,d=a.skinIndices.length;d>c;c+=b){var j=a.skinIndices[c],k=b>1?a.skinIndices[c+1]:0,l=b>2?a.skinIndices[c+2]:0,m=b>3?a.skinIndices[c+3]:0;f.skinIndices.push(new THREE.Vector4(j,k,l,m))}f.bones=a.bones,f.bones&&f.bones.length>0&&(f.skinWeights.length!==f.skinIndices.length||f.skinIndices.length!==f.vertices.length)&&console.warn("When skinning, number of vertices ("+f.vertices.length+"), skinIndices ("+f.skinIndices.length+"), and skinWeights ("+f.skinWeights.length+") should match."),f.animation=a.animation,f.animations=a.animations}function e(b){if(void 0!==a.morphTargets){var c,d,e,g,h,i;for(c=0,d=a.morphTargets.length;d>c;c++)for(f.morphTargets[c]={},f.morphTargets[c].name=a.morphTargets[c].name,f.morphTargets[c].vertices=[],h=f.morphTargets[c].vertices,i=a.morphTargets[c].vertices,e=0,g=i.length;g>e;e+=3){var j=new THREE.Vector3;j.x=i[e]*b,j.y=i[e+1]*b,j.z=i[e+2]*b,h.push(j)}}if(void 0!==a.morphColors){var c,d,k,l,m,n,o;for(c=0,d=a.morphColors.length;d>c;c++)for(f.morphColors[c]={},f.morphColors[c].name=a.morphColors[c].name,f.morphColors[c].colors=[],m=f.morphColors[c].colors,n=a.morphColors[c].colors,k=0,l=n.length;l>k;k+=3)o=new THREE.Color(16755200),o.setRGB(n[k],n[k+1],n[k+2]),m.push(o)}}var f=new THREE.Geometry,g=void 0!==a.scale?1/a.scale:1;if(c(g),d(),e(g),f.computeFaceNormals(),f.computeBoundingSphere(),void 0===a.materials||0===a.materials.length)return{geometry:f};var h=this.initMaterials(a.materials,b);return this.needsTangents(h)&&f.computeTangents(),{geometry:f,materials:h}},"undefined"==typeof XMLSerializer&&(XMLSerializer=require("xmldom").XMLSerializer,document={},document.implementation=new(require("xmldom").DOMImplementation));var JXON=new function(){function a(a){return j.test(a)?null:k.test(a)?"true"===a.toLowerCase():isFinite(a)?parseFloat(a):isFinite(Date.parse(a))?new Date(a):a}function b(){}function c(a){return null===a?new b:a instanceof Object?a:new a.constructor(a)}function d(b,e,j,k){var l,m,n=i.length,o=b.hasChildNodes(),p=b.hasAttributes(),q=Boolean(2&e),r=0,s="",t=q?{}:!0;if(o)for(var u,v=0;vy;y++)l=i[y].nodeName.toLowerCase(),m=d(i[y],e,j,k),t.hasOwnProperty(l)?(t[l].constructor!==Array&&(t[l]=[t[l]]),t[l].push(m)):(t[l]=m,r++);if(p){for(var z,A=b.attributes.length,B=k?"":h,C=k?{}:t,D=0;A>D;r++,D++)z=b.attributes.item(D),C[B+z.name.toLowerCase()]=a(z.value.trim());k&&(j&&Object.freeze(C),t[g]=C,r-=A-1)}return 3===e||(2===e||1===e&&r>0)&&s?t[f]=x:!q&&0===r&&s&&(t=x),j&&(q||r>0)&&Object.freeze(t),i.length=n,t}function e(a,b,c){var d,i;c instanceof String||c instanceof Number||c instanceof Boolean?b.appendChild(a.createTextNode(c.toString())):c.constructor===Date&&b.appendChild(a.createTextNode(c.toGMTString()));for(var j in c)if(d=c[j],!(isFinite(j)||d instanceof Function))if(j===f)null!==d&&d!==!0&&b.appendChild(a.createTextNode(d.constructor===Date?d.toGMTString():String(d)));else if(j===g)for(var k in d)b.setAttribute(k,d[k]);else if(j.charAt(0)===h)b.setAttribute(j.slice(1),d);else if(d.constructor===Array)for(var l=0;l1&&"number"==typeof b?3&b:1;return d(a,f,c||!1,arguments.length>3?e:3===f)},this.unbuild=function(a){var b=document.implementation.createDocument("","",null);return e(b,b,a),b},this.stringify=function(a){return(new XMLSerializer).serializeToString(JXON.unbuild(a))}};THREE.MapControls=function(a,b){function c(){return 2*Math.PI/60/60*m.autoRotateSpeed}function d(){return Math.pow(.95,m.zoomSpeed)}function e(a){if(m.enabled!==!1){if(a.preventDefault(),a.button===m.mouseButtons.ORBIT){if(m.noRotate===!0)return;F=E.ROTATE,o.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.ZOOM){if(m.noZoom===!0)return;F=E.DOLLY,v.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.PAN){if(m.noPan===!0)return;F=E.PAN,r.set(a.clientX,a.clientY)}document.addEventListener("mousemove",f,!1),document.addEventListener("mouseup",g,!1),m.dispatchEvent(J)