define(["./when-54335d57","./Rectangle-82621db8","./GeometryOffsetAttribute-718fa138","./Transforms-b51fdb37","./ComponentDatatype-1a100acd","./Check-24483042","./GeometryAttribute-02fdce7a","./GeometryAttributes-caa08d6c","./IndexDatatype-edb2f4d6","./Math-7a8129d6","./PolygonPipeline-be37706f","./RectangleGeometryLibrary-3593e470","./PixelFormat-d198afce","./WebGLConstants-95ceb4e9","./RuntimeError-88a32665","./EllipsoidRhumbLine-2550c0e1"],function(h,d,y,m,E,e,A,G,R,b,P,w,t,i,a,r){"use strict";var _=new m.BoundingSphere,v=new m.BoundingSphere,L=new d.Cartesian3,C=new d.Rectangle;function x(e,t){var i=e._ellipsoid,a=t.height,r=t.width,n=t.northCap,o=t.southCap,l=a,u=2,s=0,d=4;n&&(u-=1,l-=1,s+=1,d-=2),o&&(u-=1,l-=1,s+=1,d-=2),s+=u*r+2*l-d;var p,c=new Float64Array(3*s),f=0,g=0,h=L;if(n)w.RectangleGeometryLibrary.computePosition(t,i,!1,g,0,h),c[f++]=h.x,c[f++]=h.y,c[f++]=h.z;else for(p=0;p<r;p++)w.RectangleGeometryLibrary.computePosition(t,i,!1,g,p,h),c[f++]=h.x,c[f++]=h.y,c[f++]=h.z;for(p=r-1,g=1;g<a;g++)w.RectangleGeometryLibrary.computePosition(t,i,!1,g,p,h),c[f++]=h.x,c[f++]=h.y,c[f++]=h.z;if(g=a-1,!o)for(p=r-2;0<=p;p--)w.RectangleGeometryLibrary.computePosition(t,i,!1,g,p,h),c[f++]=h.x,c[f++]=h.y,c[f++]=h.z;for(p=0,g=a-2;0<g;g--)w.RectangleGeometryLibrary.computePosition(t,i,!1,g,p,h),c[f++]=h.x,c[f++]=h.y,c[f++]=h.z;for(var y=c.length/3*2,m=R.IndexDatatype.createTypedArray(c.length/3,y),b=0,_=0;_<c.length/3-1;_++)m[b++]=_,m[b++]=_+1;m[b++]=c.length/3-1,m[b++]=0;var v=new A.Geometry({attributes:new G.GeometryAttributes,primitiveType:A.PrimitiveType.LINES});return v.attributes.position=new A.GeometryAttribute({componentDatatype:E.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:c}),v.indices=m,v}function p(e){var t=(e=h.defaultValue(e,h.defaultValue.EMPTY_OBJECT)).rectangle,i=h.defaultValue(e.granularity,b.CesiumMath.RADIANS_PER_DEGREE),a=h.defaultValue(e.ellipsoid,d.Ellipsoid.WGS84),r=h.defaultValue(e.rotation,0),n=h.defaultValue(e.height,0),o=h.defaultValue(e.extrudedHeight,n);this._rectangle=d.Rectangle.clone(t),this._granularity=i,this._ellipsoid=a,this._surfaceHeight=Math.max(n,o),this._rotation=r,this._extrudedHeight=Math.min(n,o),this._offsetAttribute=e.offsetAttribute,this._workerName="createRectangleOutlineGeometry"}p.packedLength=d.Rectangle.packedLength+d.Ellipsoid.packedLength+5,p.pack=function(e,t,i){return i=h.defaultValue(i,0),d.Rectangle.pack(e._rectangle,t,i),i+=d.Rectangle.packedLength,d.Ellipsoid.pack(e._ellipsoid,t,i),i+=d.Ellipsoid.packedLength,t[i++]=e._granularity,t[i++]=e._surfaceHeight,t[i++]=e._rotation,t[i++]=e._extrudedHeight,t[i]=h.defaultValue(e._offsetAttribute,-1),t};var c=new d.Rectangle,f=d.Ellipsoid.clone(d.Ellipsoid.UNIT_SPHERE),g={rectangle:c,ellipsoid:f,granularity:void 0,height:void 0,rotation:void 0,extrudedHeight:void 0,offsetAttribute:void 0};p.unpack=function(e,t,i){t=h.defaultValue(t,0);var a=d.Rectangle.unpack(e,t,c);t+=d.Rectangle.packedLength;var r=d.Ellipsoid.unpack(e,t,f);t+=d.Ellipsoid.packedLength;var n=e[t++],o=e[t++],l=e[t++],u=e[t++],s=e[t];return h.defined(i)?(i._rectangle=d.Rectangle.clone(a,i._rectangle),i._ellipsoid=d.Ellipsoid.clone(r,i._ellipsoid),i._surfaceHeight=o,i._rotation=l,i._extrudedHeight=u,i._offsetAttribute=-1===s?void 0:s,i):(g.granularity=n,g.height=o,g.rotation=l,g.extrudedHeight=u,g.offsetAttribute=-1===s?void 0:s,new p(g))};var D=new d.Cartographic;return p.createGeometry=function(e){var t,i,a=e._rectangle,r=e._ellipsoid,n=w.RectangleGeometryLibrary.computeOptions(a,e._granularity,e._rotation,0,C,D);if(!b.CesiumMath.equalsEpsilon(a.north,a.south,b.CesiumMath.EPSILON10)&&!b.CesiumMath.equalsEpsilon(a.east,a.west,b.CesiumMath.EPSILON10)){var o,l=e._surfaceHeight,u=e._extrudedHeight;if(!b.CesiumMath.equalsEpsilon(l,u,0,b.CesiumMath.EPSILON2)){if(t=function(e,t){var i=e._surfaceHeight,a=e._extrudedHeight,r=e._ellipsoid,n=a,o=i,l=x(e,t),u=t.height,s=t.width,d=P.PolygonPipeline.scaleToGeodeticHeight(l.attributes.position.values,o,r,!1),p=d.length,c=new Float64Array(2*p);c.set(d);var f=P.PolygonPipeline.scaleToGeodeticHeight(l.attributes.position.values,n,r);c.set(f,p),l.attributes.position.values=c;var g=t.northCap,h=t.southCap,y=4;g&&(y-=1),h&&(y-=1);var m=2*(c.length/3+y),b=R.IndexDatatype.createTypedArray(c.length/3,m);p=c.length/6;for(var _,v=0,E=0;E<p-1;E++)b[v++]=E,b[v++]=E+1,b[v++]=E+p,b[v++]=E+p+1;if(b[v++]=p-1,b[v++]=0,b[v++]=p+p-1,b[v++]=p,b[v++]=0,b[v++]=p,g)_=u-1;else{var A=s-1;b[v++]=A,b[v++]=A+p,_=s+u-2}if(b[v++]=_,b[v++]=_+p,!h){var G=s+_-1;b[v++]=G,b[v]=G+p}return l.indices=b,l}(e,n),h.defined(e._offsetAttribute)){var s=t.attributes.position.values.length/3,d=new Uint8Array(s);d=e._offsetAttribute===y.GeometryOffsetAttribute.TOP?y.arrayFill(d,1,0,s/2):(o=e._offsetAttribute===y.GeometryOffsetAttribute.NONE?0:1,y.arrayFill(d,o)),t.attributes.applyOffset=new A.GeometryAttribute({componentDatatype:E.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:d})}var p=m.BoundingSphere.fromRectangle3D(a,r,l,v),c=m.BoundingSphere.fromRectangle3D(a,r,u,_);i=m.BoundingSphere.union(p,c)}else{if((t=x(e,n)).attributes.position.values=P.PolygonPipeline.scaleToGeodeticHeight(t.attributes.position.values,l,r,!1),h.defined(e._offsetAttribute)){var f=t.attributes.position.values.length,g=new Uint8Array(f/3);o=e._offsetAttribute===y.GeometryOffsetAttribute.NONE?0:1,y.arrayFill(g,o),t.attributes.applyOffset=new A.GeometryAttribute({componentDatatype:E.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:g})}i=m.BoundingSphere.fromRectangle3D(a,r,l)}return new A.Geometry({attributes:t.attributes,indices:t.indices,primitiveType:A.PrimitiveType.LINES,boundingSphere:i,offsetAttribute:e._offsetAttribute})}},function(e,t){return h.defined(t)&&(e=p.unpack(e,t)),e._ellipsoid=d.Ellipsoid.clone(e._ellipsoid),e._rectangle=d.Rectangle.clone(e._rectangle),p.createGeometry(e)}});
|