@vtx/ol-map 2.0.0-beta.15 → 2.0.0-beta.17

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.
@@ -1,145 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.calcRectSize = calcRectSize;
7
- exports.calcScale = calcScale;
8
- exports.getCenter = getCenter;
9
- exports.getCorners = getCorners;
10
- exports.metersToPixels = metersToPixels;
11
- exports.pixelsToMeters = pixelsToMeters;
12
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
15
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
16
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
18
- /**
19
- * 计算矩形区域的实际宽度(东西向)和高度(南北向),单位米
20
- * @param {number} west - 西侧经度(度数)
21
- * @param {number} south - 南侧纬度(度数)
22
- * @param {number} east - 东侧经度(度数)
23
- * @param {number} north - 北侧纬度(度数)
24
- * @param {string} [latRef='mean'] - 宽度计算的参考纬度:'mean'(平均纬度),'south','north'
25
- * @returns {{width: number, height: number}} 宽度和高度(米)
26
- */
27
- function calcRectSize(west, south, east, north) {
28
- var latRef = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'mean';
29
- var R = 6371000; // 地球平均半径(米)
30
- var degToRad = function degToRad(deg) {
31
- return deg * Math.PI / 180;
32
- };
33
-
34
- // 南北方向高度(经线弧长),纬度差乘以每度弧长变化不大,直接用平均半径计算
35
- var latDiff = north - south;
36
- // 方法1:使用球面弧长公式,每度纬度对应的弧长近似为 R * (π/180) ≈ 111319.5 米,但更精确使用椭球修正可忽略。
37
- // 直接计算弧长:Δσ = Δ纬度(rad) ,弧长 = R * Δσ
38
- var height = R * degToRad(latDiff);
39
-
40
- // 东西方向宽度:经度差乘以该纬度处纬圈半径
41
- var latRad;
42
- if (latRef === 'mean') {
43
- latRad = degToRad((south + north) / 2);
44
- } else if (latRef === 'south') {
45
- latRad = degToRad(south);
46
- } else if (latRef === 'north') {
47
- latRad = degToRad(north);
48
- } else {
49
- latRad = degToRad((south + north) / 2);
50
- }
51
- var lonDiff = east - west;
52
- var width = R * Math.cos(latRad) * degToRad(lonDiff);
53
- return {
54
- width: width,
55
- height: height
56
- };
57
- }
58
-
59
- // 实际宽度(米) → 像素宽度
60
- function metersToPixels(meters, scale) {
61
- return Number(meters) / Number(scale);
62
- }
63
-
64
- // 像素宽度 → 实际宽度(米)
65
- function pixelsToMeters(pixels, scale) {
66
- return Number(pixels) * Number(scale);
67
- }
68
-
69
- /**
70
- * 根据矩形边界计算中心点和四个角点(左下、右下、右上、左上)
71
- * @param {Array<number>} bounds - [west, south, east, north] 顺序的边界坐标
72
- * @returns {Object} 包含 center 和 corners 的对象
73
- */
74
- function getCenter(bounds) {
75
- if (!bounds || bounds.length !== 4) {
76
- throw new Error('边界数组必须包含 [west, south, east, north] 四个数值');
77
- }
78
- var _bounds = _slicedToArray(bounds, 4),
79
- west = _bounds[0],
80
- south = _bounds[1],
81
- east = _bounds[2],
82
- north = _bounds[3];
83
-
84
- // 中心点
85
- var centerLon = (west + east) / 2;
86
- var centerLat = (south + north) / 2;
87
-
88
- // 四个角点(左下、右下、右上、左上)
89
- var corners = {
90
- bottomLeft: [west, south],
91
- // 西南角
92
- bottomRight: [east, south],
93
- // 东南角
94
- topRight: [east, north],
95
- // 东北角
96
- topLeft: [west, north] // 西北角
97
- };
98
- return [centerLon, centerLat];
99
- }
100
- function getCorners(bounds) {
101
- if (!bounds || bounds.length !== 4) {
102
- throw new Error('边界数组必须包含 [west, south, east, north] 四个数值');
103
- }
104
- var _bounds2 = _slicedToArray(bounds, 4),
105
- west = _bounds2[0],
106
- south = _bounds2[1],
107
- east = _bounds2[2],
108
- north = _bounds2[3];
109
-
110
- // 中心点
111
- var centerLon = (west + east) / 2;
112
- var centerLat = (south + north) / 2;
113
-
114
- // 四个角点(左下、右下、右上、左上)
115
- var corners = {
116
- bottomLeft: [west, south],
117
- // 西南角
118
- bottomRight: [east, south],
119
- // 东南角
120
- topRight: [east, north],
121
- // 东北角
122
- topLeft: [west, north] // 西北角
123
- };
124
- return corners;
125
- }
126
-
127
- /**
128
- * 根据实际距离(米)和像素距离(px)计算缩放比例
129
- * @param {number} realMeters - 实际距离(米)
130
- * @param {number} px - 对应的像素长度
131
- * @returns {Object} 包含 metersPerPixel 和 pixelsPerMeter 的对象
132
- */
133
- function calcScale(realMeters, px) {
134
- if (realMeters <= 0 || px <= 0) {
135
- throw new Error('实际距离和像素必须为正数');
136
- }
137
- var metersPerPixel = realMeters / px;
138
- var pixelsPerMeter = px / realMeters;
139
- return {
140
- metersPerPixel: metersPerPixel,
141
- // 每像素 = 多少米
142
- pixelsPerMeter: pixelsPerMeter // 每米 = 多少像素
143
- };
144
- }
145
- //# sourceMappingURL=printUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"printUtils.js","names":["calcRectSize","west","south","east","north","latRef","arguments","length","undefined","R","degToRad","deg","Math","PI","latDiff","height","latRad","lonDiff","width","cos","metersToPixels","meters","scale","Number","pixelsToMeters","pixels","getCenter","bounds","Error","_bounds","_slicedToArray","centerLon","centerLat","corners","bottomLeft","bottomRight","topRight","topLeft","getCorners","_bounds2","calcScale","realMeters","px","metersPerPixel","pixelsPerMeter"],"sources":["tools/Toolbox/MapSheetPrint/printUtils.js"],"sourcesContent":["/**\n * 计算矩形区域的实际宽度(东西向)和高度(南北向),单位米\n * @param {number} west - 西侧经度(度数)\n * @param {number} south - 南侧纬度(度数)\n * @param {number} east - 东侧经度(度数)\n * @param {number} north - 北侧纬度(度数)\n * @param {string} [latRef='mean'] - 宽度计算的参考纬度:'mean'(平均纬度),'south','north'\n * @returns {{width: number, height: number}} 宽度和高度(米)\n */\nexport function calcRectSize(west, south, east, north, latRef = 'mean') {\n const R = 6371000; // 地球平均半径(米)\n const degToRad = (deg) => deg * Math.PI / 180;\n\n // 南北方向高度(经线弧长),纬度差乘以每度弧长变化不大,直接用平均半径计算\n const latDiff = north - south;\n // 方法1:使用球面弧长公式,每度纬度对应的弧长近似为 R * (π/180) ≈ 111319.5 米,但更精确使用椭球修正可忽略。\n // 直接计算弧长:Δσ = Δ纬度(rad) ,弧长 = R * Δσ\n const height = R * degToRad(latDiff);\n\n // 东西方向宽度:经度差乘以该纬度处纬圈半径\n let latRad;\n if (latRef === 'mean') {\n latRad = degToRad((south + north) / 2);\n } else if (latRef === 'south') {\n latRad = degToRad(south);\n } else if (latRef === 'north') {\n latRad = degToRad(north);\n } else {\n latRad = degToRad((south + north) / 2);\n }\n const lonDiff = east - west;\n const width = R * Math.cos(latRad) * degToRad(lonDiff);\n\n return { width, height };\n}\n\n// 实际宽度(米) → 像素宽度\nexport function metersToPixels(meters, scale) {\n\n return Number(meters) / Number(scale);\n}\n\n// 像素宽度 → 实际宽度(米)\nexport function pixelsToMeters(pixels, scale) {\n return Number(pixels) * Number(scale);\n}\n\n/**\n * 根据矩形边界计算中心点和四个角点(左下、右下、右上、左上)\n * @param {Array<number>} bounds - [west, south, east, north] 顺序的边界坐标\n * @returns {Object} 包含 center 和 corners 的对象\n */\nexport function getCenter(bounds) {\n if (!bounds || bounds.length !== 4) {\n throw new Error('边界数组必须包含 [west, south, east, north] 四个数值');\n }\n const [west, south, east, north] = bounds;\n\n // 中心点\n const centerLon = (west + east) / 2;\n const centerLat = (south + north) / 2;\n\n // 四个角点(左下、右下、右上、左上)\n const corners = {\n bottomLeft: [west, south], // 西南角\n bottomRight: [east, south], // 东南角\n topRight: [east, north], // 东北角\n topLeft: [west, north] // 西北角\n };\n\n return [centerLon, centerLat]\n}\nexport function getCorners(bounds) {\n if (!bounds || bounds.length !== 4) {\n throw new Error('边界数组必须包含 [west, south, east, north] 四个数值');\n }\n const [west, south, east, north] = bounds;\n\n // 中心点\n const centerLon = (west + east) / 2;\n const centerLat = (south + north) / 2;\n\n // 四个角点(左下、右下、右上、左上)\n const corners = {\n bottomLeft: [west, south], // 西南角\n bottomRight: [east, south], // 东南角\n topRight: [east, north], // 东北角\n topLeft: [west, north] // 西北角\n };\n\n return corners\n}\n\n/**\n * 根据实际距离(米)和像素距离(px)计算缩放比例\n * @param {number} realMeters - 实际距离(米)\n * @param {number} px - 对应的像素长度\n * @returns {Object} 包含 metersPerPixel 和 pixelsPerMeter 的对象\n */\nexport function calcScale(realMeters, px) {\n if (realMeters <= 0 || px <= 0) {\n throw new Error('实际距离和像素必须为正数');\n }\n const metersPerPixel = realMeters / px;\n const pixelsPerMeter = px / realMeters;\n return {\n metersPerPixel, // 每像素 = 多少米\n pixelsPerMeter // 每米 = 多少像素\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAACC,IAAI,EA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