Comparing version 0.1.0 to 1.0.0
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-geo/ Version 0.1.0. Copyright 2016 Mike Bostock. | ||
// https://d3js.org/d3-geo/ Version 1.0.0. Copyright 2016 Mike Bostock. | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array")):"function"==typeof define&&define.amd?define(["exports","d3-array"],t):t(n.d3=n.d3||{},n.d3)}(this,function(n,t){"use strict";function r(){return new i}function i(){this.reset()}function e(n,t,r){var i=n.s=t+r,e=i-t,o=i-e;n.t=t-o+(r-e)}function o(n){return n>1?0:n<-1?hr:Math.acos(n)}function u(n){return n>1?dr:n<-1?-dr:Math.asin(n)}function c(n){return(n=br(n/2))*n}function f(){}function a(n,t){n&&Or.hasOwnProperty(n.type)&&Or[n.type](n,t)}function l(n,t,r){var i,e=-1,o=n.length-r;for(t.lineStart();++e<o;)i=n[e],t.point(i[0],i[1],i[2]);t.lineEnd()}function p(n,t){var r=-1,i=n.length;for(t.polygonStart();++r<i;)l(n[r],t,1);t.polygonEnd()}function s(n,t){n&&Rr.hasOwnProperty(n.type)?Rr[n.type](n,t):a(n,t)}function v(){Tr.point=h}function g(){d(Ot,Tt)}function h(n,t){Tr.point=d,Ot=n,Tt=t,n*=mr,t*=mr,Gt=n,Ft=jr(t=t/2+Er),It=br(t)}function d(n,t){n*=mr,t*=mr,t=t/2+Er;var r=n-Gt,i=r>=0?1:-1,e=i*r,o=jr(t),u=br(t),c=It*u,f=Ft*o+c*jr(e),a=c*i*br(e);Lt.add(Nr(a,f)),Gt=n,Ft=o,It=u}function E(n){return Rt?Rt.reset():(Rt=r(),Lt=r()),s(n,Tr),2*Rt}function S(n){return[Nr(n[1],n[0]),u(n[2])]}function y(n){var t=n[0],r=n[1],i=jr(r);return[i*jr(t),i*br(t),br(r)]}function m(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function M(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 x(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function N(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function j(n){var t=zr(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function w(n,t){Qt.push(Vt=[_t=n,Dt=n]),t<Bt&&(Bt=t),t>Ut&&(Ut=t)}function P(n,t){var r=y([n*mr,t*mr]);if(Jt){var i=M(Jt,r),e=[i[1],-i[0],0],o=M(e,i);j(o),o=S(o);var u,c=n-Zt,f=c>0?1:-1,a=o[0]*yr*f,l=Mr(c)>180;l^(f*Zt<a&&a<f*n)?(u=o[1]*yr,u>Ut&&(Ut=u)):(a=(a+360)%360-180,l^(f*Zt<a&&a<f*n)?(u=-o[1]*yr,u<Bt&&(Bt=u)):(t<Bt&&(Bt=t),t>Ut&&(Ut=t))),l?n<Zt?L(_t,n)>L(_t,Dt)&&(Dt=n):L(n,Dt)>L(_t,Dt)&&(_t=n):Dt>=_t?(n<_t&&(_t=n),n>Dt&&(Dt=n)):n>Zt?L(_t,n)>L(_t,Dt)&&(Dt=n):L(n,Dt)>L(_t,Dt)&&(_t=n)}else w(n,t);Jt=r,Zt=n}function A(){Gr.point=P}function C(){Vt[0]=_t,Vt[1]=Dt,Gr.point=w,Jt=null}function b(n,t){if(Jt){var r=n-Zt;Kt.add(Mr(r)>180?r+(r>0?360:-360):r)}else kt=n,Ht=t;Tr.point(n,t),P(n,t)}function q(){Tr.lineStart()}function z(){b(kt,Ht),Tr.lineEnd(),Mr(Kt)>vr&&(_t=-(Dt=180)),Vt[0]=_t,Vt[1]=Dt,Jt=null}function L(n,t){return(t-=n)<0?t+360:t}function R(n,t){return n[0]-t[0]}function O(n,t){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:t<n[0]||n[1]<t}function T(n){var t,i,e,o,u,c,f;if(Kt?Kt.reset():Kt=r(),Ut=Dt=-(_t=Bt=1/0),Qt=[],s(n,Gr),i=Qt.length){for(Qt.sort(R),t=1,e=Qt[0],u=[e];t<i;++t)o=Qt[t],O(e,o[0])||O(e,o[1])?(L(e[0],o[1])>L(e[0],e[1])&&(e[1]=o[1]),L(o[0],e[1])>L(e[0],e[1])&&(e[0]=o[0])):u.push(e=o);for(c=-(1/0),i=u.length-1,t=0,e=u[i];t<=i;e=o,++t)o=u[t],(f=L(e[1],o[0]))>c&&(c=f,_t=o[0],Dt=e[1])}return Qt=Vt=null,_t===1/0||Bt===1/0?[[NaN,NaN],[NaN,NaN]]:[[_t,Bt],[Dt,Ut]]}function G(n,t){n*=mr,t*=mr;var r=jr(t);F(r*jr(n),r*br(n),br(t))}function F(n,t,r){++Wt,Yt+=(n-Yt)/Wt,$t+=(t-$t)/Wt,nr+=(r-nr)/Wt}function I(){Fr.point=_}function _(n,t){n*=mr,t*=mr;var r=jr(t);ar=r*jr(n),lr=r*br(n),pr=br(t),Fr.point=B,F(ar,lr,pr)}function B(n,t){n*=mr,t*=mr;var r=jr(t),i=r*jr(n),e=r*br(n),o=br(t),u=Nr(zr((u=lr*o-pr*e)*u+(u=pr*i-ar*o)*u+(u=ar*e-lr*i)*u),ar*i+lr*e+pr*o);Xt+=u,tr+=u*(ar+(ar=i)),rr+=u*(lr+(lr=e)),ir+=u*(pr+(pr=o)),F(ar,lr,pr)}function D(){Fr.point=G}function U(){Fr.point=k}function Z(){H(cr,fr),Fr.point=G}function k(n,t){cr=n,fr=t,n*=mr,t*=mr,Fr.point=H;var r=jr(t);ar=r*jr(n),lr=r*br(n),pr=br(t),F(ar,lr,pr)}function H(n,t){n*=mr,t*=mr;var r=jr(t),i=r*jr(n),e=r*br(n),u=br(t),c=lr*u-pr*e,f=pr*i-ar*u,a=ar*e-lr*i,l=zr(c*c+f*f+a*a),p=ar*i+lr*e+pr*u,s=l&&-o(p)/l,v=Nr(l,p);er+=s*c,or+=s*f,ur+=s*a,Xt+=v,tr+=v*(ar+(ar=i)),rr+=v*(lr+(lr=e)),ir+=v*(pr+(pr=u)),F(ar,lr,pr)}function J(n){Wt=Xt=Yt=$t=nr=tr=rr=ir=er=or=ur=0,s(n,Fr);var t=er,r=or,i=ur,e=t*t+r*r+i*i;return e<gr&&(t=tr,r=rr,i=ir,Xt<vr&&(t=Yt,r=$t,i=nr),e=t*t+r*r+i*i,e<gr)?[NaN,NaN]:[Nr(r,t)*yr,u(i/zr(e))*yr]}function K(n){return function(){return n}}function Q(n,t){function r(r,i){return r=n(r,i),t(r[0],r[1])}return n.invert&&t.invert&&(r.invert=function(r,i){return r=t.invert(r,i),r&&n.invert(r[0],r[1])}),r}function V(n,t){return[n>hr?n-Sr:n<-hr?n+Sr:n,t]}function W(n,t,r){return(n%=Sr)?t||r?Q(Y(n),$(t,r)):Y(n):t||r?$(t,r):V}function X(n){return function(t,r){return t+=n,[t>hr?t-Sr:t<-hr?t+Sr:t,r]}}function Y(n){var t=X(n);return t.invert=X(-n),t}function $(n,t){function r(n,t){var r=jr(t),f=jr(n)*r,a=br(n)*r,l=br(t),p=l*i+f*e;return[Nr(a*o-p*c,f*i-l*e),u(p*o+a*c)]}var i=jr(n),e=br(n),o=jr(t),c=br(t);return r.invert=function(n,t){var r=jr(t),f=jr(n)*r,a=br(n)*r,l=br(t),p=l*o-a*c;return[Nr(a*o+l*c,f*i+p*e),u(p*i-f*e)]},r}function nn(n){function t(t){return t=n(t[0]*mr,t[1]*mr),t[0]*=yr,t[1]*=yr,t}return n=W(n[0]*mr,n[1]*mr,n.length>2?n[2]*mr:0),t.invert=function(t){return t=n.invert(t[0]*mr,t[1]*mr),t[0]*=yr,t[1]*=yr,t},t}function tn(n,t,r,i,e,o){if(r){var u=jr(t),c=br(t),f=i*r;null==e?(e=t+i*Sr,o=t-f/2):(e=rn(u,e),o=rn(u,o),(i>0?e<o:e>o)&&(e+=i*Sr));for(var a,l=e;i>0?l>o:l<o;l-=f)a=S([u,-c*jr(l),-c*br(l)]),n.point(a[0],a[1])}}function rn(n,t){t=y(t),t[0]-=n,j(t);var r=o(-t[1]);return((-t[2]<0?-r:r)+Sr-vr)%Sr}function en(){function n(n,t){r.push(n=i(n,t)),n[0]*=yr,n[1]*=yr}function t(){var n=e.apply(this,arguments),t=o.apply(this,arguments)*mr,f=u.apply(this,arguments)*mr;return r=[],i=W(-n[0]*mr,-n[1]*mr,0).invert,tn(c,t,f,1),n={type:"Polygon",coordinates:[r]},r=i=null,n}var r,i,e=K([0,0]),o=K(90),u=K(6),c={point:n};return t.center=function(n){return arguments.length?(e="function"==typeof n?n:K([+n[0],+n[1]]),t):e},t.radius=function(n){return arguments.length?(o="function"==typeof n?n:K(+n),t):o},t.precision=function(n){return arguments.length?(u="function"==typeof n?n:K(+n),t):u},t}function on(){var n,t=[];return{point:function(t,r){n.push([t,r])},lineStart:function(){t.push(n=[])},lineEnd:f,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var r=t;return t=[],n=null,r}}}function un(n,t,r,i,e,o){var u,c=n[0],f=n[1],a=t[0],l=t[1],p=0,s=1,v=a-c,g=l-f;if(u=r-c,v||!(u>0)){if(u/=v,v<0){if(u<p)return;u<s&&(s=u)}else if(v>0){if(u>s)return;u>p&&(p=u)}if(u=e-c,v||!(u<0)){if(u/=v,v<0){if(u>s)return;u>p&&(p=u)}else if(v>0){if(u<p)return;u<s&&(s=u)}if(u=i-f,g||!(u>0)){if(u/=g,g<0){if(u<p)return;u<s&&(s=u)}else if(g>0){if(u>s)return;u>p&&(p=u)}if(u=o-f,g||!(u<0)){if(u/=g,g<0){if(u>s)return;u>p&&(p=u)}else if(g>0){if(u<p)return;u<s&&(s=u)}return p>0&&(n[0]=c+p*v,n[1]=f+p*g),s<1&&(t[0]=c+s*v,t[1]=f+s*g),!0}}}}}function cn(n,t){return Mr(n[0]-t[0])<vr&&Mr(n[1]-t[1])<vr}function fn(n,t,r,i){this.x=n,this.z=t,this.o=r,this.e=i,this.v=!1,this.n=this.p=null}function an(n,t,r,i,e){var o,u,c=[],f=[];if(n.forEach(function(n){if(!((t=n.length-1)<=0)){var t,r,i=n[0],u=n[t];if(cn(i,u)){for(e.lineStart(),o=0;o<t;++o)e.point((i=n[o])[0],i[1]);return void e.lineEnd()}c.push(r=new fn(i,n,null,(!0))),f.push(r.o=new fn(i,null,r,(!1))),c.push(r=new fn(u,n,null,(!1))),f.push(r.o=new fn(u,null,r,(!0)))}}),c.length){for(f.sort(t),ln(c),ln(f),o=0,u=f.length;o<u;++o)f[o].e=r=!r;for(var a,l,p=c[0];;){for(var s=p,v=!0;s.v;)if((s=s.n)===p)return;a=s.z,e.lineStart();do{if(s.v=s.o.v=!0,s.e){if(v)for(o=0,u=a.length;o<u;++o)e.point((l=a[o])[0],l[1]);else i(s.x,s.n.x,1,e);s=s.n}else{if(v)for(a=s.p.z,o=a.length-1;o>=0;--o)e.point((l=a[o])[0],l[1]);else i(s.x,s.p.x,-1,e);s=s.p}s=s.o,a=s.z,v=!v}while(!s.v);e.lineEnd()}}}function ln(n){if(t=n.length){for(var t,r,i=0,e=n[0];++i<t;)e.n=r=n[i],r.p=e,e=r;e.n=r=n[0],r.p=e}}function pn(n,r,i,e){function o(t,o){return n<=t&&t<=i&&r<=o&&o<=e}function u(t,o,u,f){var l=0,p=0;if(null==t||(l=c(t,u))!==(p=c(o,u))||a(t,o)<0^u>0){do f.point(0===l||3===l?n:i,l>1?e:r);while((l=(l+u+4)%4)!==p)}else f.point(o[0],o[1])}function c(t,e){return Mr(t[0]-n)<vr?e>0?0:3:Mr(t[0]-i)<vr?e>0?2:1:Mr(t[1]-r)<vr?e>0?1:0:e>0?3:2}function f(n,t){return a(n.x,t.x)}function a(n,t){var r=c(n,1),i=c(t,1);return r!==i?r-i:0===r?t[1]-n[1]:1===r?n[0]-t[0]:2===r?n[1]-t[1]:t[0]-n[0]}return function(c){function a(n,t){o(n,t)&&A.point(n,t)}function l(){for(var t=0,r=0,i=E.length;r<i;++r)for(var o,u,c=E[r],f=1,a=c.length,l=c[0],p=l[0],s=l[1];f<a;++f)o=p,u=s,l=c[f],p=l[0],s=l[1],u<=e?s>e&&(p-o)*(e-u)>(s-u)*(n-o)&&++t:s<=e&&(p-o)*(e-u)<(s-u)*(n-o)&&--t;return t}function p(){A=C,d=[],E=[],P=!0}function s(){var n=l(),r=P&&n,i=(d=t.merge(d)).length;(r||i)&&(c.polygonStart(),r&&(c.lineStart(),u(null,null,1,c),c.lineEnd()),i&&an(d,f,n,u,c),c.polygonEnd()),A=c,d=E=S=null}function v(){b.point=h,E&&E.push(S=[]),w=!0,j=!1,x=N=NaN}function g(){d&&(h(y,m),M&&j&&C.rejoin(),d.push(C.result())),b.point=a,j&&A.lineEnd()}function h(t,u){var c=o(t,u);if(E&&S.push([t,u]),w)y=t,m=u,M=c,w=!1,c&&(A.lineStart(),A.point(t,u));else if(c&&j)A.point(t,u);else{var f=[x=Math.max(Xr,Math.min(Wr,x)),N=Math.max(Xr,Math.min(Wr,N))],a=[t=Math.max(Xr,Math.min(Wr,t)),u=Math.max(Xr,Math.min(Wr,u))];un(f,a,n,r,i,e)?(j||(A.lineStart(),A.point(f[0],f[1])),A.point(a[0],a[1]),c||A.lineEnd(),P=!1):c&&(A.lineStart(),A.point(t,u),P=!1)}x=t,N=u,j=c}var d,E,S,y,m,M,x,N,j,w,P,A=c,C=on(),b={point:a,lineStart:v,lineEnd:g,polygonStart:p,polygonEnd:s};return b}}function sn(){var n,t,r,i=0,e=0,o=960,u=500;return r={stream:function(r){return n&&t===r?n:n=pn(i,e,o,u)(t=r)},extent:function(c){return arguments.length?(i=+c[0][0],e=+c[0][1],o=+c[1][0],u=+c[1][1],n=t=null,r):[[i,e],[o,u]]}}}function vn(){Yr.point=hn,Yr.lineEnd=gn}function gn(){Yr.point=Yr.lineEnd=f}function hn(n,t){n*=mr,t*=mr,_r=n,Br=br(t),Dr=jr(t),Yr.point=dn}function dn(n,t){n*=mr,t*=mr;var r=br(t),i=jr(t),e=Mr(n-_r),o=jr(e),u=br(e),c=i*u,f=Dr*r-Br*i*o,a=Br*r+Dr*i*o;Ir.add(Nr(zr(c*c+f*f),a)),_r=n,Br=r,Dr=i}function En(n){return Ir?Ir.reset():Ir=r(),s(n,Yr),+Ir}function Sn(n,t){return $r[0]=n,$r[1]=t,En(ni)}function yn(n,r,i){var e=t.range(n,r-vr,i).concat(r);return function(n){return e.map(function(t){return[n,t]})}}function mn(n,r,i){var e=t.range(n,r-vr,i).concat(r);return function(n){return e.map(function(t){return[t,n]})}}function Mn(){function n(){return{type:"MultiLineString",coordinates:r()}}function r(){return t.range(wr(u/E)*E,o,E).map(v).concat(t.range(wr(l/S)*S,a,S).map(g)).concat(t.range(wr(e/h)*h,i,h).filter(function(n){return Mr(n%E)>vr}).map(p)).concat(t.range(wr(f/d)*d,c,d).filter(function(n){return Mr(n%S)>vr}).map(s))}var i,e,o,u,c,f,a,l,p,s,v,g,h=10,d=h,E=90,S=360,y=2.5;return n.lines=function(){return r().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[v(u).concat(g(a).slice(1),v(o).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.extentMajor(t).extentMinor(t):n.extentMinor()},n.extentMajor=function(t){return arguments.length?(u=+t[0][0],o=+t[1][0],l=+t[0][1],a=+t[1][1],u>o&&(t=u,u=o,o=t),l>a&&(t=l,l=a,a=t),n.precision(y)):[[u,l],[o,a]]},n.extentMinor=function(t){return arguments.length?(e=+t[0][0],i=+t[1][0],f=+t[0][1],c=+t[1][1],e>i&&(t=e,e=i,i=t),f>c&&(t=f,f=c,c=t),n.precision(y)):[[e,f],[i,c]]},n.step=function(t){return arguments.length?n.stepMajor(t).stepMinor(t):n.stepMinor()},n.stepMajor=function(t){return arguments.length?(E=+t[0],S=+t[1],n):[E,S]},n.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],n):[h,d]},n.precision=function(t){return arguments.length?(y=+t,p=yn(f,c,90),s=mn(e,i,y),v=yn(l,a,90),g=mn(u,o,y),n):y},n.extentMajor([[-180,-90+vr],[180,90-vr]]).extentMinor([[-180,-80-vr],[180,80+vr]])}function xn(n,t){var r=n[0]*mr,i=n[1]*mr,e=t[0]*mr,o=t[1]*mr,f=jr(i),a=br(i),l=jr(o),p=br(o),s=f*jr(r),v=f*br(r),g=l*jr(e),h=l*br(e),d=2*u(zr(c(o-i)+f*l*c(e-r))),E=br(d),S=d?function(n){var t=br(n*=d)/E,r=br(d-n)/E,i=r*s+t*g,e=r*v+t*h,o=r*a+t*p;return[Nr(e,i)*yr,Nr(o,zr(i*i+e*e))*yr]}:function(){return[r*yr,i*yr]};return S.distance=d,S}function Nn(n){return n}function jn(){ii.point=wn}function wn(n,t){ii.point=Pn,Ur=kr=n,Zr=Hr=t}function Pn(n,t){ri.add(Hr*n-kr*t),kr=n,Hr=t}function An(){Pn(Ur,Zr)}function Cn(n,t){n<ei&&(ei=n),n>ui&&(ui=n),t<oi&&(oi=t),t>ci&&(ci=t)}function bn(n,t){ai+=n,li+=t,++pi}function qn(){Si.point=zn}function zn(n,t){Si.point=Ln,bn(Qr=n,Vr=t)}function Ln(n,t){var r=n-Qr,i=t-Vr,e=zr(r*r+i*i);si+=e*(Qr+n)/2,vi+=e*(Vr+t)/2,gi+=e,bn(Qr=n,Vr=t)}function Rn(){Si.point=bn}function On(){Si.point=Gn}function Tn(){Fn(Jr,Kr)}function Gn(n,t){Si.point=Fn,bn(Jr=Qr=n,Kr=Vr=t)}function Fn(n,t){var r=n-Qr,i=t-Vr,e=zr(r*r+i*i);si+=e*(Qr+n)/2,vi+=e*(Vr+t)/2,gi+=e,e=Vr*n-Qr*t,hi+=e*(Qr+n),di+=e*(Vr+t),Ei+=3*e,bn(Qr=n,Vr=t)}function In(n){function t(t,r){n.moveTo(t+u,r),n.arc(t,r,u,0,Sr)}function r(t,r){n.moveTo(t,r),c.point=i}function i(t,r){n.lineTo(t,r)}function e(){c.point=t}function o(){n.closePath()}var u=4.5,c={point:t,lineStart:function(){c.point=r},lineEnd:e,polygonStart:function(){c.lineEnd=o},polygonEnd:function(){c.lineEnd=e,c.point=t},pointRadius:function(n){return u=n,c},result:f};return c}function _n(){function n(n,t){c.push("M",n,",",t,u)}function t(n,t){c.push("M",n,",",t),f.point=r}function r(n,t){c.push("L",n,",",t)}function i(){f.point=t}function e(){f.point=n}function o(){c.push("Z")}var u=Bn(4.5),c=[],f={point:n,lineStart:i,lineEnd:e,polygonStart:function(){f.lineEnd=o},polygonEnd:function(){f.lineEnd=e,f.point=n},pointRadius:function(n){return u=Bn(n),f},result:function(){if(c.length){var n=c.join("");return c=[],n}}};return f}function Bn(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Dn(){function n(n){return n&&("function"==typeof o&&e.pointRadius(+o.apply(this,arguments)),s(n,r(e))),e.result()}var t,r,i,e,o=4.5;return n.area=function(n){return s(n,r(ii)),ii.result()},n.bounds=function(n){return s(n,r(fi)),fi.result()},n.centroid=function(n){return s(n,r(Si)),Si.result()},n.projection=function(i){return arguments.length?(r=null==(t=i)?Nn:i.stream,n):t},n.context=function(t){return arguments.length?(e=null==(i=t)?new _n:new In(t),"function"!=typeof o&&e.pointRadius(o),n):i},n.pointRadius=function(t){return arguments.length?(o="function"==typeof t?t:(e.pointRadius(+t),+t),n):o},n.projection(null).context(null)}function Un(n,t){for(var r=t[0],i=t[1],e=[br(r),-jr(r),0],o=0,c=0,f=0,a=n.length;f<a;++f)if(p=(l=n[f]).length)for(var l,p,s=l[p-1],v=s[0],g=s[1]/2+Er,h=br(g),d=jr(g),E=0;E<p;++E,v=m,h=N,d=w,s=S){var S=l[E],m=S[0],x=S[1]/2+Er,N=br(x),w=jr(x),P=m-v,A=P>=0?1:-1,C=A*P,b=C>hr,q=h*N;if(yi.add(Nr(q*A*br(C),d*w+q*jr(C))),o+=b?P+A*Sr:P,b^v>=r^m>=r){var z=M(y(s),y(S));j(z);var L=M(e,z);j(L);var R=(b^P>=0?-1:1)*u(L[2]);(i>R||i===R&&(z[0]||z[1]))&&(c+=b^P>=0?1:-1)}}var O=(o<-vr||o<vr&&yi<-vr)^1&c;return yi.reset(),O}function Zn(n,r,i,e){return function(o,u){function c(t,r){var i=o(t,r);n(t=i[0],r=i[1])&&u.point(t,r)}function f(n,t){var r=o(n,t);E.point(r[0],r[1])}function a(){x.point=f,E.lineStart()}function l(){x.point=c,E.lineEnd()}function p(n,t){d.push([n,t]);var r=o(n,t);m.point(r[0],r[1])}function s(){m.lineStart(),d=[]}function v(){p(d[0][0],d[0][1]),m.lineEnd();var n,t,r,i,e=m.clean(),o=y.result(),c=o.length;if(d.pop(),g.push(d),d=null,c)if(1&e){if(r=o[0],(t=r.length-1)>0){for(M||(u.polygonStart(),M=!0),u.lineStart(),n=0;n<t;++n)u.point((i=r[n])[0],i[1]);u.lineEnd()}}else c>1&&2&e&&o.push(o.pop().concat(o.shift())),h.push(o.filter(kn))}var g,h,d,E=r(u),S=o.invert(e[0],e[1]),y=on(),m=r(y),M=!1,x={point:c,lineStart:a,lineEnd:l,polygonStart:function(){x.point=p,x.lineStart=s,x.lineEnd=v,h=[],g=[]},polygonEnd:function(){x.point=c,x.lineStart=a,x.lineEnd=l,h=t.merge(h);var n=Un(g,S);h.length?(M||(u.polygonStart(),M=!0),an(h,Hn,n,i,u)):n&&(M||(u.polygonStart(),M=!0),u.lineStart(),i(null,null,1,u),u.lineEnd()),M&&(u.polygonEnd(),M=!1),h=g=null},sphere:function(){u.polygonStart(),u.lineStart(),i(null,null,1,u),u.lineEnd(),u.polygonEnd()}};return x}}function kn(n){return n.length>1}function Hn(n,t){return((n=n.x)[0]<0?n[1]-dr-vr:dr-n[1])-((t=t.x)[0]<0?t[1]-dr-vr:dr-t[1])}function Jn(n){var t,r=NaN,i=NaN,e=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(o,u){var c=o>0?hr:-hr,f=Mr(o-r);Mr(f-hr)<vr?(n.point(r,i=(i+u)/2>0?dr:-dr),n.point(e,i),n.lineEnd(),n.lineStart(),n.point(c,i),n.point(o,i),t=0):e!==c&&f>=hr&&(Mr(r-e)<vr&&(r-=e*vr),Mr(o-c)<vr&&(o-=c*vr),i=Kn(r,i,o,u),n.point(e,i),n.lineEnd(),n.lineStart(),n.point(c,i),t=0),n.point(r=o,i=u),e=c},lineEnd:function(){n.lineEnd(),r=i=NaN},clean:function(){return 2-t}}}function Kn(n,t,r,i){var e,o,u=br(n-r);return Mr(u)>vr?xr((br(t)*(o=jr(i))*br(r)-br(i)*(e=jr(t))*br(n))/(e*o*u)):(t+i)/2}function Qn(n,t,r,i){var e;if(null==n)e=r*dr,i.point(-hr,e),i.point(0,e),i.point(hr,e),i.point(hr,0),i.point(hr,-e),i.point(0,-e),i.point(-hr,-e),i.point(-hr,0),i.point(-hr,e);else if(Mr(n[0]-t[0])>vr){var o=n[0]<t[0]?hr:-hr;e=r*o/2,i.point(-o,e),i.point(0,e),i.point(o,e)}else i.point(t[0],t[1])}function Vn(n,t){function r(r,i,e,o){tn(o,n,t,e,r,i)}function i(n,t){return jr(n)*jr(t)>c}function e(n){var t,r,e,c,l;return{lineStart:function(){c=e=!1,l=1},point:function(p,s){var v,g=[p,s],h=i(p,s),d=f?h?0:u(p,s):h?u(p+(p<0?hr:-hr),s):0;if(!t&&(c=e=h)&&n.lineStart(),h!==e&&(v=o(t,g),(cn(t,v)||cn(g,v))&&(g[0]+=vr,g[1]+=vr,h=i(g[0],g[1]))),h!==e)l=0,h?(n.lineStart(),v=o(g,t),n.point(v[0],v[1])):(v=o(t,g),n.point(v[0],v[1]),n.lineEnd()),t=v;else if(a&&t&&f^h){var E;d&r||!(E=o(g,t,!0))||(l=0,f?(n.lineStart(),n.point(E[0][0],E[0][1]),n.point(E[1][0],E[1][1]),n.lineEnd()):(n.point(E[1][0],E[1][1]),n.lineEnd(),n.lineStart(),n.point(E[0][0],E[0][1])))}!h||t&&cn(t,g)||n.point(g[0],g[1]),t=g,e=h,r=d},lineEnd:function(){e&&n.lineEnd(),t=null},clean:function(){return l|(c&&e)<<1}}}function o(n,t,r){var i=y(n),e=y(t),o=[1,0,0],u=M(i,e),f=m(u,u),a=u[0],l=f-a*a;if(!l)return!r&&n;var p=c*f/l,s=-c*a/l,v=M(o,u),g=N(o,p),h=N(u,s);x(g,h);var d=v,E=m(g,d),j=m(d,d),w=E*E-j*(m(g,g)-1);if(!(w<0)){var P=zr(w),A=N(d,(-E-P)/j);if(x(A,g),A=S(A),!r)return A;var C,b=n[0],q=t[0],z=n[1],L=t[1];q<b&&(C=b,b=q,q=C);var R=q-b,O=Mr(R-hr)<vr,T=O||R<vr;if(!O&&L<z&&(C=z,z=L,L=C),T?O?z+L>0^A[1]<(Mr(A[0]-b)<vr?z:L):z<=A[1]&&A[1]<=L:R>hr^(b<=A[0]&&A[0]<=q)){var G=N(d,(-E+P)/j);return x(G,g),[A,S(G)]}}}function u(t,r){var i=f?n:hr-n,e=0;return t<-i?e|=1:t>i&&(e|=2),r<-i?e|=4:r>i&&(e|=8),e}var c=jr(n),f=c>0,a=Mr(c)>vr;return Zn(i,e,r,f?[0,-n]:[-hr,n-hr])}function Wn(n){return{stream:Xn(n)}}function Xn(n){function t(){}var r=t.prototype=Object.create(Yn.prototype);for(var i in n)r[i]=n[i];return function(n){var r=new t;return r.stream=n,r}}function Yn(){}function $n(n,t){return+t?tt(n,t):nt(n)}function nt(n){return Xn({point:function(t,r){t=n(t,r),this.stream.point(t[0],t[1])}})}function tt(n,t){function r(i,e,o,c,f,a,l,p,s,v,g,h,d,E){var S=l-i,y=p-e,m=S*S+y*y;if(m>4*t&&d--){var M=c+v,x=f+g,N=a+h,j=zr(M*M+x*x+N*N),w=u(N/=j),P=Mr(Mr(N)-1)<vr||Mr(o-s)<vr?(o+s)/2:Nr(x,M),A=n(P,w),C=A[0],b=A[1],q=C-i,z=b-e,L=y*q-S*z;(L*L/m>t||Mr((S*q+y*z)/m-.5)>.3||c*v+f*g+a*h<xi)&&(r(i,e,o,c,f,a,C,b,P,M/=j,x/=j,N,d,E),E.point(C,b),r(C,b,P,M,x,N,l,p,s,v,g,h,d,E))}}return function(t){function i(r,i){r=n(r,i),t.point(r[0],r[1])}function e(){E=NaN,N.point=o,t.lineStart()}function o(i,e){var o=y([i,e]),u=n(i,e);r(E,S,d,m,M,x,E=u[0],S=u[1],d=i,m=o[0],M=o[1],x=o[2],Mi,t),t.point(E,S)}function u(){N.point=i,t.lineEnd()}function c(){e(),N.point=f,N.lineEnd=a}function f(n,t){o(l=n,t),p=E,s=S,v=m,g=M,h=x,N.point=o}function a(){r(E,S,d,m,M,x,p,s,l,v,g,h,Mi,t),N.lineEnd=u,u()}var l,p,s,v,g,h,d,E,S,m,M,x,N={point:i,lineStart:e,lineEnd:u,polygonStart:function(){t.polygonStart(),N.lineStart=c},polygonEnd:function(){t.polygonEnd(),N.lineStart=e}};return N}}function rt(n){return it(function(){return n})()}function it(n){function t(n){return n=l(n[0]*mr,n[1]*mr),[n[0]*d+c,f-n[1]*d]}function r(n){return n=l.invert((n[0]-c)/d,(f-n[1])/d),n&&[n[0]*yr,n[1]*yr]}function i(n,t){return n=u(n,t),[n[0]*d+c,f-n[1]*d]}function e(){l=Q(a=W(M,x,N),u);var n=u(y,m);return c=E-n[0]*d,f=S+n[1]*d,o()}function o(){return g=h=null,t}var u,c,f,a,l,p,s,v,g,h,d=150,E=480,S=250,y=0,m=0,M=0,x=0,N=0,j=null,w=mi,P=null,A=Nn,C=.5,b=$n(i,C);return t.stream=function(n){return g&&h===n?g:g=Ni(w(a,b(A(h=n))))},t.clipAngle=function(n){return arguments.length?(w=+n?Vn(j=n*mr,6*mr):(j=null,mi),o()):j*yr},t.clipExtent=function(n){return arguments.length?(A=null==n?(P=p=s=v=null,Nn):pn(P=+n[0][0],p=+n[0][1],s=+n[1][0],v=+n[1][1]),o()):null==P?null:[[P,p],[s,v]]},t.scale=function(n){return arguments.length?(d=+n,e()):d},t.translate=function(n){return arguments.length?(E=+n[0],S=+n[1],e()):[E,S]},t.center=function(n){return arguments.length?(y=n[0]%360*mr,m=n[1]%360*mr,e()):[y*yr,m*yr]},t.rotate=function(n){return arguments.length?(M=n[0]%360*mr,x=n[1]%360*mr,N=n.length>2?n[2]%360*mr:0,e()):[M*yr,x*yr,N*yr]},t.precision=function(n){return arguments.length?(b=$n(i,C=n*n),o()):zr(C)},function(){return u=n.apply(this,arguments),t.invert=u.invert&&r,e()}}function et(n){var t=0,r=hr/3,i=it(n),e=i(t,r);return e.parallels=function(n){return arguments.length?i(t=n[0]*mr,r=n[1]*mr):[t*yr,r*yr]},e}function ot(n,t){function r(n,t){var r=zr(o-2*e*br(t))/e;return[r*br(n*=e),c-r*jr(n)]}var i=br(n),e=(i+br(t))/2,o=1+i*(2*e-i),c=zr(o)/e;return r.invert=function(n,t){var r=c-t;return[Nr(n,r)/e,u((o-(n*n+r*r)*e*e)/(2*e))]},r}function ut(){return et(ot).scale(151).translate([480,347])}function ct(){return ut().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function ft(n){var t=n.length;return{point:function(r,i){for(var e=-1;++e<t;)n[e].point(r,i)},sphere:function(){for(var r=-1;++r<t;)n[r].sphere()},lineStart:function(){for(var r=-1;++r<t;)n[r].lineStart()},lineEnd:function(){for(var r=-1;++r<t;)n[r].lineEnd()},polygonStart:function(){for(var r=-1;++r<t;)n[r].polygonStart()},polygonEnd:function(){for(var r=-1;++r<t;)n[r].polygonEnd()}}}function at(){function n(n){var t=n[0],r=n[1];return u=null,i.point(t,r),u||(e.point(t,r),u)||(o.point(t,r),u)}var t,r,i,e,o,u,c=ct(),f=ut().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ut().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,t){u=[n,t]}};return n.invert=function(n){var t=c.scale(),r=c.translate(),i=(n[0]-r[0])/t,e=(n[1]-r[1])/t;return(e>=.12&&e<.234&&i>=-.425&&i<-.214?f:e>=.166&&e<.234&&i>=-.214&&i<-.115?a:c).invert(n)},n.stream=function(n){return t&&r===n?t:t=ft([c.stream(r=n),f.stream(n),a.stream(n)])},n.precision=function(t){return arguments.length?(c.precision(t),f.precision(t),a.precision(t),n):c.precision()},n.scale=function(t){return arguments.length?(c.scale(t),f.scale(.35*t),a.scale(t),n.translate(c.translate())):c.scale()},n.translate=function(t){if(!arguments.length)return c.translate();var r=c.scale(),u=+t[0],p=+t[1];return i=c.translate(t).clipExtent([[u-.455*r,p-.238*r],[u+.455*r,p+.238*r]]).stream(l),e=f.translate([u-.307*r,p+.201*r]).clipExtent([[u-.425*r+vr,p+.12*r+vr],[u-.214*r-vr,p+.234*r-vr]]).stream(l),o=a.translate([u-.205*r,p+.212*r]).clipExtent([[u-.214*r+vr,p+.166*r+vr],[u-.115*r-vr,p+.234*r-vr]]).stream(l),n},n.scale(1070)}function lt(n){return function(t,r){var i=jr(t),e=jr(r),o=n(i*e);return[o*e*br(t),o*br(r)]}}function pt(n){return function(t,r){var i=zr(t*t+r*r),e=n(i),o=br(e),c=jr(e);return[Nr(t*o,i*c),u(i&&r*o/i)]}}function st(){return rt(ji).scale(120).clipAngle(179.999)}function vt(){return rt(wi).scale(480/Sr).clipAngle(179.999)}function gt(n,t){return[n,Ar(Lr((dr+t)/2))]}function ht(){return dt(gt)}function dt(n){var t,r=rt(n),i=r.scale,e=r.translate,o=r.clipExtent;return r.scale=function(n){return arguments.length?(i(n),t&&r.clipExtent(null),r):i()},r.translate=function(n){return arguments.length?(e(n),t&&r.clipExtent(null),r):e()},r.clipExtent=function(n){if(!arguments.length)return t?null:o();if(t=null==n){var u=hr*i(),c=e();n=[[c[0]-u,c[1]-u],[c[0]+u,c[1]+u]]}return o(n),r},r.clipExtent(null).scale(961/Sr)}function Et(n){return Lr((dr+n)/2)}function St(n,t){function r(n,t){o>0?t<-dr+vr&&(t=-dr+vr):t>dr-vr&&(t=dr-vr);var r=o/Cr(Et(t),e);return[r*br(e*n),o-r*jr(e*n)]}var i=jr(n),e=n===t?br(n):Ar(i/jr(t))/Ar(Et(t)/Et(n)),o=i*Cr(Et(n),e)/e;return e?(r.invert=function(n,t){var r=o-t,i=qr(e)*zr(n*n+r*r);return[Nr(n,r)/e,2*xr(Cr(o/i,1/e))-dr]},r):gt}function yt(){return et(St)}function mt(n,t){return[n,t]}function Mt(){return rt(mt).scale(480/hr)}function xt(n,t){function r(n,t){var r=o-t,i=e*n;return[r*br(i),o-r*jr(i)]}var i=jr(n),e=n===t?br(n):(i-jr(t))/(t-n),o=i/e+n;return Mr(e)<vr?mt:(r.invert=function(n,t){var r=o-t;return[Nr(n,r)/e,o-qr(e)*zr(n*n+r*r)]},r)}function Nt(){return et(xt).scale(128).translate([480,280])}function jt(n,t){var r=jr(t),i=jr(n)*r;return[r*br(n)/i,br(t)/i]}function wt(){return rt(jt).scale(139).clipAngle(60)}function Pt(n,t){return[jr(t)*br(n),br(t)]}function At(){return rt(Pt).scale(240).clipAngle(90+vr)}function Ct(n,t){var r=jr(t),i=1+jr(n)*r;return[r*br(n)/i,br(t)/i]}function bt(){return rt(Ct).scale(240).clipAngle(142)}function qt(n,t){return[Ar(Lr((dr+t)/2)),-n]}function zt(){var n=dt(qt),t=n.center,r=n.rotate;return n.center=function(n){return arguments.length?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return arguments.length?r([n[0],n[1],n.length>2?n[2]+90:90]):(n=r(),[n[0],n[1],n[2]-90])},r([0,0,90])}i.prototype={constructor:i,reset:function(){this.s=this.t=0},add:function(n){e(sr,n,this.t),e(this,sr.s,this.s),this.s?this.t+=sr.t:this.s=sr.t},valueOf:function(){return this.s}};var Lt,Rt,Ot,Tt,Gt,Ft,It,_t,Bt,Dt,Ut,Zt,kt,Ht,Jt,Kt,Qt,Vt,Wt,Xt,Yt,$t,nr,tr,rr,ir,er,or,ur,cr,fr,ar,lr,pr,sr=new i,vr=1e-6,gr=1e-12,hr=Math.PI,dr=hr/2,Er=hr/4,Sr=2*hr,yr=180/hr,mr=hr/180,Mr=Math.abs,xr=Math.atan,Nr=Math.atan2,jr=Math.cos,wr=Math.ceil,Pr=Math.exp,Ar=Math.log,Cr=Math.pow,br=Math.sin,qr=Math.sign||function(n){return n>0?1:n<0?-1:0},zr=Math.sqrt,Lr=Math.tan,Rr={Feature:function(n,t){a(n.geometry,t)},FeatureCollection:function(n,t){for(var r=n.features,i=-1,e=r.length;++i<e;)a(r[i].geometry,t)}},Or={Sphere:function(n,t){t.sphere()},Point:function(n,t){n=n.coordinates,t.point(n[0],n[1],n[2])},MultiPoint:function(n,t){for(var r=n.coordinates,i=-1,e=r.length;++i<e;)n=r[i],t.point(n[0],n[1],n[2])},LineString:function(n,t){l(n.coordinates,t,0)},MultiLineString:function(n,t){for(var r=n.coordinates,i=-1,e=r.length;++i<e;)l(r[i],t,0)},Polygon:function(n,t){p(n.coordinates,t)},MultiPolygon:function(n,t){for(var r=n.coordinates,i=-1,e=r.length;++i<e;)p(r[i],t)},GeometryCollection:function(n,t){for(var r=n.geometries,i=-1,e=r.length;++i<e;)a(r[i],t)}},Tr={point:f,lineStart:f,lineEnd:f,polygonStart:function(){Lt.reset(),Tr.lineStart=v,Tr.lineEnd=g},polygonEnd:function(){var n=+Lt;Rt.add(n<0?Sr+n:n),this.lineStart=this.lineEnd=this.point=f},sphere:function(){Rt.add(Sr)}},Gr={point:w,lineStart:A,lineEnd:C,polygonStart:function(){Gr.point=b,Gr.lineStart=q,Gr.lineEnd=z,Kt.reset(),Tr.polygonStart()},polygonEnd:function(){Tr.polygonEnd(),Gr.point=w,Gr.lineStart=A,Gr.lineEnd=C,Lt<0?(_t=-(Dt=180),Bt=-(Ut=90)):Kt>vr?Ut=90:Kt<-vr&&(Bt=-90),Vt[0]=_t,Vt[1]=Dt}},Fr={sphere:f,point:G,lineStart:I,lineEnd:D,polygonStart:function(){Fr.lineStart=U,Fr.lineEnd=Z},polygonEnd:function(){Fr.lineStart=I,Fr.lineEnd=D}};V.invert=V;var Ir,_r,Br,Dr,Ur,Zr,kr,Hr,Jr,Kr,Qr,Vr,Wr=1e9,Xr=-Wr,Yr={sphere:f,point:f,lineStart:vn,lineEnd:f,polygonStart:f,polygonEnd:f},$r=[null,null],ni={type:"LineString",coordinates:$r},ti=r(),ri=r(),ii={point:f,lineStart:f,lineEnd:f,polygonStart:function(){ii.lineStart=jn,ii.lineEnd=An},polygonEnd:function(){ii.lineStart=ii.lineEnd=ii.point=f,ti.add(Mr(ri)),ri.reset()},result:function(){var n=ti/2;return ti.reset(),n}},ei=1/0,oi=ei,ui=-ei,ci=ui,fi={point:Cn,lineStart:f,lineEnd:f,polygonStart:f,polygonEnd:f,result:function(){var n=[[ei,oi],[ui,ci]];return ui=ci=-(oi=ei=1/0),n}},ai=0,li=0,pi=0,si=0,vi=0,gi=0,hi=0,di=0,Ei=0,Si={point:bn,lineStart:qn,lineEnd:Rn,polygonStart:function(){Si.lineStart=On,Si.lineEnd=Tn},polygonEnd:function(){Si.point=bn,Si.lineStart=qn,Si.lineEnd=Rn},result:function(){var n=Ei?[hi/Ei,di/Ei]:gi?[si/gi,vi/gi]:pi?[ai/pi,li/pi]:[NaN,NaN];return ai=li=pi=si=vi=gi=hi=di=Ei=0,n}},yi=r(),mi=Zn(function(){return!0},Jn,Qn,[-hr,-dr]);Yn.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Mi=16,xi=jr(30*mr),Ni=Xn({point:function(n,t){this.stream.point(n*mr,t*mr)}}),ji=lt(function(n){return zr(2/(1+n))});ji.invert=pt(function(n){return 2*u(n/2)});var wi=lt(function(n){return(n=o(n))&&n/br(n)});wi.invert=pt(function(n){return n}),gt.invert=function(n,t){return[n,2*xr(Pr(t))-dr]},mt.invert=mt,jt.invert=pt(xr),Pt.invert=pt(u),Ct.invert=pt(function(n){return 2+xr(n)}),qt.invert=function(n,t){return[-t,2*xr(Pr(n))-dr]},n.geoArea=E,n.geoBounds=T,n.geoCentroid=J,n.geoCircle=en,n.geoClipExtent=sn,n.geoDistance=Sn,n.geoGraticule=Mn,n.geoInterpolate=xn,n.geoLength=En,n.geoPath=Dn,n.geoAlbers=ct,n.geoAlbersUsa=at,n.geoAzimuthalEqualArea=st,n.geoAzimuthalEquidistant=vt,n.geoConicConformal=yt,n.geoConicEqualArea=ut,n.geoConicEquidistant=Nt,n.geoEquirectangular=Mt,n.geoGnomonic=wt,n.geoProjection=rt,n.geoProjectionMutator=it,n.geoMercator=ht,n.geoOrthographic=At,n.geoStereographic=bt,n.geoTransverseMercator=zt,n.geoRotation=nn,n.geoStream=s,n.geoTransform=Wn,Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-geo", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Shapes and calculators for spherical coordinates.", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-geo.js -c -m -o build/d3-geo.min.js", | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-geo.js ../d3.github.com/d3-geo.v0.1.js && cp build/d3-geo.min.js ../d3.github.com/d3-geo.v0.1.min.js && cd ../d3.github.com && git add d3-geo.v0.1.js d3-geo.v0.1.min.js && git commit -m \"d3-geo ${VERSION}\" && git push && cd - && zip -j build/d3-geo.zip -- LICENSE README.md build/d3-geo.js build/d3-geo.min.js" | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-geo.js ../d3.github.com/d3-geo.v1.js && cp build/d3-geo.min.js ../d3.github.com/d3-geo.v1.min.js && cd ../d3.github.com && git add d3-geo.v1.js d3-geo.v1.min.js && git commit -m \"d3-geo ${VERSION}\" && git push && cd - && zip -j build/d3-geo.zip -- LICENSE README.md build/d3-geo.js build/d3-geo.min.js" | ||
}, | ||
@@ -38,3 +38,3 @@ "dependencies": { | ||
"package-preamble": "0.0", | ||
"rollup": "0.31", | ||
"rollup": "0.33", | ||
"tape": "4", | ||
@@ -41,0 +41,0 @@ "topojson": "1", |
220
README.md
# d3-geo | ||
… | ||
Map projections are often naïvely regarded as simple point transformations. Spherical Mercator, for instance, can be implemented concisely as: | ||
```js | ||
function mercator(x, y) { | ||
return [x, Math.log(Math.tan(Math.PI / 4 + y / 2))]; | ||
} | ||
``` | ||
While this is a reasonable mathematical representation, it only works if your geometry is represented continuously as infinite point sets! Of course computers do not have infinite memory, and so we must instead work with discrete geometry such as polygons and polylines. | ||
Alas, discrete geometry makes the challenge of projecting from the sphere to the plane much harder. The edges of a spherical polygon are [geodesics](https://en.wikipedia.org/wiki/Geodesic) (also known as great arcs, or segments of a great circle), not straight lines. Even projected to the plane, geodesics remain curves in all map projections except [gnomonic](#geoGnomonic), and thus accurate projection requires interpolating along great arcs. D3 uses [adaptive interpolation](https://bl.ocks.org/mbostock/3795544), inspired by a popular [line simplification method](https://bost.ocks.org/mike/simplify/), to balance accuracy and performance. | ||
The projection of polygons and polylines must also deal with the topological differences between the sphere and the plane. Some projections require cutting geometry that [cross the antimeridian](https://bl.ocks.org/mbostock/3788999), while others require [clipping geometry to a great circle](http://bl.ocks.org/mbostock/3021474). Furthermore, spherical polygons require a winding order convention to determine which side of the polygon is the inside: D3 and [TopoJSON](https://github.com/mbostock/topojson) use clockwise winding. (Spherical polygons can be [larger than a hemisphere](https://bl.ocks.org/mbostock/6713736)! See also [ST_ForceRHR](http://www.postgis.org/docs/ST_ForceRHR.html) in PostGIS.) | ||
D3’s approach affords great expressiveness: you can choose the right projection, and the right aspect, for your data. D3 supports a wide variety of common and [unusual map projections](https://github.com/d3/d3-geo-projection). For more, see Part 2 of [The Toolmaker’s Guide](https://vimeo.com/106198518#t=20m0s). | ||
D3 uses [GeoJSON](http://geojson.org/geojson-spec.html) to represent geographic features in JavaScript. (See also [TopoJSON](/mbostock/topojson), an extension of GeoJSON that is significantly more compact and encodes topology.) To convert shapefiles to GeoJSON, use ogr2ogr, part of the [GDAL package](http://www.gdal.org/). In addition to [map projections](#projections), D3 includes useful [spherical shape generators](#spherical-shapes) and [spherical math utilities](#spherical-math). | ||
## Installing | ||
If you use NPM, `npm install d3-geo`. Otherwise, download the [latest release](https://github.com/d3/d3-geo/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-geo.v0.1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: | ||
If you use NPM, `npm install d3-geo`. Otherwise, download the [latest release](https://github.com/d3/d3-geo/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-geo.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: | ||
```html | ||
<script src="https://d3js.org/d3-array.v1.min.js"></script> | ||
<script src="https://d3js.org/d3-geo.v0.1.min.js"></script> | ||
<script src="https://d3js.org/d3-geo.v1.min.js"></script> | ||
<script> | ||
@@ -23,47 +39,50 @@ | ||
* [Math](#math) | ||
* [Shapes](#shapes) | ||
* [Spherical Math](#spherical-math) | ||
* [Spherical Shapes](#spherical-shapes) | ||
* [Paths](#paths) | ||
* [Projections](#projections) | ||
* [Transforms](#transforms) | ||
* [Streams](#streams) | ||
### Math | ||
### Spherical Math | ||
<a name="geoArea" href="#geoArea">#</a> d3.<b>geoArea</b>(<i>feature</i>) | ||
Returns the spherical area of the specified *feature* in [steradians](http://mathworld.wolfram.com/Steradian.html). See also [path.area](#path_area), which computes the projected area on the Cartesian plane. | ||
Returns the spherical area of the specified GeoJSON *feature* in [steradians](http://mathworld.wolfram.com/Steradian.html). See also [*path*.area](#path_area), which computes the projected planar area. | ||
<a name="geoBounds" href="#geoBounds">#</a> d3.<b>geoBounds</b>(<i>feature</i>) | ||
Returns the spherical bounding box for the specified *feature*. The bounding box is represented by a two-dimensional array: [[*left*, *bottom*], [*right*, *top*]], where *left* is the minimum longitude, *bottom* is the minimum latitude, *right* is maximum longitude, and *top* is the maximum latitude. | ||
Returns the [spherical bounding box](https://www.jasondavies.com/maps/bounds/) for the specified GeoJSON *feature*. The bounding box is represented by a two-dimensional array: [[*left*, *bottom*], [*right*, *top*]], where *left* is the minimum longitude, *bottom* is the minimum latitude, *right* is maximum longitude, and *top* is the maximum latitude. All coordinates are given in degrees. (Note that in projected planar coordinates, the minimum latitude is typically the maximum *y*-value, and the maximum latitude is typically the minimum *y*-value.) | ||
<a name="geoCentroid" href="#geoCentroid">#</a> d3.<b>geoCentroid</b>(<i>feature</i>) | ||
Returns the spherical centroid of the specified *feature*. See also [path.centroid](#path_centroid), which computes the projected centroid on the Cartesian plane. | ||
Returns the spherical centroid of the specified GeoJSON *feature*. See also [*path*.centroid](#path_centroid), which computes the projected planar centroid. | ||
<a name="geoDistance" href="#geoDistance">#</a> d3.<b>geoDistance</b>(<i>a</i>, <i>b</i>) | ||
Returns the great-arc distance in radians between the two location *a* and *b*. Each location must be specified as a two-element array [*longitude*, *latitude*] in degrees. | ||
Returns the great-arc distance in [radians](http://mathworld.wolfram.com/Radian.html) between the two points *a* and *b*. Each point must be specified as a two-element array [*longitude*, *latitude*] in degrees. | ||
<a name="geoLength" href="#geoLength">#</a> d3.<b>geoLength</b>(<i>feature</i>) | ||
Returns the great-arc length of the specified *feature* in [radians](http://mathworld.wolfram.com/Radian.html). For polygons, returns the perimeter of the exterior ring plus that of any interior rings. | ||
Returns the great-arc length of the specified GeoJSON *feature* in [radians](http://mathworld.wolfram.com/Radian.html). For polygons, returns the perimeter of the exterior ring plus that of any interior rings. | ||
<a name="geoInterpolate" href="#geoInterpolate">#</a> d3.<b>geoInterpolate</b>(<i>a</i>, <i>b</i>) | ||
Returns an interpolator given the two locations *a* and *b*. Each location must be specified as a two-element array [*longitude*, *latitude*] in degrees. The returned interpolator is a function which takes a single parameter *t* as input, where *t* ranges from 0 to 1. A value of 0 returns the location *a*, while a value of 1 returns the location *b*. Intermediate values interpolate from *a* to *b* along the spanning great arc. | ||
Returns an interpolator function given two points *a* and *b*. Each point must be specified as a two-element array [*longitude*, *latitude*] in degrees. The returned interpolator function takes a single argument *t*, where *t* is a number ranging from 0 to 1; a value of 0 returns the point *a*, while a value of 1 returns the point *b*. Intermediate values interpolate from *a* to *b* along the great arc that passes through both *a* and *b*. If *a* and *b* are antipodes, an arbitrary great arc is chosen. | ||
<a name="geoRotation" href="#geoRotation">#</a> d3.<b>geoRotation</b>(<i>angles</i>) | ||
Returns a rotation operator for the given *angles*, which must be a two- or three-element array of numbers [*lambda*, *phi*, *gamma*] specifying the rotation angles in degrees about [each spherical axis](http://bl.ocks.org/mbostock/4282586). If the rotation angle *gamma* is omitted, it defaults to 0. | ||
Returns a [rotation function](#_rotation) for the given *angles*, which must be a two- or three-element array of numbers [*lambda*, *phi*, *gamma*] specifying the rotation angles in degrees about [each spherical axis](http://bl.ocks.org/mbostock/4282586). (These correspond to [yaw, pitch and roll](http://en.wikipedia.org/wiki/Aircraft_principal_axes).) If the rotation angle *gamma* is omitted, it defaults to 0. See also [*projection*.rotate](#projection_rotate). | ||
<a name="_rotation" href="#_rotation">#</a> <i>rotation</i>(<i>location</i>) | ||
<a name="_rotation" href="#_rotation">#</a> <i>rotation</i>(<i>point</i>) | ||
Rotates the given *location* according to the angles specified for this rotation, in the order described above. The location must be specified as a two-element array [*longitude*, *latitude*] in degrees. Returns a new array representing the rotated location. | ||
Returns a new array [*longitude*, *latitude*] in degrees representing the rotated point of the given *point*. The point must be specified as a two-element array [*longitude*, *latitude*] in degrees. | ||
<a name="rotation_invert" href="#rotation_invert">#</a> <i>rotation</i>.<b>invert</b>(<i>location</i>) | ||
<a name="rotation_invert" href="#rotation_invert">#</a> <i>rotation</i>.<b>invert</b>(<i>point</i>) | ||
Rotates the given *location* according to the angles specified for this rotation, but with the order described above reversed. The location must be specified as a two-element array [*longitude*, *latitude*] in degrees. Returns a new array representing the rotated location. | ||
Returns a new array [*longitude*, *latitude*] in degrees representing the point of the given rotated *point*; the inverse of [*rotation*](#_rotation). The point must be specified as a two-element array [*longitude*, *latitude*] in degrees. | ||
### Shapes | ||
### Spherical Shapes | ||
To generate a [great arc](https://en.wikipedia.org/wiki/Great-circle_distance) (a segment of a great circle), simply pass a GeoJSON LineString geometry object to a [d3.geoPath](#geoPath). D3’s projections use great-arc interpolation for intermediate points, so there’s no need for a great arc shape generator. | ||
<a name="geoCircle" href="#geoCircle">#</a> d3.<b>geoCircle</b>() | ||
@@ -75,7 +94,7 @@ | ||
Returns a new GeoJSON geometry object of type “Polygon” approximating a circle on the surface of a sphere, with the current [center](#circle_center), [radius](#circle_radius) and [precision](#circle_precision). Any *arguments* are passed to the accessors. | ||
Returns a new GeoJSON geometry object of type “Polygon” approximating a circle on the surface of a sphere, with the current [center](#circle_center), [radius](#circle_radius) and [precision](#circle_precision). Any *arguments* are passed to the accessors. | ||
<a name="circle_center" href="#circle_center">#</a> <i>circle</i>.<b>center</b>([<i>center</i>]) | ||
If *center* is specified, sets the circle center to the specified location [*longitude*, *latitude*] in degrees, and returns this circle generator. The center may also be specified as a function; this function will be invoked whenever a circle is [generated](#_circle), being passed any arguments passed to the circle generator. If *center* is not specified, returns the current center accessor, which defaults to: | ||
If *center* is specified, sets the circle center to the specified point [*longitude*, *latitude*] in degrees, and returns this circle generator. The center may also be specified as a function; this function will be invoked whenever a circle is [generated](#_circle), being passed any arguments passed to the circle generator. If *center* is not specified, returns the current center accessor, which defaults to: | ||
@@ -112,15 +131,17 @@ ```js | ||
Constructs a feature generator for creating graticules. | ||
Constructs a feature generator for creating graticules: a uniform grid of [meridians](https://en.wikipedia.org/wiki/Meridian_\(geography\)) and [parallels](https://en.wikipedia.org/wiki/Circle_of_latitude) for showing projection distortion. The default graticule has meridians and parallels every 10° between ±80° latitude; for the polar regions, there are meridians every 90°. | ||
<img src="https://raw.githubusercontent.com/d3/d3-geo/master/img/graticule.png" width="480" height="360"> | ||
<a name="_graticule" href="#_graticule">#</a> <i>graticule</i>() | ||
Returns a MultiLineString geometry object representing all meridians and parallels for this graticule. | ||
Returns a GeoJSON MultiLineString geometry object representing all meridians and parallels for this graticule. | ||
<a name="graticule_lines" href="#graticule_lines">#</a> <i>graticule</i>.<b>lines</b>() | ||
Returns an array of LineString geometry objects, one for each meridian or parallel for this graticule. | ||
Returns an array of GeoJSON LineString geometry objects, one for each meridian or parallel for this graticule. | ||
<a name="graticule_outline" href="#graticule_outline">#</a> <i>graticule</i>.<b>outline</b>() | ||
Returns a Polygon geometry object representing the outline of this graticule, i.e. along the meridians and parallels defining its extent. | ||
Returns a GeoJSON Polygon geometry object representing the outline of this graticule, i.e. along the meridians and parallels defining its extent. | ||
@@ -155,83 +176,168 @@ <a name="graticule_extent" href="#graticule_extent">#</a> <i>graticule</i>.<b>extent</b>([<i>extent</i>]) | ||
### Projections | ||
### Paths | ||
The geographic path generator, [d3.geoPath](#geoPath), is similar to the shape generators in [d3-shape](https://github.com/d3/d3-shape): given a GeoJSON geometry or feature object, it generates an SVG path data string or [renders the path to a Canvas](http://bl.ocks.org/mbostock/3783604). Canvas is recommended for dynamic or interactive projections to improve performance. | ||
<a href="#geoPath" name="geoPath">#</a> d3.<b>geoPath</b>() | ||
… | ||
Creates a new geographic path generator with the default settings. | ||
<a href="_path" name="_path">#</a> <i>path</i>(<i>object</i>) | ||
<a href="_path" name="_path">#</a> <i>path</i>(<i>object</i>[, <i>arguments…</i>]) | ||
… | ||
Renders the given *object*, which may be any GeoJSON feature or geometry object: | ||
* Point - a single position. | ||
* MultiPoint - an array of positions. | ||
* LineString - an array of positions forming a continuous line. | ||
* MultiLineString - an array of arrays of positions forming several lines. | ||
* Polygon - an array of arrays of positions forming a polygon (possibly with holes). | ||
* MultiPolygon - a multidimensional array of positions forming multiple polygons. | ||
* GeometryCollection - an array of geometry objects. | ||
* Feature - a feature containing one of the above geometry objects. | ||
* FeatureCollection - an array of feature objects. | ||
The type *Sphere* is also supported, which is useful for rendering the outline of the globe; a sphere has no coordinates. Any additional *arguments* are passed along to the [pointRadius](#path_pointRadius) accessor. | ||
To display multiple features, combine them into a feature collection: | ||
```js | ||
svg.append("path") | ||
.datum({type: "FeatureCollection", features: features}) | ||
.attr("d", d3.geoPath()); | ||
``` | ||
Or use multiple path elements: | ||
```js | ||
svg.selectAll("path") | ||
.data(features) | ||
.enter().append("path") | ||
.attr("d", d3.geoPath()); | ||
``` | ||
Separate path elements are typically slower than a single path element. However, distinct path elements are useful for styling and interation (e.g., click or mouseover). Canvas rendering (see [*path*.context](#path_context)) is typically faster than SVG, but requires more effort to implement styling and interaction. | ||
<a href="#path_area" name="path_area">#</a> <i>path</i>.<b>area</b>(<i>object</i>) | ||
… | ||
Returns the projected planar area (typically in square pixels) for the specified GeoJSON *object*. Point, MultiPoint, LineString and MultiLineString features have zero area. For Polygon and MultiPolygon features, this method first computes the area of the exterior ring, and then subtracts the area of any interior holes. This method observes any clipping performed by the [projection](#path_projection); see [*projection*.clipAngle](#projection_clipAngle) and [*projection*.clipExtent](#projection_clipExtent). | ||
<a href="#path_bounds" name="path_bounds">#</a> <i>path</i>.<b>bounds</b>(<i>object</i>) | ||
… | ||
Returns the projected planar bounding box (typically in pixels) for the specified GeoJSON *object*. The bounding box is represented by a two-dimensional array: [[*x₀*, *y₀*], [*x₁*, *y₁*]], where *x₀* is the minimum *x*-coordinate, *y₀* is the minimum *y*-coordinate, *x₁* is maximum *x*-coordinate, and *y₁* is the maximum *y*-coordinate. This is handy for, say, zooming in to a particular feature. (Note that in projected planar coordinates, the minimum latitude is typically the maximum *y*-value, and the maximum latitude is typically the minimum *y*-value.) This method observes any clipping performed by the [projection](#path_projection); see [*projection*.clipAngle](#projection_clipAngle) and [*projection*.clipExtent](#projection_clipExtent). | ||
<a href="#path_centroid" name="path_centroid">#</a> <i>path</i>.<b>centroid</b>(<i>object</i>) | ||
… | ||
Returns the projected planar centroid (typically in pixels) for the specified GeoJSON *object*. This is handy for, say, labeling state or county boundaries, or displaying a symbol map. For example, a [noncontiguous cartogram](http://bl.ocks.org/mbostock/4055908) might scale each state around its centroid. This method observes any clipping performed by the [projection](#path_projection); see [*projection*.clipAngle](#projection_clipAngle) and [*projection*.clipExtent](#projection_clipExtent). | ||
<a href="#path_projection" name="path_projection">#</a><i>path</i>.<b>projection</b>([<i>projection</i>]) | ||
… | ||
If a *projection* is specified, sets the current projection to the specified projection. If *projection* is not specified, returns the current projection, which defaults to null. The null projection represents the identity transformation: the input geometry is not projected and is instead rendered directly in raw coordinates. This can be useful for fast rendering of [pre-projected geometry](http://bl.ocks.org/mbostock/5557726), or for fast rendering of the equirectangular projection. | ||
The given *projection* is typically one of D3’s built-in [geographic projections](#geoProjection); however, any object that exposes a [*projection*.stream](#projection_stream) function can be used, enabling the use of [custom projections](http://bl.ocks.org/mbostock/5663666). | ||
<a href="#path_context" name="path_context">#</a><i>path</i>.<b>context</b>([<i>context</i>]) | ||
… | ||
If *context* is specified, sets the current render context and returns the path generator. If the *context* is null, then the [path generator](#_path) will return an SVG path string; if the context is non-null, the path generator will instead call methods on the specified context to render geometry. The context must implement the following subset of the [CavnasRenderingContext2D API](https://www.w3.org/TR/2dcontext/#canvasrenderingcontext2d): | ||
* *context*.beginPath() | ||
* *context*.moveTo(*x*, *y*) | ||
* *context*.lineTo(*x*, *y*) | ||
* *context*.arc(*x*, *y*, *radius*, *startAngle*, *endAngle*) | ||
* *context*.closePath() | ||
If a *context* is not specified, returns the current render context which defaults to null. | ||
<a href="#path_pointRadius" name="path_pointRadius">#</a><i>path</i>.<b>pointRadius</b>([<i>radius</i>]) | ||
… | ||
If *radius* is specified, sets the radius used to display Point and MultiPoint features to the specified number. If *radius* is not specified, returns the current radius accessor, which defaults to 4.5. While the radius is commonly specified as a number constant, it may also be specified as a function which is computed per feature, being passed the any arguments passed to the [path generator](#_path). For example, if your GeoJSON data has additional properties, you might access those properties inside the radius function to vary the point size; alternatively, you could [d3.symbol](https://github.com/d3/d3-shape#symbols) and a [projection](#geoProjection) for greater flexibility. | ||
### Projections | ||
<a href="#geoProjection" name="geoProjection">#</a> d3.<b>geoProjection</b>(<i>project</i>) | ||
… | ||
Constructs a new projection from the specified *project* function. The *project* function takes the *longitude* and *latitude* of a given point in [radians](http://mathworld.wolfram.com/Radian.html), often referred to as *lambda* (λ) and *phi* (φ), and returns a two-element array [*x*, *y*] representing its unit projection. The *project* function does not need to scale or translate the point, as these are applied automatically by [*projection*.scale](#projection_scale), [*projection*.translate](#projection_translate), and [*projection*.center](#projection_center). Likewise, the *project* function does not need to perform any spherical rotation, as [*projection*.rotate](#projection_rotate) is applied prior to projection. | ||
<a href="#geoProjectionMutator" name="geoProjectionMutator">#</a> d3.<b>geoProjectionMutator</b>(<i>projectFactory</i>) | ||
For example, a spherical Mercator projection can be implemented as: | ||
… | ||
```js | ||
var mercator = d3.geoProjection(function(x, y) { | ||
return [x, Math.log(Math.tan(Math.PI / 4 + y / 2))]; | ||
}); | ||
``` | ||
If the *project* function exposes an *invert* method, the returned projection will also expose [*projection*.invert](#projection_invert). | ||
<a href="#geoProjectionMutator" name="geoProjectionMutator">#</a> d3.<b>geoProjectionMutator</b>(<i>factory</i>) | ||
Constructs a new projection from the specified *project* function *factory*, returning a *mutate* function to call whenever the raw projection function changes. For example, a conic projection typically has two configurable parallels. A suitable *factory* function would be: | ||
```js | ||
// y0 and y1 represent two parallels | ||
function conicFactory(y0, y1) { | ||
return function conic(x, y) { | ||
return […, …]; | ||
}; | ||
} | ||
``` | ||
Using d3.geoProjectionMutator, you can implement a standard projection that allows the parallels to be changed, reassigning the raw projection used internally by [d3.geoProjection](#geoProjection): | ||
```js | ||
function conic() { | ||
var y0 = 29.5, | ||
y1 = 45.5, | ||
mutate = d3.geoProjectionMutator(conicFactory), | ||
projection = mutate(y0, y1); | ||
projection.parallels = function(_) { | ||
return arguments.length ? mutate(y0 = +_[0], y1 = +_[1]) : [y0, y1]; | ||
}; | ||
return projection; | ||
} | ||
``` | ||
When creating a mutable projection, the *mutate* function is typically not exposed. | ||
<a href="#_projection" name="_projection">#</a> <i>projection</i>(<i>point</i>) | ||
… | ||
Returns a new array [*x*, *y*] (typically in pixels) representing the projected point of the given *point*. The point must be specified as a two-element array [*longitude*, *latitude*] in degrees. May return null if the specified *point* has no defined projected position, such as when the point is outside the clipping bounds of the projection. | ||
<a href="#projection_invert" name="projection_invert">#</a> <i>projection</i>.<b>invert</b>(<i>point</i>) | ||
… | ||
Returns a new array [*longitude*, *latitude*] in degrees representing the unprojected point of the given projected *point*. The point must be specified as a two-element array [*x*, *y*] (typically in pixels). May return null if the specified *point* has no defined projected position, such as when the point is outside the clipping bounds of the projection. | ||
This method is only defined on invertible projections. | ||
<a href="#projection_stream" name="projection_stream">#</a> <i>projection</i>.<b>stream</b>(<i>stream</i>) | ||
… | ||
Returns a [projection stream](#streams) for the specified output *stream*. Any input geometry is projected before being streamed to the output stream. A typical projection involves several geometry transformations: the input geometry is first converted to radians, rotated on three axes, clipped to the small circle or cut along the antimeridian, and lastly projected to the plane with adaptive resampling, scale and translation. | ||
<a href="#projection_clipAngle" name="projection_clipAngle">#</a> <i>projection</i>.<b>clipAngle</b>([<i>angle</i>]) | ||
… | ||
If *angle* is specified, sets the projection’s clipping circle radius to the specified angle in degrees and returns the projection. If *angle* is null, switches to [antimeridian cutting](http://bl.ocks.org/mbostock/3788999) rather than small-circle clipping. If *angle* is not specified, returns the current clip angle which defaults to null. Small-circle clipping is independent of viewport clipping via [*projection*.clipExtent](#projection_clipExtent). | ||
<a href="#projection_clipExtent" name="projection_clipExtent">#</a> <i>projection</i>.<b>clipExtent</b>([<i>extent</i>]) | ||
… | ||
If *extent* is specified, sets the projection’s viewport clip extent to the specified bounds in pixels and returns the projection. The *extent* bounds are specified as an array [[<i>x₀</i>, <i>y₀</i>], [<i>x₁</i>, <i>y₁</i>]], where <i>x₀</i> is the left-side of the viewport, <i>y₀</i> is the top, <i>x₁</i> is the right and <i>y₁</i> is the bottom. If *extent* is null, no viewport clipping is performed. If *extent* is not specified, returns the current viewport clip extent which defaults to null. Viewport clipping is independent of small-circle clipping via [*projection*.clipAngle](#projection_clipAngle). | ||
<a href="#projection_scale" name="projection_scale">#</a> <i>projection</i>.<b>scale</b>([<i>scale</i>]) | ||
… | ||
If *scale* is specified, sets the projection’s scale factor to the specified value and returns the projection. If *scale* is not specified, returns the current scale factor; the default scale is projection-specific. The scale factor corresponds linearly to the distance between projected points; however, absolute scale factors are not equivalent across projections. | ||
<a href="#projection_translate" name="projection_translate">#</a> <i>projection</i>.<b>translate</b>([<i>translate</i>]) | ||
… | ||
If *translate* is specified, sets the projection’s translation offset to the specified two-element array [<i>t<sub>x</sub></i>, <i>t<sub>y</sub></i>] and returns the projection. If *translate* is not specified, returns the current translation offset which defaults to [480, 250]. The translation offset determines the pixel coordinates of the projection’s [center](#projection_center). The default translation offset places ⟨0°,0°⟩ at the center of a 960×500 area. | ||
<a href="#projection_center" name="projection_center">#</a> <i>projection</i>.<b>center</b>([<i>center</i>]) | ||
… | ||
If *center* is specified, sets the projection’s center to the specified *center*, a two-element array of longitude and latitude in degrees and returns the projection. If *center* is not specified, returns the current center, which defaults to ⟨0°,0°⟩. | ||
<a href="#projection_rotate" name="projection_rotate">#</a> <i>projection</i>.<b>rotate</b>([<i>rotate</i>]) | ||
<a href="#projection_rotate" name="projection_rotate">#</a> <i>projection</i>.<b>rotate</b>([<i>angles</i>]) | ||
… | ||
If *rotation* is specified, sets the projection’s [three-axis rotation](http://bl.ocks.org/mbostock/4282586) to the specified *angles*, which must be a two- or three-element array of numbers [*lambda*, *phi*, *gamma*] specifying the rotation angles in degrees about [each spherical axis](http://bl.ocks.org/mbostock/4282586). (These correspond to [yaw, pitch and roll](http://en.wikipedia.org/wiki/Aircraft_principal_axes).) If the rotation angle *gamma* is omitted, it defaults to 0. See also [d3.geoRotation](#geoRotation). If *rotation* is not specified, returns the current rotation which defaults [0, 0, 0]. | ||
<a href="#projection_precision" name="projection_precision">#</a> <i>projection</i>.<b>precision</b>([<i>precision</i>]) | ||
… | ||
If *precision* is specified, sets the threshold for the projection’s [adaptive resampling](http://bl.ocks.org/mbostock/3795544) to the specified value in pixels and returns the projection. This value corresponds to the [Douglas–Peucker](http://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm) distance. If *precision* is not specified, returns the projection’s current resampling precision which defaults to √0.5 ≅ 0.70710… | ||
@@ -242,2 +348,4 @@ <a href="#geoAlbers" name="geoAlbers">#</a> d3.<b>geoAlbers</b>() | ||
See also [*conic*.parallels](#conic_parallels). | ||
<a href="#geoAlbersUsa" name="geoAlbersUsa">#</a> d3.<b>geoAlbersUsa</b>() | ||
@@ -259,2 +367,4 @@ | ||
See also [*conic*.parallels](#conic_parallels). | ||
<a href="#geoConicEqualArea" name="geoConicEqualArea">#</a> d3.<b>geoConicEqualArea</b>() | ||
@@ -264,2 +374,4 @@ | ||
See also [*conic*.parallels](#conic_parallels). | ||
<a href="#geoConicEquidistant" name="geoConicEquidistant">#</a> d3.<b>geoConicEquidistant</b>() | ||
@@ -269,2 +381,4 @@ | ||
See also [*conic*.parallels](#conic_parallels). | ||
<a href="#geoEquirectangular" name="geoEquirectangular">#</a> d3.<b>geoEquirectangular</b>() | ||
@@ -282,2 +396,4 @@ | ||
Defines a default [*projection*.clipExtent](#projection_clipExtent) such that the world is projected to a square, clipped to approximately ±85° latitude. | ||
<a href="#geoOrthographic" name="geoOrthographic">#</a> d3.<b>geoOrthographic</b>() | ||
@@ -295,2 +411,8 @@ | ||
Defines a default [*projection*.clipExtent](#projection_clipExtent) such that the world is projected to a square, clipped to approximately ±85° latitude. | ||
<a href="#conic_parallels" name="conic_parallels">#</a> <i>conic</i>.<b>parallels</b>([<i>parallels</i>]) | ||
… | ||
### Streams | ||
@@ -297,0 +419,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
297339
59
1
487