为了方便查找和使用该文件,故放在此处
文件名:cesium-wind.esm.js
/*!
* author: joe <qj5657@gmail.com>
* cesium-wind 1.0.3
* build-time: 2020-9-23 11:17
* LICENSE: MIT
* (c) 2020-2020 https://github.com/QJvic/cesium-wind
*/
import {
Cartesian3, SceneTransforms, Cartesian2, Math as Math$1, Ellipsoid, EllipsoidalOccluder } from 'cesium';
/*!
* author: sakitam-fdd <smilefdd@gmail.com>
* wind-core v1.0.0-alpha.9
* build-time: 2020-7-5 23:35
* LICENSE: MIT
* (c) 2017-2020 https://github.com/sakitam-fdd/wind-layer#readme
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __spreadArrays() {
var arguments$1 = arguments;
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments$1[i].length; }
for (var r = Array(s), k = 0, i = 0; i < il; i++)
{
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
{
r[k] = a[j]; } }
return r;
}
if (!Array.isArray) {
// @ts-ignore
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
if (typeof Object.assign != 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) {
var arguments$1 = arguments;
if (target == null) {
// TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments$1[index];
if (nextSource != null) {
// Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
var symToStringTag = typeof Symbol !== 'undefined' ? Symbol.toStringTag : undefined;
function baseGetTag(value) {
if (value === null) {
return value === undefined ? '[object Undefined]' : '[object Null]';
}
if (!(symToStringTag && symToStringTag in Object(value))) {
return toString.call(value);
}
var isOwn = hasOwnProperty.call(value, symToStringTag);
var tag = value[symToStringTag];
var unmasked = false;
try {
value[symToStringTag] = undefined;
unmasked = true;
}
catch (e) {
}
var result = Object.prototype.toString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
}
else {
delete value[symToStringTag];
}
}
return result;
}
/**
* 判断是否为函数
* @param value
* @returns {boolean}
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
var tag = baseGetTag(value);
return tag === '[object Function]' || tag === '[object AsyncFunction]' ||
tag === '[object GeneratorFunction]' || tag === '[object Proxy]';
}
/**
* 判断是否为对象
* @param value
* @returns {boolean}
*/
function isObject(value) {
var type = typeof value;
return value !== null && (type === 'object' || type === 'function');
}
/**
* 判断是否为合法字符串
* @param value
* @returns {boolean}
*/
function isString(value) {
if (value == null) {
return false;
}
return typeof value === 'string' || (value.constructor !== null && value.constructor === String);
}
/**
* 判断是否为数字
* @param value
* @returns {boolean}
*/
function isNumber(value) {
return Object.prototype.toString.call(value) === '[object Number]' && !isNaN(value);
}
/**
* check is array
* @param arr
*/
function isArray(arr) {
return Array.isArray(arr);
}
/**
* assign object
* @param target
* @param sources
*/
function assign(target) {
var arguments$1 = arguments;
var sources = [];
for (var _i = 1; _i < arguments.length; _i++) {
sources[_i - 1] = arguments$1[_i];
}
return Object.assign.apply(Object, __spreadArrays([target], sources));
}
/**
* Get floored division
* @param a
* @param n
* @returns {Number} returns remainder of floored division,
* i.e., floor(a / n). Useful for consistent modulo of negative numbers.
* See http://en.wikipedia.org/wiki/Modulo_operation.
*/
function floorMod(a, n) {
return a - n * Math.floor(a / n);
}
/**
* 检查值是否合法
* @param val
* @returns {boolean}
*/
function isValide(val) {
return val !== undefined && val !== null && !isNaN(val);
}
/**
* format gfs json to vector
* @param data
*/
function formatData(data) {
var uComp;
var vComp;
{
console.time('format-data');
}
data.forEach(function (record) {
switch (record.header.parameterCategory + "," + record.header.parameterNumber) {
case "1,2":
case "2,2":
uComp = record;
break;
case "1,3":
case "2,3":
vComp = record;
break;
}
});
// @ts-ignore
if (!vComp || !uComp)
{
return; }
var header = uComp.header;
var vectorField = new Field({
xmin: header.lo1,
ymin: header.la1,
xmax: header.lo2,
ymax: header.la2,
deltaX: header.dx,
deltaY: header.dy,
cols: header.nx,
rows: header.ny,
us: uComp.data,
vs: vComp.data
});
{
console.timeEnd('format-data');
}
return vectorField;
}
/**
* 移除 dom
* @param node
* @returns {removeDomNode}
*/
function removeDomNode(node) {
if (!node) {
return null;
}
if (node.parentNode) {
node.parentNode.removeChild(node);
}
return node;
}
// from: https://sourcegraph.com/github.com/IHCantabria/Leaflet.CanvasLayer.Field/-/blob/src/Vector.js?utm_source=share
var Vector = /** @class */ (function () {
function Vector(u, v) {
this.u = u;
this.v = v;
this.m = this.magnitude();
}
/**
* the vector value
* 向量值(流体强度)
* @returns {Number}
*/
Vector.prototype.magnitude = function () {
// Math.pow(u, 2)
// Math.pow(v, 2)
return Math.sqrt(this.u * this.u + this.v * this.v);
};
/**
* Angle in degrees (0 to 360º) --> Towards
* 流体方向
* N is 0º and E is 90º
* @returns {Number}
*/
Vector.prototype.directionTo = function () {
var verticalAngle = Math.atan2(this.u, this.v);
var inDegrees = verticalAngle * (180.0 / Math.PI);
if (inDegrees < 0) {
inDegrees += 360.0;
}
return inDegrees;
};
/**
* Angle in degrees (0 to 360º) From x-->
* N is 0º and E is 90º
* @returns {Number}
*/
Vector.prototype.directionFrom = function () {
var a = this.directionTo();
return (a + 180.0) % 360.0;
};
return Vector;
}());
var Field = /** @class */ (function () {
function Field(params) {
this.grid = [];
this.xmin = params.xmin;
this.xmax = params.xmax;
this.ymin = params.ymin;
this.ymax = params.ymax;
this.cols = params.cols; // 列数
this.rows = params.rows; // 行数
this.us = params.us; //
this.vs = params.vs;
this.deltaX = params.deltaX; // x 方向增量
this.deltaY = params.deltaY; // y方向增量
if (this.deltaY < 0 && this.ymin <