gis-common 1.1.14 → 1.1.16

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.
Files changed (2) hide show
  1. package/dist/resource.min.js +115 -41
  2. package/package.json +1 -1
@@ -1111,8 +1111,67 @@ function splitWords(str) {
1111
1111
  return doc.children[0];
1112
1112
  }
1113
1113
  });
1114
+ // CONCATENATED MODULE: ./src/utils/MathUtils.js
1115
+ /* harmony default export */ var MathUtils = ({
1116
+ DEG2RAD: Math.PI / 180,
1117
+ RAD2DEG: 180 / Math.PI,
1118
+ randInt: function randInt(low, high) {
1119
+ return low + Math.floor(Math.random() * (high - low + 1));
1120
+ },
1121
+ randFloat: function randFloat(low, high) {
1122
+ return low + Math.random() * (high - low);
1123
+ },
1124
+
1125
+ /**
1126
+ * 角度转弧度
1127
+ *
1128
+ * @param {*} degrees
1129
+ * @returns {*}
1130
+ */
1131
+ degreesToRadians: function degreesToRadians(degrees) {
1132
+ return degrees * this.DEG2RAD;
1133
+ },
1134
+
1135
+ /**
1136
+ * 角度转弧度
1137
+ *
1138
+ * @param {*} degrees
1139
+ * @returns {*}
1140
+ */
1141
+ toRadians: function toRadians(degrees) {
1142
+ return degrees * this.DEG2RAD;
1143
+ },
1144
+
1145
+ /**
1146
+ * 弧度转角度
1147
+ *
1148
+ * @param {*} radians
1149
+ * @returns {*}
1150
+ */
1151
+ radiansToDegrees: function radiansToDegrees(radians) {
1152
+ return radians * this.RAD2DEG;
1153
+ },
1154
+
1155
+ /**
1156
+ * 弧度转角度
1157
+ *
1158
+ * @param {*} radians
1159
+ * @returns {*}
1160
+ */
1161
+ toDegrees: function toDegrees(radians) {
1162
+ return radians * this.RAD2DEG;
1163
+ },
1164
+ formatFloat: function formatFloat(value) {
1165
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1166
+
1167
+ return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
1168
+ }
1169
+ });
1114
1170
  // CONCATENATED MODULE: ./src/utils/GeoUtils.js
1171
+
1115
1172
  /* harmony default export */ var GeoUtils = ({
1173
+ toRadian: Math.PI / 180,
1174
+ R: 6371393,
1116
1175
  /**
1117
1176
  * 验证经纬度坐标
1118
1177
  *
@@ -1282,6 +1341,55 @@ function splitWords(str) {
1282
1341
  var x = (p1.x - p2.x) * Math.cos(Math.PI / 180 * -θ) - (p1.y - p2.y) * Math.sin(Math.PI / 180 * -θ) + p2.x;
1283
1342
  var y = (p1.x - p2.x) * Math.sin(Math.PI / 180 * -θ) + (p1.y - p2.y) * Math.cos(Math.PI / 180 * -θ) + p2.y;
1284
1343
  return { x: x, y: y };
1344
+ },
1345
+
1346
+ /**
1347
+ * 计算latlng2相对于latlng1的方位角和距离
1348
+ *
1349
+ * @param {*} latlng1
1350
+ * @param {*} latlng2
1351
+ * @returns {*} {boolean}
1352
+ */
1353
+ calcBearAndDisByPoints: function calcBearAndDisByPoints(latlng1, latlng2) {
1354
+ var f1 = parseFloat(latlng1.lat),
1355
+ l1 = parseFloat(latlng1.lng),
1356
+ f2 = parseFloat(latlng2.lat),
1357
+ l2 = parseFloat(latlng2.lng);
1358
+ var y = Math.sin((l2 - l1) * this.toRadian) * Math.cos(f2 * this.toRadian);
1359
+ var x = Math.cos(f1 * this.toRadian) * Math.sin(f2 * this.toRadian) - Math.sin(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.cos((l2 - l1) * this.toRadian);
1360
+ var angle = Math.atan2(y, x) * (180 / Math.PI);
1361
+ var deltaF = (f2 - f1) * this.toRadian;
1362
+ var deltaL = (l2 - l1) * this.toRadian;
1363
+ var a = Math.sin(deltaF / 2) * Math.sin(deltaF / 2) + Math.cos(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.sin(deltaL / 2) * Math.sin(deltaL / 2);
1364
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
1365
+ var distance = this.R * c;
1366
+ return {
1367
+ angle: angle,
1368
+ distance: distance
1369
+ };
1370
+ },
1371
+
1372
+ /**
1373
+ * 根据方位角和距离生成新的坐标
1374
+ *
1375
+ * @param {*} latlng
1376
+ * @param {*} angle
1377
+ * @param {*} distance
1378
+ * @returns {*}
1379
+ */
1380
+ calcPointByBearAndDis: function calcPointByBearAndDis(latlng, angle, distance) {
1381
+ var sLat = MathUtils.toRadians(parseFloat(latlng.lng));
1382
+ var sLng = MathUtils.toRadians(parseFloat(latlng.lng));
1383
+ angle = parseFloat(angle);
1384
+ distance = parseFloat(distance);
1385
+ var d = distance / this.R;
1386
+ angle = MathUtils.toRadians(angle);
1387
+ var lat = Math.asin(Math.sin(sLat) * Math.cos(d) + Math.cos(sLat) * Math.sin(d) * Math.cos(angle));
1388
+ var lon = sLng + Math.atan2(Math.sin(angle) * Math.sin(d) * Math.cos(sLat), Math.cos(d) - Math.sin(sLat) * Math.sin(lat));
1389
+ return {
1390
+ lat: MathUtils.toDegrees(lat),
1391
+ lng: MathUtils.toDegrees(lon)
1392
+ };
1285
1393
  }
1286
1394
  });
1287
1395
  // CONCATENATED MODULE: ./src/utils/FileUtils.js
@@ -1395,42 +1503,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1395
1503
  window.URL.revokeObjectURL(link.href);
1396
1504
  }
1397
1505
  });
1398
- // CONCATENATED MODULE: ./src/utils/MathUtils.js
1399
- /* harmony default export */ var MathUtils = ({
1400
- DEG2RAD: Math.PI / 180,
1401
- RAD2DEG: 180 / Math.PI,
1402
- randInt: function randInt(low, high) {
1403
- return low + Math.floor(Math.random() * (high - low + 1));
1404
- },
1405
- randFloat: function randFloat(low, high) {
1406
- return low + Math.random() * (high - low);
1407
- },
1408
-
1409
- /**
1410
- * 角度转弧度
1411
- *
1412
- * @param {*} degrees
1413
- * @returns {*}
1414
- */
1415
- degreesToRadians: function degreesToRadians(degrees) {
1416
- return degrees * this.DEG2RAD;
1417
- },
1418
-
1419
- /**
1420
- * 弧度转角度
1421
- *
1422
- * @param {*} radians
1423
- * @returns {*}
1424
- */
1425
- radiansToDegrees: function radiansToDegrees(radians) {
1426
- return radians * this.RAD2DEG;
1427
- },
1428
- formatFloat: function formatFloat(value) {
1429
- var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1430
-
1431
- return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
1432
- }
1433
- });
1434
1506
  // CONCATENATED MODULE: ./src/utils/OptimizeUtils.js
1435
1507
  /* harmony default export */ var OptimizeUtils = ({
1436
1508
  /**
@@ -2400,10 +2472,12 @@ function DevicePixelRatio_classCallCheck(instance, Constructor) { if (!(instance
2400
2472
 
2401
2473
  var DevicePixelRatio = function () {
2402
2474
  function DevicePixelRatio() {
2475
+ var magnification = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2476
+
2403
2477
  DevicePixelRatio_classCallCheck(this, DevicePixelRatio);
2404
- }
2405
- // this.flag = false;
2406
2478
 
2479
+ this.magnification = magnification;
2480
+ }
2407
2481
  // 获取系统类型
2408
2482
 
2409
2483
 
@@ -2460,19 +2534,19 @@ var DevicePixelRatio = function () {
2460
2534
  // 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
2461
2535
  var scale = document.documentElement.clientWidth / pageWidth;
2462
2536
  // 设置页面根节点字体大小
2463
- document.documentElement.style.fontSize = baseSize * Math.min(scale, 2) + 'px';
2537
+ document.documentElement.style.fontSize = this.magnification * baseSize * Math.min(scale, 2) + 'px';
2464
2538
  } else if (pageWidth > 750 && pageWidth <= 1200) {
2465
2539
  var _baseSize = 85;
2466
2540
  // 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
2467
2541
  var _scale = document.documentElement.clientWidth / pageWidth;
2468
2542
  // 设置页面根节点字体大小
2469
- document.documentElement.style.fontSize = _baseSize * Math.min(_scale, 2) + 'px';
2543
+ document.documentElement.style.fontSize = this.magnification * _baseSize * Math.min(_scale, 2) + 'px';
2470
2544
  } else {
2471
2545
  var _baseSize2 = 100;
2472
2546
  // 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
2473
2547
  var _scale2 = document.documentElement.clientWidth / 1920;
2474
2548
  // 设置页面根节点字体大小
2475
- document.documentElement.style.fontSize = _baseSize2 * Math.min(_scale2, 2) + 'px';
2549
+ document.documentElement.style.fontSize = this.magnification * _baseSize2 * Math.min(_scale2, 2) + 'px';
2476
2550
  }
2477
2551
  }
2478
2552
  // 监听页面缩放
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "dist/resource.min.js",
5
- "version": "1.1.14",
5
+ "version": "1.1.16",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,