PolygonPipeline-83fb62b0.js 11 KB

1
  1. define(["exports","./Matrix2-ccd5b911","./RuntimeError-346a3079","./ComponentDatatype-93750d1a","./when-4bbc8319","./EllipsoidRhumbLine-aa9e6266","./GeometryAttribute-c30799b8","./WebGLConstants-1c8239cc"],function(e,L,t,D,G,O,T,n){"use strict";var r=i,a=i;function i(e,t,n){n=n||2;var r,a,i,u,x,o=t&&t.length,s=o?t[0]*n:e.length,p=y(e,0,s,n,!0),h=[];if(!p||p.next===p.prev)return h;if(o&&(p=function(e,t,n,r){var a,i,u,x,o=[];for(a=0,i=t.length;a<i;a++)u=t[a]*r,x=a<i-1?t[a+1]*r:e.length,(x=y(e,u,x,r,!1))===x.next&&(x.steiner=!0),o.push(function(e){var t=e,n=e;for(;(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next,t!==e;);return n}(x));for(o.sort(m),a=0;a<o.length;a++)n=function(e,t){var n=function(e,t){var n,r=t,a=e.x,i=e.y,u=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var x=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(x<=a&&u<x){if((u=x)===a){if(i===r.y)return r;if(i===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}}while(r=r.next,r!==t);if(!n)return null;if(a===u)return n;var o,s=n,p=n.x,h=n.y,f=1/0;r=n;for(;a>=r.x&&r.x>=p&&a!==r.x&&g(i<h?a:u,i,p,h,i<h?u:a,i,r.x,r.y)&&(o=Math.abs(i-r.y)/(a-r.x),w(r,e)&&(o<f||o===f&&(r.x>n.x||r.x===n.x&&function(e,t){return b(e.prev,e,t.prev)<0&&b(t.next,e,e.next)<0}(n,r)))&&(n=r,f=o)),r=r.next,r!==s;);return n}(e,t);if(!n)return t;var r=E(n,e),e=c(n,n.next);return c(r,r.next),t===n?e:t}(o[a],n),n=c(n,n.next);return n}(e,t,p,n)),e.length>80*n){for(var f=r=e[0],l=a=e[1],v=n;v<s;v+=n)(i=e[v])<f&&(f=i),(u=e[v+1])<l&&(l=u),r<i&&(r=i),a<u&&(a=u);x=0!==(x=Math.max(r-f,a-l))?1/x:0}return d(p,h,n,f,l,x),h}function y(e,t,n,r,a){var i,u;if(a===0<M(e,t,n,r))for(i=t;i<n;i+=r)u=x(i,e[i],e[i+1],u);else for(i=n-r;t<=i;i-=r)u=x(i,e[i],e[i+1],u);return u&&p(u,u.next)&&(f(u),u=u.next),u}function c(e,t){if(!e)return e;t=t||e;var n,r=e;do{if(n=!1,r.steiner||!p(r,r.next)&&0!==b(r.prev,r,r.next))r=r.next;else{if(f(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function d(e,t,n,r,a,i,u){if(e){!u&&i&&function(e,t,n,r){var a=e;for(;null===a.z&&(a.z=C(a.x,a.y,t,n,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next,a!==e;);a.prevZ.nextZ=null,a.prevZ=null,function(e){var t,n,r,a,i,u,x,o,s=1;do{for(n=e,i=e=null,u=0;n;){for(u++,r=n,t=x=0;t<s&&(x++,r=r.nextZ);t++);for(o=s;0<x||0<o&&r;)0!==x&&(0===o||!r||n.z<=r.z)?(n=(a=n).nextZ,x--):(r=(a=r).nextZ,o--),i?i.nextZ=a:e=a,a.prevZ=i,i=a;n=r}}while(i.nextZ=null,s*=2,1<u)}(a)}(e,r,a,i);for(var x,o,s=e;e.prev!==e.next;)if(x=e.prev,o=e.next,i?function(e,t,n,r){var a=e.prev,i=e,u=e.next;if(0<=b(a,i,u))return!1;var x=(a.x<i.x?a.x<u.x?a:u:i.x<u.x?i:u).x,o=(a.y<i.y?a.y<u.y?a:u:i.y<u.y?i:u).y,s=(a.x>i.x?a.x>u.x?a:u:i.x>u.x?i:u).x,p=(a.y>i.y?a.y>u.y?a:u:i.y>u.y?i:u).y,h=C(x,o,t,n,r),f=C(s,p,t,n,r),l=e.prevZ,v=e.nextZ;for(;l&&l.z>=h&&v&&v.z<=f;){if(l!==e.prev&&l!==e.next&&g(a.x,a.y,i.x,i.y,u.x,u.y,l.x,l.y)&&0<=b(l.prev,l,l.next))return!1;if(l=l.prevZ,v!==e.prev&&v!==e.next&&g(a.x,a.y,i.x,i.y,u.x,u.y,v.x,v.y)&&0<=b(v.prev,v,v.next))return!1;v=v.nextZ}for(;l&&l.z>=h;){if(l!==e.prev&&l!==e.next&&g(a.x,a.y,i.x,i.y,u.x,u.y,l.x,l.y)&&0<=b(l.prev,l,l.next))return!1;l=l.prevZ}for(;v&&v.z<=f;){if(v!==e.prev&&v!==e.next&&g(a.x,a.y,i.x,i.y,u.x,u.y,v.x,v.y)&&0<=b(v.prev,v,v.next))return!1;v=v.nextZ}return!0}(e,r,a,i):function(e){var t=e.prev,n=e,r=e.next;if(0<=b(t,n,r))return!1;var a=e.next.next;for(;a!==e.prev;){if(g(t.x,t.y,n.x,n.y,r.x,r.y,a.x,a.y)&&0<=b(a.prev,a,a.next))return!1;a=a.next}return!0}(e))t.push(x.i/n),t.push(e.i/n),t.push(o.i/n),f(e),e=o.next,s=o.next;else if((e=o)===s){u?1===u?d(e=function(e,t,n){var r=e;do{var a=r.prev,i=r.next.next}while(!p(a,i)&&h(a,r,r.next,i)&&w(a,i)&&w(i,a)&&(t.push(a.i/n),t.push(r.i/n),t.push(i.i/n),f(r),f(r.next),r=e=i),r=r.next,r!==e);return c(r)}(c(e),t,n),t,n,r,a,i,2):2===u&&function(e,t,n,r,a,i){var u=e;do{for(var x=u.next.next;x!==u.prev;){if(u.i!==x.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&h(n,n.next,e,t))return!0}while(n=n.next,n!==e);return!1}(e,t)&&(w(e,t)&&w(t,e)&&function(e,t){var n=e,r=!1,a=(e.x+t.x)/2,i=(e.y+t.y)/2;for(;n.y>i!=n.next.y>i&&n.next.y!==n.y&&a<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next,n!==e;);return r}(e,t)&&(b(e.prev,e,t.prev)||b(e,t.prev,t))||p(e,t)&&0<b(e.prev,e,e.next)&&0<b(t.prev,t,t.next))}(u,x)){var o=E(u,x);return u=c(u,u.next),o=c(o,o.next),d(u,t,n,r,a,i),d(o,t,n,r,a,i)}x=x.next}}while(u=u.next,u!==e)}(e,t,n,r,a,i):d(c(e),t,n,r,a,i,1);break}}}function m(e,t){return e.x-t.x}function C(e,t,n,r,a){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*a)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*a)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function g(e,t,n,r,a,i,u,x){return 0<=(a-u)*(t-x)-(e-u)*(i-x)&&0<=(e-u)*(r-x)-(n-u)*(t-x)&&0<=(n-u)*(i-x)-(a-u)*(r-x)}function b(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function p(e,t){return e.x===t.x&&e.y===t.y}function h(e,t,n,r){var a=s(b(e,t,n)),i=s(b(e,t,r)),u=s(b(n,r,e)),x=s(b(n,r,t));return a!==i&&u!==x||(0===a&&o(e,n,t)||(0===i&&o(e,r,t)||(0===u&&o(n,e,r)||!(0!==x||!o(n,t,r)))))}function o(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function s(e){return 0<e?1:e<0?-1:0}function w(e,t){return b(e.prev,e,e.next)<0?0<=b(e,t,e.next)&&0<=b(e,e.prev,t):b(e,t,e.prev)<0||b(e,e.next,t)<0}function E(e,t){var n=new u(e.i,e.x,e.y),r=new u(t.i,t.x,t.y),a=e.next,i=t.prev;return(e.next=t).prev=e,(n.next=a).prev=n,(r.next=n).prev=r,(i.next=r).prev=i,r}function x(e,t,n,r){n=new u(e,t,n);return r?(n.next=r.next,(n.prev=r).next.prev=n,r.next=n):(n.prev=n).next=n,n}function f(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function u(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function M(e,t,n,r){for(var a=0,i=t,u=n-r;i<n;i+=r)a+=(e[u]-e[i])*(e[i+1]+e[u+1]),u=i;return a}i.deviation=function(e,t,n,r){var a=t&&t.length,i=a?t[0]*n:e.length,u=Math.abs(M(e,0,i,n));if(a)for(var x=0,o=t.length;x<o;x++){var s=t[x]*n,p=x<o-1?t[x+1]*n:e.length;u-=Math.abs(M(e,s,p,n))}for(var h=0,x=0;x<r.length;x+=3){var f=r[x]*n,l=r[x+1]*n,v=r[x+2]*n;h+=Math.abs((e[f]-e[v])*(e[1+l]-e[1+f])-(e[f]-e[l])*(e[1+v]-e[1+f]))}return 0===u&&0===h?0:Math.abs((h-u)/u)},i.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,a=0;a<e.length;a++){for(var i=0;i<e[a].length;i++)for(var u=0;u<t;u++)n.vertices.push(e[a][i][u]);0<a&&(r+=e[a-1].length,n.holes.push(r))}return n},r.default=a;var l={CLOCKWISE:n.WebGLConstants.CW,COUNTER_CLOCKWISE:n.WebGLConstants.CCW,validate:function(e){return e===l.CLOCKWISE||e===l.COUNTER_CLOCKWISE}},v=Object.freeze(l),Z=new L.Cartesian3,S=new L.Cartesian3,A={computeArea2D:function(e){for(var t=e.length,n=0,r=t-1,a=0;a<t;r=a++){var i=e[r],u=e[a];n+=i.x*u.y-u.x*i.y}return.5*n},computeWindingOrder2D:function(e){return 0<A.computeArea2D(e)?v.COUNTER_CLOCKWISE:v.CLOCKWISE},triangulate:function(e,t){e=L.Cartesian2.packArray(e);return r(e,t,2)}},W=new L.Cartesian3,P=new L.Cartesian3,I=new L.Cartesian3,z=new L.Cartesian3,R=new L.Cartesian3,B=new L.Cartesian3,N=new L.Cartesian3;A.computeSubdivision=function(e,t,n,r){r=G.defaultValue(r,D.CesiumMath.RADIANS_PER_DEGREE);for(var a=n.slice(0),i=t.length,u=new Array(3*i),x=0,o=0;o<i;o++){var s=t[o];u[x++]=s.x,u[x++]=s.y,u[x++]=s.z}for(var p=[],h={},f=e.maximumRadius,r=D.CesiumMath.chordLength(r,f),l=r*r;0<a.length;){var v,y,c=a.pop(),d=a.pop(),m=a.pop(),C=L.Cartesian3.fromArray(u,3*m,W),g=L.Cartesian3.fromArray(u,3*d,P),b=L.Cartesian3.fromArray(u,3*c,I),w=L.Cartesian3.multiplyByScalar(L.Cartesian3.normalize(C,z),f,z),E=L.Cartesian3.multiplyByScalar(L.Cartesian3.normalize(g,R),f,R),M=L.Cartesian3.multiplyByScalar(L.Cartesian3.normalize(b,B),f,B),Z=L.Cartesian3.magnitudeSquared(L.Cartesian3.subtract(w,E,N)),E=L.Cartesian3.magnitudeSquared(L.Cartesian3.subtract(E,M,N)),M=L.Cartesian3.magnitudeSquared(L.Cartesian3.subtract(M,w,N)),w=Math.max(Z,E,M);l<w?Z===w?(o=h[v=Math.min(m,d)+" "+Math.max(m,d)],G.defined(o)||(y=L.Cartesian3.add(C,g,N),L.Cartesian3.multiplyByScalar(y,.5,y),u.push(y.x,y.y,y.z),o=u.length/3-1,h[v]=o),a.push(m,o,c),a.push(o,d,c)):E===w?(o=h[v=Math.min(d,c)+" "+Math.max(d,c)],G.defined(o)||(y=L.Cartesian3.add(g,b,N),L.Cartesian3.multiplyByScalar(y,.5,y),u.push(y.x,y.y,y.z),o=u.length/3-1,h[v]=o),a.push(d,o,m),a.push(o,c,m)):M===w&&(o=h[v=Math.min(c,m)+" "+Math.max(c,m)],G.defined(o)||(y=L.Cartesian3.add(b,C,N),L.Cartesian3.multiplyByScalar(y,.5,y),u.push(y.x,y.y,y.z),o=u.length/3-1,h[v]=o),a.push(c,o,d),a.push(o,m,d)):(p.push(m),p.push(d),p.push(c))}return new T.Geometry({attributes:{position:new T.GeometryAttribute({componentDatatype:D.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:u})},indices:p,primitiveType:T.PrimitiveType.TRIANGLES})};var U=new L.Cartographic,_=new L.Cartographic,K=new L.Cartographic,V=new L.Cartographic;A.computeRhumbLineSubdivision=function(e,t,n,r){r=G.defaultValue(r,D.CesiumMath.RADIANS_PER_DEGREE);for(var a=n.slice(0),i=t.length,u=new Array(3*i),x=0,o=0;o<i;o++){var s=t[o];u[x++]=s.x,u[x++]=s.y,u[x++]=s.z}for(var p=[],h={},n=e.maximumRadius,f=D.CesiumMath.chordLength(r,n),l=new O.EllipsoidRhumbLine(void 0,void 0,e),v=new O.EllipsoidRhumbLine(void 0,void 0,e),y=new O.EllipsoidRhumbLine(void 0,void 0,e);0<a.length;){var c=a.pop(),d=a.pop(),m=a.pop(),C=L.Cartesian3.fromArray(u,3*m,W),g=L.Cartesian3.fromArray(u,3*d,P),b=L.Cartesian3.fromArray(u,3*c,I),w=e.cartesianToCartographic(C,U),E=e.cartesianToCartographic(g,_),M=e.cartesianToCartographic(b,K);l.setEndPoints(w,E);var Z=l.surfaceDistance;v.setEndPoints(E,M);C=v.surfaceDistance;y.setEndPoints(M,w);var S,A,z,R,g=y.surfaceDistance,b=Math.max(Z,C,g);f<b?Z===b?(o=h[S=Math.min(m,d)+" "+Math.max(m,d)],G.defined(o)||(A=l.interpolateUsingFraction(.5,V),z=.5*(w.height+E.height),R=L.Cartesian3.fromRadians(A.longitude,A.latitude,z,e,N),u.push(R.x,R.y,R.z),o=u.length/3-1,h[S]=o),a.push(m,o,c),a.push(o,d,c)):C===b?(o=h[S=Math.min(d,c)+" "+Math.max(d,c)],G.defined(o)||(A=v.interpolateUsingFraction(.5,V),z=.5*(E.height+M.height),R=L.Cartesian3.fromRadians(A.longitude,A.latitude,z,e,N),u.push(R.x,R.y,R.z),o=u.length/3-1,h[S]=o),a.push(d,o,m),a.push(o,c,m)):g===b&&(o=h[S=Math.min(c,m)+" "+Math.max(c,m)],G.defined(o)||(A=y.interpolateUsingFraction(.5,V),z=.5*(M.height+w.height),R=L.Cartesian3.fromRadians(A.longitude,A.latitude,z,e,N),u.push(R.x,R.y,R.z),o=u.length/3-1,h[S]=o),a.push(c,o,d),a.push(o,m,d)):(p.push(m),p.push(d),p.push(c))}return new T.Geometry({attributes:{position:new T.GeometryAttribute({componentDatatype:D.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:u})},indices:p,primitiveType:T.PrimitiveType.TRIANGLES})},A.scaleToGeodeticHeight=function(e,t,n,r){n=G.defaultValue(n,L.Ellipsoid.WGS84);var a=Z,i=S;if(t=G.defaultValue(t,0),r=G.defaultValue(r,!0),G.defined(e))for(var u=e.length,x=0;x<u;x+=3)L.Cartesian3.fromArray(e,x,i),r&&(i=n.scaleToGeodeticSurface(i,i)),0!==t&&(a=n.geodeticSurfaceNormal(i,a),L.Cartesian3.multiplyByScalar(a,t,a),L.Cartesian3.add(i,a,i)),e[x]=i.x,e[x+1]=i.y,e[x+2]=i.z;return e},e.PolygonPipeline=A,e.WindingOrder=v});