gis-common 5.1.12 → 5.1.14
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
CHANGED
|
@@ -285,7 +285,7 @@ const Util = {
|
|
|
285
285
|
* @returns 解码后的字符串
|
|
286
286
|
*/
|
|
287
287
|
decodeDict(...args) {
|
|
288
|
-
let res =
|
|
288
|
+
let res = null;
|
|
289
289
|
if (args.length > 1) {
|
|
290
290
|
const items = args.slice(1, args.length % 2 === 0 ? args.length - 1 : args.length);
|
|
291
291
|
for (let i = 0; i < items.length; i = i + 2) {
|
|
@@ -1223,18 +1223,6 @@ class GeoUtil {
|
|
|
1223
1223
|
const y = earthRad / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a)));
|
|
1224
1224
|
return { x, y };
|
|
1225
1225
|
}
|
|
1226
|
-
/**
|
|
1227
|
-
* 根据百分比获取坐标
|
|
1228
|
-
*
|
|
1229
|
-
* @param start 起点坐标
|
|
1230
|
-
* @param end 终点坐标
|
|
1231
|
-
* @param percent 百分比,取值范围0-1
|
|
1232
|
-
* @returns 返回插值后的坐标
|
|
1233
|
-
*/
|
|
1234
|
-
static interpolate({ x: x1, y: y1, z: z1 = 0 }, { x: x2, y: y2, z: z2 = 0 }, percent) {
|
|
1235
|
-
const dx = x2 - x1, dy = y2 - y1, dz = z2 - z1;
|
|
1236
|
-
return { x: x1 + dx * percent, y: y1 + dy * percent, z: z1 + dz * percent };
|
|
1237
|
-
}
|
|
1238
1226
|
/**
|
|
1239
1227
|
* 计算三角形面积
|
|
1240
1228
|
*
|
|
@@ -1281,25 +1269,22 @@ class GeoUtil {
|
|
|
1281
1269
|
};
|
|
1282
1270
|
}
|
|
1283
1271
|
/**
|
|
1284
|
-
*
|
|
1272
|
+
* 根据百分比获取坐标
|
|
1285
1273
|
*
|
|
1286
1274
|
* @param pA 线段起点,可以是Coordinate类型(包含x,y属性)或LngLat类型(包含lng,lat属性)
|
|
1287
1275
|
* @param pB 线段终点,可以是Coordinate类型(包含x,y属性)或LngLat类型(包含lng,lat属性)
|
|
1288
1276
|
* @param ratio 插值比例,0表示在起点pA,1表示在终点pB,0-1之间表示两点间的插值点
|
|
1289
1277
|
* @returns 返回插值点坐标,类型与输入参数保持一致
|
|
1290
1278
|
*/
|
|
1291
|
-
static
|
|
1292
|
-
ratio = MathUtil.clamp(ratio, 0, 1);
|
|
1279
|
+
static interpolate(pA, pB, ratio) {
|
|
1293
1280
|
if ("x" in pA && "y" in pA && "x" in pB && "y" in pB) {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
};
|
|
1281
|
+
const dx = pB.x - pA.x;
|
|
1282
|
+
const dy = pB.y - pA.y;
|
|
1283
|
+
return { x: pA.x + dx * ratio, y: pA.y + dy * ratio };
|
|
1298
1284
|
} else if ("lng" in pA && "lat" in pA && "lng" in pB && "lat" in pB) {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
};
|
|
1285
|
+
const dx = pB.lng - pA.lng;
|
|
1286
|
+
const dy = pB.lat - pA.lat;
|
|
1287
|
+
return { x: pA.lng + dx * ratio, y: pA.lat + dy * ratio };
|
|
1303
1288
|
}
|
|
1304
1289
|
}
|
|
1305
1290
|
}
|
|
@@ -1469,7 +1454,7 @@ class Color {
|
|
|
1469
1454
|
this._r = r;
|
|
1470
1455
|
this._g = g;
|
|
1471
1456
|
this._b = b;
|
|
1472
|
-
this._alpha = MathUtil.clamp(a
|
|
1457
|
+
this._alpha = MathUtil.clamp(a ?? 1, 0, 1);
|
|
1473
1458
|
}
|
|
1474
1459
|
_validateColorChannel(channel) {
|
|
1475
1460
|
if (channel < 0 || channel > 255) {
|
|
@@ -1492,7 +1477,7 @@ class Color {
|
|
|
1492
1477
|
return Color.rgb2hex(this._r, this._g, this._b, this._alpha);
|
|
1493
1478
|
}
|
|
1494
1479
|
setAlpha(a) {
|
|
1495
|
-
this._alpha = MathUtil.clamp(a, 0, 1);
|
|
1480
|
+
this._alpha = MathUtil.clamp(a ?? 1, 0, 1);
|
|
1496
1481
|
return this;
|
|
1497
1482
|
}
|
|
1498
1483
|
// 设置颜色的RGB值
|