2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
define(["exports","./Cartesian2-bd414876","./Check-741c5f3c","./defaultValue-81eec7ed","./Math-e73894ab"],(function(t,e,a,n,s){"use strict";function u(t,e,a,s){this.west=n.defaultValue(t,0),this.south=n.defaultValue(e,0),this.east=n.defaultValue(a,0),this.north=n.defaultValue(s,0)}Object.defineProperties(u.prototype,{width:{get:function(){return u.computeWidth(this)}},height:{get:function(){return u.computeHeight(this)}}}),u.packedLength=4,u.pack=function(t,e,a){return a=n.defaultValue(a,0),e[a++]=t.west,e[a++]=t.south,e[a++]=t.east,e[a]=t.north,e},u.unpack=function(t,e,a){return e=n.defaultValue(e,0),n.defined(a)||(a=new u),a.west=t[e++],a.south=t[e++],a.east=t[e++],a.north=t[e],a},u.computeWidth=function(t){let e=t.east;const a=t.west;return e<a&&(e+=s.CesiumMath.TWO_PI),e-a},u.computeHeight=function(t){return t.north-t.south},u.fromDegrees=function(t,e,a,i,o){return t=s.CesiumMath.toRadians(n.defaultValue(t,0)),e=s.CesiumMath.toRadians(n.defaultValue(e,0)),a=s.CesiumMath.toRadians(n.defaultValue(a,0)),i=s.CesiumMath.toRadians(n.defaultValue(i,0)),n.defined(o)?(o.west=t,o.south=e,o.east=a,o.north=i,o):new u(t,e,a,i)},u.fromRadians=function(t,e,a,s,i){return n.defined(i)?(i.west=n.defaultValue(t,0),i.south=n.defaultValue(e,0),i.east=n.defaultValue(a,0),i.north=n.defaultValue(s,0),i):new u(t,e,a,s)},u.fromCartographicArray=function(t,e){let a=Number.MAX_VALUE,i=-Number.MAX_VALUE,o=Number.MAX_VALUE,h=-Number.MAX_VALUE,r=Number.MAX_VALUE,d=-Number.MAX_VALUE;for(let e=0,n=t.length;e<n;e++){const n=t[e];a=Math.min(a,n.longitude),i=Math.max(i,n.longitude),r=Math.min(r,n.latitude),d=Math.max(d,n.latitude);const u=n.longitude>=0?n.longitude:n.longitude+s.CesiumMath.TWO_PI;o=Math.min(o,u),h=Math.max(h,u)}return i-a>h-o&&(a=o,i=h,i>s.CesiumMath.PI&&(i-=s.CesiumMath.TWO_PI),a>s.CesiumMath.PI&&(a-=s.CesiumMath.TWO_PI)),n.defined(e)?(e.west=a,e.south=r,e.east=i,e.north=d,e):new u(a,r,i,d)},u.fromCartesianArray=function(t,a,i){a=n.defaultValue(a,e.Ellipsoid.WGS84);let o=Number.MAX_VALUE,h=-Number.MAX_VALUE,r=Number.MAX_VALUE,d=-Number.MAX_VALUE,l=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(let e=0,n=t.length;e<n;e++){const n=a.cartesianToCartographic(t[e]);o=Math.min(o,n.longitude),h=Math.max(h,n.longitude),l=Math.min(l,n.latitude),c=Math.max(c,n.latitude);const u=n.longitude>=0?n.longitude:n.longitude+s.CesiumMath.TWO_PI;r=Math.min(r,u),d=Math.max(d,u)}return h-o>d-r&&(o=r,h=d,h>s.CesiumMath.PI&&(h-=s.CesiumMath.TWO_PI),o>s.CesiumMath.PI&&(o-=s.CesiumMath.TWO_PI)),n.defined(i)?(i.west=o,i.south=l,i.east=h,i.north=c,i):new u(o,l,h,c)},u.clone=function(t,e){if(n.defined(t))return n.defined(e)?(e.west=t.west,e.south=t.south,e.east=t.east,e.north=t.north,e):new u(t.west,t.south,t.east,t.north)},u.equalsEpsilon=function(t,e,a){return a=n.defaultValue(a,0),t===e||n.defined(t)&&n.defined(e)&&Math.abs(t.west-e.west)<=a&&Math.abs(t.south-e.south)<=a&&Math.abs(t.east-e.east)<=a&&Math.abs(t.north-e.north)<=a},u.prototype.clone=function(t){return u.clone(this,t)},u.prototype.equals=function(t){return u.equals(this,t)},u.equals=function(t,e){return t===e||n.defined(t)&&n.defined(e)&&t.west===e.west&&t.south===e.south&&t.east===e.east&&t.north===e.north},u.prototype.equalsEpsilon=function(t,e){return u.equalsEpsilon(this,t,e)},u.validate=function(t){},u.southwest=function(t,a){return n.defined(a)?(a.longitude=t.west,a.latitude=t.south,a.height=0,a):new e.Cartographic(t.west,t.south)},u.northwest=function(t,a){return n.defined(a)?(a.longitude=t.west,a.latitude=t.north,a.height=0,a):new e.Cartographic(t.west,t.north)},u.northeast=function(t,a){return n.defined(a)?(a.longitude=t.east,a.latitude=t.north,a.height=0,a):new e.Cartographic(t.east,t.north)},u.southeast=function(t,a){return n.defined(a)?(a.longitude=t.east,a.latitude=t.south,a.height=0,a):new e.Cartographic(t.east,t.south)},u.center=function(t,a){let u=t.east;const i=t.west;u<i&&(u+=s.CesiumMath.TWO_PI);const o=s.CesiumMath.negativePiToPi(.5*(i+u)),h=.5*(t.south+t.north);return n.defined(a)?(a.longitude=o,a.latitude=h,a.height=0,a):new e.Cartographic(o,h)},u.intersection=function(t,e,a){let i=t.east,o=t.west,h=e.east,r=e.west;i<o&&h>0?i+=s.CesiumMath.TWO_PI:h<r&&i>0&&(h+=s.CesiumMath.TWO_PI),i<o&&r<0?r+=s.CesiumMath.TWO_PI:h<r&&o<0&&(o+=s.CesiumMath.TWO_PI);const d=s.CesiumMath.negativePiToPi(Math.max(o,r)),l=s.CesiumMath.negativePiToPi(Math.min(i,h));if((t.west<t.east||e.west<e.east)&&l<=d)return;const c=Math.max(t.south,e.south),m=Math.min(t.north,e.north);return c>=m?void 0:n.defined(a)?(a.west=d,a.south=c,a.east=l,a.north=m,a):new u(d,c,l,m)},u.simpleIntersection=function(t,e,a){const s=Math.max(t.west,e.west),i=Math.max(t.south,e.south),o=Math.min(t.east,e.east),h=Math.min(t.north,e.north);if(!(i>=h||s>=o))return n.defined(a)?(a.west=s,a.south=i,a.east=o,a.north=h,a):new u(s,i,o,h)},u.union=function(t,e,a){n.defined(a)||(a=new u);let i=t.east,o=t.west,h=e.east,r=e.west;i<o&&h>0?i+=s.CesiumMath.TWO_PI:h<r&&i>0&&(h+=s.CesiumMath.TWO_PI),i<o&&r<0?r+=s.CesiumMath.TWO_PI:h<r&&o<0&&(o+=s.CesiumMath.TWO_PI);const d=s.CesiumMath.negativePiToPi(Math.min(o,r)),l=s.CesiumMath.negativePiToPi(Math.max(i,h));return a.west=d,a.south=Math.min(t.south,e.south),a.east=l,a.north=Math.max(t.north,e.north),a},u.expand=function(t,e,a){return n.defined(a)||(a=new u),a.west=Math.min(t.west,e.longitude),a.south=Math.min(t.south,e.latitude),a.east=Math.max(t.east,e.longitude),a.north=Math.max(t.north,e.latitude),a},u.contains=function(t,e){let a=e.longitude;const n=e.latitude,u=t.west;let i=t.east;return i<u&&(i+=s.CesiumMath.TWO_PI,a<0&&(a+=s.CesiumMath.TWO_PI)),(a>u||s.CesiumMath.equalsEpsilon(a,u,s.CesiumMath.EPSILON14))&&(a<i||s.CesiumMath.equalsEpsilon(a,i,s.CesiumMath.EPSILON14))&&n>=t.south&&n<=t.north};const i=new e.Cartographic;u.subsample=function(t,a,o,h){a=n.defaultValue(a,e.Ellipsoid.WGS84),o=n.defaultValue(o,0),n.defined(h)||(h=[]);let r=0;const d=t.north,l=t.south,c=t.east,m=t.west,M=i;M.height=o,M.longitude=m,M.latitude=d,h[r]=a.cartographicToCartesian(M,h[r]),r++,M.longitude=c,h[r]=a.cartographicToCartesian(M,h[r]),r++,M.latitude=l,h[r]=a.cartographicToCartesian(M,h[r]),r++,M.longitude=m,h[r]=a.cartographicToCartesian(M,h[r]),r++,M.latitude=d<0?d:l>0?l:0;for(let e=1;e<8;++e)M.longitude=-Math.PI+e*s.CesiumMath.PI_OVER_TWO,u.contains(t,M)&&(h[r]=a.cartographicToCartesian(M,h[r]),r++);return 0===M.latitude&&(M.longitude=m,h[r]=a.cartographicToCartesian(M,h[r]),r++,M.longitude=c,h[r]=a.cartographicToCartesian(M,h[r]),r++),h.length=r,h},u.subsection=function(t,e,a,i,o,h){if(n.defined(h)||(h=new u),t.west<=t.east){const a=t.east-t.west;h.west=t.west+e*a,h.east=t.west+i*a}else{const a=s.CesiumMath.TWO_PI+t.east-t.west;h.west=s.CesiumMath.negativePiToPi(t.west+e*a),h.east=s.CesiumMath.negativePiToPi(t.west+i*a)}const r=t.north-t.south;return h.south=t.south+a*r,h.north=t.south+o*r,1===e&&(h.west=t.east),1===i&&(h.east=t.east),1===a&&(h.south=t.north),1===o&&(h.north=t.north),h},u.MAX_VALUE=Object.freeze(new u(-Math.PI,-s.CesiumMath.PI_OVER_TWO,Math.PI,s.CesiumMath.PI_OVER_TWO)),t.Rectangle=u}));
|