Files
4.0/static/sdk/Cesium/Workers/BoundingRectangle-766f44ee.js

26 lines
3.0 KiB
JavaScript

/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.98
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
define(["exports","./Matrix2-cf4c6e69","./defaultValue-50f7432c","./Transforms-7ac1f9ee"],(function(t,e,n,i){"use strict";function h(t,e,i,h){this.x=n.defaultValue(t,0),this.y=n.defaultValue(e,0),this.width=n.defaultValue(i,0),this.height=n.defaultValue(h,0)}h.packedLength=4,h.pack=function(t,e,i){return i=n.defaultValue(i,0),e[i++]=t.x,e[i++]=t.y,e[i++]=t.width,e[i]=t.height,e},h.unpack=function(t,e,i){return e=n.defaultValue(e,0),n.defined(i)||(i=new h),i.x=t[e++],i.y=t[e++],i.width=t[e++],i.height=t[e],i},h.fromPoints=function(t,e){if(n.defined(e)||(e=new h),!n.defined(t)||0===t.length)return e.x=0,e.y=0,e.width=0,e.height=0,e;const i=t.length;let r=t[0].x,u=t[0].y,d=t[0].x,a=t[0].y;for(let e=1;e<i;e++){const n=t[e],i=n.x,h=n.y;r=Math.min(i,r),d=Math.max(i,d),u=Math.min(h,u),a=Math.max(h,a)}return e.x=r,e.y=u,e.width=d-r,e.height=a-u,e};const r=new i.GeographicProjection,u=new e.Cartographic,d=new e.Cartographic;h.fromRectangle=function(t,i,a){if(n.defined(a)||(a=new h),!n.defined(t))return a.x=0,a.y=0,a.width=0,a.height=0,a;const c=(i=n.defaultValue(i,r)).project(e.Rectangle.southwest(t,u)),o=i.project(e.Rectangle.northeast(t,d));return e.Cartesian2.subtract(o,c,o),a.x=c.x,a.y=c.y,a.width=o.x,a.height=o.y,a},h.clone=function(t,e){if(n.defined(t))return n.defined(e)?(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e):new h(t.x,t.y,t.width,t.height)},h.union=function(t,e,i){n.defined(i)||(i=new h);const r=Math.min(t.x,e.x),u=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),a=Math.max(t.y+t.height,e.y+e.height);return i.x=r,i.y=u,i.width=d-r,i.height=a-u,i},h.expand=function(t,e,n){n=h.clone(t,n);const i=e.x-n.x,r=e.y-n.y;return i>n.width?n.width=i:i<0&&(n.width-=i,n.x=e.x),r>n.height?n.height=r:r<0&&(n.height-=r,n.y=e.y),n},h.intersect=function(t,e){const n=t.x,h=t.y,r=e.x,u=e.y;return n>r+e.width||n+t.width<r||h+t.height<u||h>u+e.height?i.Intersect.OUTSIDE:i.Intersect.INTERSECTING},h.equals=function(t,e){return t===e||n.defined(t)&&n.defined(e)&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},h.prototype.clone=function(t){return h.clone(this,t)},h.prototype.intersect=function(t){return h.intersect(this,t)},h.prototype.equals=function(t){return h.equals(this,t)},t.BoundingRectangle=h}));