gis-common 5.1.35 → 5.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gis-common.es.js +117 -2
- package/dist/gis-common.umd.js +1 -1
- package/dist/index.d.ts +60 -3
- package/package.json +1 -1
package/dist/gis-common.es.js
CHANGED
|
@@ -136,6 +136,101 @@ class AudioPlayer {
|
|
|
136
136
|
this.audio.muted = val;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
class BinaryReader {
|
|
140
|
+
// 是否为小端字节序
|
|
141
|
+
constructor(buffer, littleEndian = true) {
|
|
142
|
+
__publicField(this, "_buffer");
|
|
143
|
+
__publicField(this, "_view");
|
|
144
|
+
__publicField(this, "_offset");
|
|
145
|
+
__publicField(this, "_littleEndian");
|
|
146
|
+
this._buffer = buffer;
|
|
147
|
+
this._littleEndian = littleEndian;
|
|
148
|
+
this._view = new DataView(buffer);
|
|
149
|
+
this._offset = 0;
|
|
150
|
+
}
|
|
151
|
+
/** 当前读取位置 */
|
|
152
|
+
get offset() {
|
|
153
|
+
return this._offset;
|
|
154
|
+
}
|
|
155
|
+
/** 原始 ArrayBuffer */
|
|
156
|
+
get buffer() {
|
|
157
|
+
return this._buffer;
|
|
158
|
+
}
|
|
159
|
+
/** 底层 DataView */
|
|
160
|
+
get dataView() {
|
|
161
|
+
return this._view;
|
|
162
|
+
}
|
|
163
|
+
/** 重置读取位置到开头 */
|
|
164
|
+
reset() {
|
|
165
|
+
this._offset = 0;
|
|
166
|
+
}
|
|
167
|
+
/** 跳转到指定位置 */
|
|
168
|
+
seek(offset) {
|
|
169
|
+
this._offset = offset;
|
|
170
|
+
}
|
|
171
|
+
/** 跳过指定字节数 */
|
|
172
|
+
skip(bytes) {
|
|
173
|
+
this._offset += bytes;
|
|
174
|
+
}
|
|
175
|
+
/** 读取 1 字节无符号整数 */
|
|
176
|
+
readUint8() {
|
|
177
|
+
const value = this._view.getUint8(this._offset);
|
|
178
|
+
this._offset += 1;
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
/** 读取 2 字节无符号整数 */
|
|
182
|
+
readUint16() {
|
|
183
|
+
const value = this._view.getUint16(this._offset, this._littleEndian);
|
|
184
|
+
this._offset += 2;
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
/** 读取 4 字节无符号整数 */
|
|
188
|
+
readUint32() {
|
|
189
|
+
const value = this._view.getUint32(this._offset, this._littleEndian);
|
|
190
|
+
this._offset += 4;
|
|
191
|
+
return value;
|
|
192
|
+
}
|
|
193
|
+
/** 读取 1 字节有符号整数 */
|
|
194
|
+
readInt8() {
|
|
195
|
+
const value = this._view.getInt8(this._offset);
|
|
196
|
+
this._offset += 1;
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
/** 读取 2 字节有符号整数 */
|
|
200
|
+
readInt16() {
|
|
201
|
+
const value = this._view.getInt16(this._offset, this._littleEndian);
|
|
202
|
+
this._offset += 2;
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
/** 读取 4 字节有符号整数 */
|
|
206
|
+
readInt32() {
|
|
207
|
+
const value = this._view.getInt32(this._offset, this._littleEndian);
|
|
208
|
+
this._offset += 4;
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
/** 读取 4 字节浮点数 (float32) */
|
|
212
|
+
readFloat32() {
|
|
213
|
+
const value = this._view.getFloat32(this._offset, this._littleEndian);
|
|
214
|
+
this._offset += 4;
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
/** 读取 8 字节浮点数 (float64) */
|
|
218
|
+
readFloat64() {
|
|
219
|
+
const value = this._view.getFloat64(this._offset, this._littleEndian);
|
|
220
|
+
this._offset += 8;
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
/** 读取指定长度的 buffer 片段 */
|
|
224
|
+
readBuffer(length) {
|
|
225
|
+
const slice = this._buffer.slice(this._offset, this._offset + length);
|
|
226
|
+
this._offset += length;
|
|
227
|
+
return slice;
|
|
228
|
+
}
|
|
229
|
+
/** 读取指定长度的字符串 */
|
|
230
|
+
readString(length) {
|
|
231
|
+
return String.fromCharCode.apply(null, new Uint8Array(this.readBuffer(length)));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
139
234
|
const ExceptionUtil = {
|
|
140
235
|
getException(type, message = "") {
|
|
141
236
|
const _Exception = function() {
|
|
@@ -2672,9 +2767,9 @@ const OptimizeUtil = {
|
|
|
2672
2767
|
*
|
|
2673
2768
|
* @param fun 要递归调用的函数。
|
|
2674
2769
|
* @param frequency 每次调用函数之间的时间间隔,单位为毫秒,默认为500毫秒。
|
|
2675
|
-
* @param duration
|
|
2770
|
+
* @param duration 函数递归调用的总时长,单位为毫秒,默认为不限制。
|
|
2676
2771
|
*/
|
|
2677
|
-
recurve(fun, frequency = 500, duration =
|
|
2772
|
+
recurve(fun, frequency = 500, duration = Infinity) {
|
|
2678
2773
|
let timer = 0;
|
|
2679
2774
|
setTimeout(() => {
|
|
2680
2775
|
timer++;
|
|
@@ -3424,6 +3519,14 @@ class CanvasDrawer {
|
|
|
3424
3519
|
this.ctx.stroke();
|
|
3425
3520
|
}
|
|
3426
3521
|
}
|
|
3522
|
+
/**
|
|
3523
|
+
* 绘制图像
|
|
3524
|
+
*
|
|
3525
|
+
* @param coordinate 绘制位置的坐标
|
|
3526
|
+
* @param image 要绘制的图像(ImageBitmap)
|
|
3527
|
+
* @param options 绘制选项,包括宽度、高度和旋转角度
|
|
3528
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
3529
|
+
*/
|
|
3427
3530
|
drawImage({ x, y }, image, options = {}) {
|
|
3428
3531
|
const width = options.width || image.width;
|
|
3429
3532
|
const height = options.height || image.height;
|
|
@@ -3437,12 +3540,23 @@ class CanvasDrawer {
|
|
|
3437
3540
|
this.ctx.drawImage(image, -width / 2, -height / 2, width, height);
|
|
3438
3541
|
this.ctx.restore();
|
|
3439
3542
|
}
|
|
3543
|
+
/**
|
|
3544
|
+
* 绘制文本
|
|
3545
|
+
*
|
|
3546
|
+
* @param coordinate 绘制位置的坐标
|
|
3547
|
+
* @param text 要绘制的文本内容
|
|
3548
|
+
* @param options 绘制选项,包括字体和颜色
|
|
3549
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
3550
|
+
*/
|
|
3440
3551
|
drawText({ x, y }, text, options) {
|
|
3441
3552
|
this.ctx.font = options.font || "10px sans-serif";
|
|
3442
3553
|
this.ctx.strokeStyle = options.color || "#000";
|
|
3443
3554
|
this.ctx.lineWidth = 2;
|
|
3444
3555
|
this.ctx.strokeText(text, x, y);
|
|
3445
3556
|
}
|
|
3557
|
+
destroy() {
|
|
3558
|
+
this.canvas.remove();
|
|
3559
|
+
}
|
|
3446
3560
|
static createCanvas(width = 1, height = 1) {
|
|
3447
3561
|
const canvas = document.createElement("canvas");
|
|
3448
3562
|
if (width) {
|
|
@@ -18434,6 +18548,7 @@ export {
|
|
|
18434
18548
|
AjaxUtil,
|
|
18435
18549
|
ArrayUtil,
|
|
18436
18550
|
AudioPlayer,
|
|
18551
|
+
BinaryReader,
|
|
18437
18552
|
BrowserUtil,
|
|
18438
18553
|
CanvasDrawer,
|
|
18439
18554
|
CaseType,
|