@sword916/vae-map-plus 1.0.0 → 1.0.1

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 (185) hide show
  1. package/lib/index.js +5376 -0
  2. package/lib/style.css +1 -0
  3. package/lib/vae-amap/favicon.ico +0 -0
  4. package/lib/vae-amap/images/game.png +0 -0
  5. package/lib/vae-amap/images/grid.png +0 -0
  6. package/lib/vae-amap/images/marker.png +0 -0
  7. package/lib/vae-amap/index.js +209 -0
  8. package/lib/vae-amap/style.css +1 -0
  9. package/lib/vae-cloudmap/favicon.ico +0 -0
  10. package/lib/vae-cloudmap/images/game.png +0 -0
  11. package/lib/vae-cloudmap/images/grid.png +0 -0
  12. package/lib/vae-cloudmap/images/marker.png +0 -0
  13. package/lib/vae-cloudmap/index.html +30 -0
  14. package/lib/vae-cloudmap/index.js +4085 -0
  15. package/lib/vae-cloudmap/style.css +1 -0
  16. package/lib/vae-map/favicon.ico +0 -0
  17. package/lib/vae-map/images/game.png +0 -0
  18. package/lib/vae-map/images/grid.png +0 -0
  19. package/lib/vae-map/images/marker.png +0 -0
  20. package/lib/vae-map/index.html +30 -0
  21. package/lib/vae-map/index.js +4322 -0
  22. package/lib/vae-map/style.css +1 -0
  23. package/package.json +1 -1
  24. package/plugins/L.AnimatedMarker/favicon.ico +0 -0
  25. package/plugins/L.AnimatedMarker/images/game.png +0 -0
  26. package/plugins/L.AnimatedMarker/images/grid.png +0 -0
  27. package/plugins/L.AnimatedMarker/images/marker.png +0 -0
  28. package/plugins/L.AnimatedMarker/index.html +30 -0
  29. package/plugins/L.AnimatedMarker/index.js +83 -0
  30. package/plugins/L.EchartsLayer/favicon.ico +0 -0
  31. package/plugins/L.EchartsLayer/images/game.png +0 -0
  32. package/plugins/L.EchartsLayer/images/grid.png +0 -0
  33. package/plugins/L.EchartsLayer/images/marker.png +0 -0
  34. package/plugins/L.EchartsLayer/index.html +30 -0
  35. package/plugins/L.EchartsLayer/index.js +176 -0
  36. package/plugins/L.FootageCalculator.Area/favicon.ico +0 -0
  37. package/plugins/L.FootageCalculator.Area/images/game.png +0 -0
  38. package/plugins/L.FootageCalculator.Area/images/grid.png +0 -0
  39. package/plugins/L.FootageCalculator.Area/images/marker.png +0 -0
  40. package/plugins/L.FootageCalculator.Area/index.html +30 -0
  41. package/plugins/L.FootageCalculator.Area/index.js +418 -0
  42. package/plugins/L.FootageCalculator.Line/favicon.ico +0 -0
  43. package/plugins/L.FootageCalculator.Line/images/game.png +0 -0
  44. package/plugins/L.FootageCalculator.Line/images/grid.png +0 -0
  45. package/plugins/L.FootageCalculator.Line/images/marker.png +0 -0
  46. package/plugins/L.FootageCalculator.Line/index.html +30 -0
  47. package/plugins/L.FootageCalculator.Line/index.js +416 -0
  48. package/plugins/L.GeoUtil/favicon.ico +0 -0
  49. package/plugins/L.GeoUtil/images/game.png +0 -0
  50. package/plugins/L.GeoUtil/images/grid.png +0 -0
  51. package/plugins/L.GeoUtil/images/marker.png +0 -0
  52. package/plugins/L.GeoUtil/index.html +30 -0
  53. package/plugins/L.GeoUtil/index.js +279 -0
  54. package/plugins/L.Glyphicon/favicon.ico +0 -0
  55. package/plugins/L.Glyphicon/images/game.png +0 -0
  56. package/plugins/L.Glyphicon/images/grid.png +0 -0
  57. package/plugins/L.Glyphicon/images/marker.png +0 -0
  58. package/plugins/L.Glyphicon/index.html +30 -0
  59. package/plugins/L.Glyphicon/index.js +57 -0
  60. package/plugins/L.Glyphicon/style.css +1 -0
  61. package/plugins/L.MarkerClusterX/favicon.ico +0 -0
  62. package/plugins/L.MarkerClusterX/images/game.png +0 -0
  63. package/plugins/L.MarkerClusterX/images/grid.png +0 -0
  64. package/plugins/L.MarkerClusterX/images/marker.png +0 -0
  65. package/plugins/L.MarkerClusterX/index.html +30 -0
  66. package/plugins/L.MarkerClusterX/index.js +33 -0
  67. package/plugins/L.MarkerClusterX/style.css +1 -0
  68. package/plugins/L.SafeDivOverlay/favicon.ico +0 -0
  69. package/plugins/L.SafeDivOverlay/images/game.png +0 -0
  70. package/plugins/L.SafeDivOverlay/images/grid.png +0 -0
  71. package/plugins/L.SafeDivOverlay/images/marker.png +0 -0
  72. package/plugins/L.SafeDivOverlay/index.html +30 -0
  73. package/plugins/L.SafeDivOverlay/index.js +26 -0
  74. package/plugins/L.TileLayer.ChinaProvider/favicon.ico +0 -0
  75. package/plugins/L.TileLayer.ChinaProvider/images/game.png +0 -0
  76. package/plugins/L.TileLayer.ChinaProvider/images/grid.png +0 -0
  77. package/plugins/L.TileLayer.ChinaProvider/images/marker.png +0 -0
  78. package/plugins/L.TileLayer.ChinaProvider/index.html +30 -0
  79. package/plugins/L.TileLayer.ChinaProvider/index.js +91 -0
  80. package/plugins/L.VuePopup/favicon.ico +0 -0
  81. package/plugins/L.VuePopup/images/game.png +0 -0
  82. package/plugins/L.VuePopup/images/grid.png +0 -0
  83. package/plugins/L.VuePopup/images/marker.png +0 -0
  84. package/plugins/L.VuePopup/index.html +30 -0
  85. package/plugins/L.VuePopup/index.js +68 -0
  86. package/plugins/L.VueTooltip/favicon.ico +0 -0
  87. package/plugins/L.VueTooltip/images/game.png +0 -0
  88. package/plugins/L.VueTooltip/images/grid.png +0 -0
  89. package/plugins/L.VueTooltip/images/marker.png +0 -0
  90. package/plugins/L.VueTooltip/index.html +30 -0
  91. package/plugins/L.VueTooltip/index.js +68 -0
  92. package/plugins/Mixin.Map.Measure/favicon.ico +0 -0
  93. package/plugins/Mixin.Map.Measure/images/game.png +0 -0
  94. package/plugins/Mixin.Map.Measure/images/grid.png +0 -0
  95. package/plugins/Mixin.Map.Measure/images/marker.png +0 -0
  96. package/plugins/Mixin.Map.Measure/index.html +30 -0
  97. package/plugins/Mixin.Map.Measure/index.js +84 -0
  98. package/plugins/globals/favicon.ico +0 -0
  99. package/plugins/globals/images/game.png +0 -0
  100. package/plugins/globals/images/grid.png +0 -0
  101. package/plugins/globals/images/marker.png +0 -0
  102. package/plugins/globals/index.html +30 -0
  103. package/plugins/globals/index.js +4 -0
  104. package/build/index.mjs +0 -113
  105. package/examples/App.vue +0 -18
  106. package/examples/index.js +0 -13
  107. package/examples/router/index.js +0 -35
  108. package/examples/views/amap.vue +0 -29
  109. package/examples/views/amarker.vue +0 -58
  110. package/examples/views/buffer.vue +0 -66
  111. package/examples/views/cluster.vue +0 -74
  112. package/examples/views/cover.vue +0 -85
  113. package/examples/views/draw-line.vue +0 -49
  114. package/examples/views/draw.vue +0 -54
  115. package/examples/views/echarts.vue +0 -142
  116. package/examples/views/emarker.vue +0 -39
  117. package/examples/views/image.vue +0 -182
  118. package/examples/views/index.vue +0 -61
  119. package/examples/views/lrmap.vue +0 -108
  120. package/examples/views/map.vue +0 -82
  121. package/examples/views/measure.vue +0 -86
  122. package/examples/views/parts/popup.vue +0 -39
  123. package/examples/views/parts/tooltip.vue +0 -39
  124. package/examples/views/push-area.vue +0 -52
  125. package/examples/views/push-line.vue +0 -84
  126. package/examples/views/trace.vue +0 -49
  127. package/jsconfig.json +0 -17
  128. package/src/components/resize-listener/component.jsx +0 -30
  129. package/src/components/resize-listener/index.js +0 -3
  130. package/src/composables/useAutoMessage.js +0 -41
  131. package/src/composables/useContextMenu.js +0 -99
  132. package/src/composables/useMapMeasure.js +0 -191
  133. package/src/composables/useResizeObserver.js +0 -81
  134. package/src/mixins/message.js +0 -1
  135. package/src/packages/index.js +0 -16
  136. package/src/packages/vae-amap/index.js +0 -8
  137. package/src/packages/vae-amap/style.less +0 -9
  138. package/src/packages/vae-amap/vae-amap.jsx +0 -98
  139. package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +0 -74
  140. package/src/packages/vae-cloudmap/ctrl-draw/index.vue +0 -499
  141. package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +0 -161
  142. package/src/packages/vae-cloudmap/index.js +0 -57
  143. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +0 -2690
  144. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +0 -14
  145. package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +0 -212
  146. package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +0 -780
  147. package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +0 -101
  148. package/src/packages/vae-cloudmap/style.less +0 -163
  149. package/src/packages/vae-cloudmap/vae-cloudmap.jsx +0 -272
  150. package/src/packages/vae-map/ctrl-context-menu/index.vue +0 -74
  151. package/src/packages/vae-map/ctrl-draw/index.vue +0 -498
  152. package/src/packages/vae-map/ctrl-draw-line/index.vue +0 -128
  153. package/src/packages/vae-map/index.js +0 -59
  154. package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +0 -2690
  155. package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +0 -14
  156. package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +0 -114
  157. package/src/packages/vae-map/scripts/L.Vae.Client/index.js +0 -548
  158. package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +0 -1
  159. package/src/packages/vae-map/style.less +0 -161
  160. package/src/packages/vae-map/vae-lrmap.jsx +0 -237
  161. package/src/packages/vae-map/vae-map.jsx +0 -135
  162. package/src/plugins/L.AnimatedMarker/index.js +0 -158
  163. package/src/plugins/L.EchartsLayer/index.js +0 -339
  164. package/src/plugins/L.ElasticMarker/index.js +0 -162
  165. package/src/plugins/L.FootageCalculator.Area/index.js +0 -263
  166. package/src/plugins/L.FootageCalculator.Line/index.js +0 -273
  167. package/src/plugins/L.GeoUtil/buffer.js +0 -67
  168. package/src/plugins/L.GeoUtil/index.js +0 -284
  169. package/src/plugins/L.Glyphicon/index.js +0 -91
  170. package/src/plugins/L.Glyphicon/style.less +0 -37
  171. package/src/plugins/L.MarkerClusterX/index.js +0 -93
  172. package/src/plugins/L.MarkerClusterX/style.less +0 -162
  173. package/src/plugins/L.SafeDivOverlay/index.js +0 -55
  174. package/src/plugins/L.TileLayer.ChinaProvider/index.js +0 -108
  175. package/src/plugins/L.VuePopup/index.js +0 -67
  176. package/src/plugins/L.VueTooltip/index.js +0 -63
  177. package/src/plugins/Mixin.Map.Measure/index.js +0 -248
  178. package/src/plugins/globals/index.js +0 -7
  179. package/src/utils/index.js +0 -36
  180. package/src/utils/resize-event.js +0 -45
  181. /package/{public → lib}/favicon.ico +0 -0
  182. /package/{public → lib}/images/game.png +0 -0
  183. /package/{public → lib}/images/grid.png +0 -0
  184. /package/{public → lib}/images/marker.png +0 -0
  185. /package/{public → lib/vae-amap}/index.html +0 -0
@@ -0,0 +1,418 @@
1
+ import y from "@turf/buffer";
2
+ function E(t, e, n = {}) {
3
+ const r = { type: "Feature" };
4
+ return (n.id === 0 || n.id) && (r.id = n.id), n.bbox && (r.bbox = n.bbox), r.properties = {}, r.geometry = t, r;
5
+ }
6
+ function m(t, e, n = {}) {
7
+ if (!t)
8
+ throw new Error("coordinates is required");
9
+ if (!Array.isArray(t))
10
+ throw new Error("coordinates must be an Array");
11
+ if (t.length < 2)
12
+ throw new Error("coordinates must be at least 2 numbers long");
13
+ if (!P(t[0]) || !P(t[1]))
14
+ throw new Error("coordinates must contain numbers");
15
+ return E({
16
+ type: "Point",
17
+ coordinates: t
18
+ }, e, n);
19
+ }
20
+ function S(t, e, n = {}) {
21
+ for (const s of t) {
22
+ if (s.length < 4)
23
+ throw new Error(
24
+ "Each LinearRing of a Polygon must have 4 or more Positions."
25
+ );
26
+ if (s[s.length - 1].length !== s[0].length)
27
+ throw new Error("First and last Position are not equivalent.");
28
+ for (let i = 0; i < s[s.length - 1].length; i++)
29
+ if (s[s.length - 1][i] !== s[0][i])
30
+ throw new Error("First and last Position are not equivalent.");
31
+ }
32
+ return E({
33
+ type: "Polygon",
34
+ coordinates: t
35
+ }, e, n);
36
+ }
37
+ function w(t, e, n = {}) {
38
+ if (t.length < 2)
39
+ throw new Error("coordinates must be an array of two or more positions");
40
+ return E({
41
+ type: "LineString",
42
+ coordinates: t
43
+ }, e, n);
44
+ }
45
+ function P(t) {
46
+ return !isNaN(t) && t !== null && !Array.isArray(t);
47
+ }
48
+ const I = (t) => {
49
+ let e = [];
50
+ return t.geometry.coordinates.forEach((r) => {
51
+ e.push(r.map((s) => ({
52
+ lat: s[1],
53
+ lng: s[0]
54
+ })));
55
+ }), e;
56
+ }, A = {
57
+ /**
58
+ * 点缓冲分析
59
+ * @param {L.LatLng} center 中心点
60
+ * @param {Number} distance 缓冲距离
61
+ * @param {String} units 单位
62
+ * @returns {Array<Array<L.LatLng>>} 缓冲区经纬度序列
63
+ */
64
+ bufferPoint(t, e, n = "meters") {
65
+ const r = [t.lng, t.lat], s = y(m(r), e, { units: n });
66
+ return I(s);
67
+ },
68
+ /**
69
+ * 路径缓冲分析
70
+ * @param {Array<L.LatLng>} latLngs 路径经纬度序列
71
+ * @param {Number} distance 缓冲距离
72
+ * @param {String} units 单位
73
+ * @returns {Array<Array<L.LatLng>>} 缓冲区经纬度序列
74
+ */
75
+ bufferLine(t, e, n = "meters") {
76
+ const r = t.map((i) => [i.lng, i.lat]), s = y(w(r), e, { units: n });
77
+ return I(s);
78
+ },
79
+ /**
80
+ * 区域缓冲分析
81
+ * @param {Array<L.LatLng>} latLngs 区域经纬度序列
82
+ * @param {Number} distance 缓冲距离
83
+ * @param {String} units 单位
84
+ * @returns {Array<Array<L.LatLng>>} 缓冲区经纬度序列
85
+ */
86
+ bufferArea(t, e, n = "meters") {
87
+ let r = t.map((i) => [i.lng, i.lat]);
88
+ r.push(r[0]);
89
+ const s = y(S([r]), e, { units: n });
90
+ return I(s);
91
+ }
92
+ }, j = {
93
+ /**
94
+ * 角度转弧度
95
+ * @param {角度} angle
96
+ */
97
+ angleToRad(t) {
98
+ return t * Math.PI / 180;
99
+ },
100
+ /**
101
+ * 弧度转角度
102
+ * @param {弧度} rad
103
+ */
104
+ radToAngle(t) {
105
+ return t * 180 / Math.PI;
106
+ },
107
+ /**
108
+ * 水平角度转顺时针角
109
+ * @param {角度} angle
110
+ */
111
+ toClockwiseAngle(t) {
112
+ let e = 90 - t;
113
+ return e < 0 && (e += 360), e;
114
+ },
115
+ /**
116
+ * 求两点水平弧度
117
+ * @param {L.Point} a 起点
118
+ * @param {L.Point} b 终点
119
+ */
120
+ computeRad(t, e) {
121
+ return Math.atan2(e.y - t.y, e.x - t.x);
122
+ },
123
+ /**
124
+ * 求两点水平角度
125
+ * @param {L.Point} a 起点
126
+ * @param {L.Point} b 终点
127
+ */
128
+ computeAngle(t, e) {
129
+ return this.radToAngle(this.computeRad(t, e));
130
+ },
131
+ /**
132
+ * 获取线段夹角弧度
133
+ * @param {L.Point} a 交点
134
+ * @param {L.Point} b 终点一
135
+ * @param {L.Point} c 终点二
136
+ */
137
+ segmentsRad(t, e, n) {
138
+ const r = e.x - t.x, s = e.y - t.y, i = n.x - t.x, o = n.y - t.y, h = r * i + s * o, a = r * o - s * i;
139
+ return Math.atan2(a, h);
140
+ },
141
+ /**
142
+ * 获取点到线段所在直线的垂足
143
+ * @param {L.Point} a 点
144
+ * @param {L.Point} m 线段起点
145
+ * @param {L.Point} n 线段终点
146
+ */
147
+ footPointOnLine(t, e, n) {
148
+ const r = (e.x - n.x) * (e.x - n.x) + (e.y - n.y) * (e.y - n.y), i = ((t.x - e.x) * (n.x - e.x) + (t.y - e.y) * (n.y - e.y)) / r, o = e.x + i * (n.x - e.x), h = e.y + i * (n.y - e.y);
149
+ return L.point(o, h);
150
+ },
151
+ /**
152
+ * 两线段所在直线的交点坐标,平行或共线时不返回
153
+ * @param {L.Point} a 线段一起点
154
+ * @param {L.Point} b 线段一终点
155
+ * @param {L.Point} c 线段二起点
156
+ * @param {L.Point} d 线段二终点
157
+ */
158
+ linesIntersection(t, e, n, r) {
159
+ const s = (e.y - t.y) * (r.x - n.x) - (t.x - e.x) * (n.y - r.y);
160
+ if (s) {
161
+ const i = ((e.x - t.x) * (r.x - n.x) * (n.y - t.y) + (e.y - t.y) * (r.x - n.x) * t.x - (r.y - n.y) * (e.x - t.x) * n.x) / s, o = -((e.y - t.y) * (r.y - n.y) * (n.x - t.x) + (e.x - t.x) * (r.y - n.y) * t.y - (r.x - n.x) * (e.y - t.y) * n.y) / s;
162
+ return L.point(i, o);
163
+ }
164
+ },
165
+ /**
166
+ * 根据经纬度计算累计距离,单位米
167
+ * @param {Array<L.LatLng>} latLngs
168
+ * @param {L.CRS} 坐标系,默认使用L.CRS.EPSG3857
169
+ */
170
+ distanceByLatLngs(t, e = L.CRS.EPSG3857) {
171
+ typeof e.distance != "function" && (e = L.CRS.EPSG3857);
172
+ let n = 0;
173
+ if (Array.isArray(t) && t.length > 1)
174
+ for (let r = 0; r < t.length - 1; r++)
175
+ n += e.distance(t[r], t[r + 1]);
176
+ return n;
177
+ },
178
+ /**
179
+ * 根据经纬度计算面积,单位平方米
180
+ * @param {Array<L.LatLng>} latLngs
181
+ */
182
+ areaByLatLngs(t) {
183
+ let e = t.length, n = 0, r = Math.PI / 180, s, i;
184
+ if (e > 2) {
185
+ for (let o = 0; o < e; o++)
186
+ s = t[o], i = t[(o + 1) % e], n += (i.lng - s.lng) * r * (2 + Math.sin(s.lat * r) + Math.sin(i.lat * r));
187
+ n = n * 6378137 * 6378137 / 2;
188
+ }
189
+ return Math.abs(n);
190
+ },
191
+ /**
192
+ * 根据坐标点计算面积
193
+ * @param {Array<L.Point>} points
194
+ */
195
+ areaByPoints(t) {
196
+ let e = 0;
197
+ if (Array.isArray(t) && t.length > 2) {
198
+ let n = 0;
199
+ for (let r = 0; r < t.length; r++)
200
+ r + 1 == t.length ? n += t[r].x * t[0].y - t[0].x * t[r].y : n += t[r].x * t[r + 1].y - t[r + 1].x * t[r].y;
201
+ e = 1 / 2 * Math.abs(n);
202
+ }
203
+ return e;
204
+ },
205
+ /**
206
+ * 转换面积,增加单位
207
+ * @param {number} area 面积数字,单位平方米
208
+ */
209
+ readableArea(t) {
210
+ let e = 0;
211
+ return t > 1e3 * 1e3 ? e = (t / (1e3 * 1e3)).toFixed(2) + " km²" : e = Math.ceil(t) + " m²", e;
212
+ },
213
+ /**
214
+ * 点是否在多边形内,射线法
215
+ * @param {L.Point} point 给定点
216
+ * @param {Array<L.Point>} points 多边形坐标
217
+ * @returns {Boolean} 是否置于多边形内或边界上
218
+ */
219
+ isPointInPoly(t, e) {
220
+ const n = t.x, r = t.y;
221
+ let s = !1, i = !1;
222
+ const o = e.length;
223
+ for (let h = 0, a = o - 1; h < o; a = h, h++) {
224
+ const l = e[h].x, c = e[h].y, f = e[a].x, d = e[a].y;
225
+ if ((l === n && c === r || f === n && d === r) && (i = !0), c < r && d >= r || c >= r && d < r) {
226
+ const u = l + (r - c) * (f - l) / (d - c);
227
+ i = u === n, u > n && (s = !s);
228
+ }
229
+ if (i)
230
+ break;
231
+ }
232
+ return i || s;
233
+ },
234
+ /**
235
+ * 点到面的距离,在内部视为0
236
+ * @param {L.Point} point 给定点
237
+ * @param {Array<L.Point>} points 多边形坐标
238
+ * @param {L.CRS} crs 地图CRS
239
+ * @returns {Boolean} 距离数值,若CRS可用,单位为米
240
+ */
241
+ distanceToPoly(t, e, n) {
242
+ let r = 0;
243
+ if (!this.isPointInPoly(t, e)) {
244
+ let s = [], i = [];
245
+ const o = e.length;
246
+ for (let l = 0, c = o - 1; l < o; c = l, l++)
247
+ s.push(L.LineUtil.pointToSegmentDistance(t, e[l], e[c])), i.push(L.LineUtil.closestPointOnSegment(t, e[l], e[c]));
248
+ r = _.min(s);
249
+ const h = _.indexOf(s, r), a = i[h];
250
+ if (n && n.unproject) {
251
+ const l = n.unproject(t), c = n.unproject(a);
252
+ r = n.distance(l, c);
253
+ }
254
+ }
255
+ return r;
256
+ },
257
+ /**
258
+ * 点到折线的距离
259
+ * @param {L.Point} point 给定点
260
+ * @param {Array<L.Point>} points 折线坐标
261
+ * @param {L.CRS} crs 地图CRS
262
+ * @param {Boolean} 距离数值,若CRS可用,单位为米
263
+ */
264
+ distanceToLine(t, e, n) {
265
+ let r = 0, s = [], i = [];
266
+ if (Array.isArray(e) && e.length > 1) {
267
+ for (let a = 0; a < e.length - 1; a++)
268
+ s.push(L.LineUtil.pointToSegmentDistance(t, e[a], e[a + 1])), i.push(L.LineUtil.closestPointOnSegment(t, e[a], e[a + 1]));
269
+ r = _.min(s);
270
+ const o = _.indexOf(s, r), h = i[o];
271
+ if (n && n.unproject) {
272
+ const a = n.unproject(t), l = n.unproject(h);
273
+ r = n.distance(a, l);
274
+ }
275
+ }
276
+ return r;
277
+ }
278
+ };
279
+ L.GeoUtil = L.extend(L.GeoUtil || {}, _.assign(j, A));
280
+ L.FootageCalculator = L.FootageCalculator || {};
281
+ L.FootageCalculator.Area = L.Evented.extend({
282
+ options: {
283
+ crs: L.CRS.EPSG3857,
284
+ // 坐标转换类
285
+ latlngs: [],
286
+ // 边界经纬度
287
+ headStart: null,
288
+ // 机头经纬度
289
+ headEnd: null,
290
+ // 机头终点经纬度
291
+ tailStart: null,
292
+ // 机尾经纬度
293
+ tailEnd: null
294
+ /// 机尾终点经纬度
295
+ },
296
+ initialize(t) {
297
+ L.setOptions(this, t);
298
+ const { crs: e, latlngs: n, headStart: r, headEnd: s, tailStart: i, tailEnd: o } = this.options;
299
+ if (e && e.project && e.unproject)
300
+ this.crs = e;
301
+ else
302
+ throw new Error("请传入正确的crs参数");
303
+ if (Array.isArray(n) && n.length > 2)
304
+ this.latlngs = n;
305
+ else
306
+ throw new Error("请传入正确的latlngs参数");
307
+ function h(l, c) {
308
+ if (l < 0)
309
+ throw new Error(`请传入正确的${c}参数,此参数必须是latlngs的某个节点`);
310
+ }
311
+ if (this.hsIndex = _.findIndex(n, (l) => _.isEqual(l, r)), h(this.hsIndex, "headStart"), this.heIndex = _.findIndex(n, (l) => _.isEqual(l, s)), h(this.heIndex, "headEnd"), this.tsIndex = _.findIndex(n, (l) => _.isEqual(l, i)), h(this.tsIndex, "tailStart"), this.teIndex = _.findIndex(n, (l) => _.isEqual(l, o)), h(this.teIndex, "tailEnd"), _.uniq([this.hsIndex, this.heIndex, this.tsIndex, this.teIndex]).length < 4)
312
+ throw new Error("机头机尾坐标不允许重复");
313
+ const a = Math.abs(this.hsIndex - this.tsIndex);
314
+ if (a != 1 && a != n.length - 1)
315
+ throw new Error("机头和机尾起点必须相邻");
316
+ this.initParams();
317
+ },
318
+ // 初始化参数
319
+ initParams() {
320
+ this.points = this.latlngs.map((s) => this.crs.project(p(s)));
321
+ const t = this.latlngs.length;
322
+ let e = [], n = [], r = this.hsIndex < this.tsIndex;
323
+ if (Math.abs(this.hsIndex - this.tsIndex) == t - 1 && (r = this.tsIndex == 0), r) {
324
+ let s = this.hsIndex;
325
+ this.heIndex > this.hsIndex && (s += t);
326
+ for (let o = this.heIndex; o <= s; o++)
327
+ e.push(this.points[o >= t ? o - t : o]);
328
+ e.reverse();
329
+ let i = this.teIndex;
330
+ this.tsIndex > this.teIndex && (i += t);
331
+ for (let o = this.tsIndex; o <= i; o++)
332
+ n.push(this.points[o >= t ? o - t : o]);
333
+ } else {
334
+ let s = this.heIndex;
335
+ this.hsIndex > this.heIndex && (s += t);
336
+ for (let o = this.hsIndex; o <= s; o++)
337
+ e.push(this.points[o >= t ? o - t : o]);
338
+ let i = this.tsIndex;
339
+ this.teIndex > this.tsIndex && (i += t);
340
+ for (let o = this.teIndex; o <= i; o++)
341
+ n.push(this.points[o >= t ? o - t : o]);
342
+ n.reverse();
343
+ }
344
+ this.headSegments = [], e.forEach((s, i) => {
345
+ i > 0 && this.headSegments.push({ start: e[i - 1], end: s });
346
+ }), this.tailSegments = [], n.forEach((s, i) => {
347
+ i > 0 && this.tailSegments.push({ start: n[i - 1], end: s });
348
+ });
349
+ },
350
+ /**
351
+ * 执行计算
352
+ * @param {L.LatLng} headStart 机头起点
353
+ * @param {L.LatLng} tailStart 机尾起点
354
+ * @param {Number} headDistance 机头推进距离
355
+ * @param {Number} tailDistance 机尾推进距离
356
+ * @returns {L.LatLng} headEnd 推进后机头的经纬度
357
+ * @returns {L.LatLng} tailEnd 推进后机尾的经纬度
358
+ * @returns {Array<L.LatLng>} latlngs 推进的区域范围
359
+ */
360
+ doCalculate({ headStart: t, tailStart: e, headDistance: n, tailDistance: r }) {
361
+ const s = this.crs.project(p(t)), i = this.crs.project(p(e)), o = this.calcWorkPath(s, this.headSegments, n), h = this.calcWorkPath(i, this.tailSegments, r), a = this.crs.unproject(_.last(o.path)), l = this.crs.unproject(_.last(h.path));
362
+ let c = [], f = o.path, d = h.path;
363
+ return d.reverse(), new Array(f, d).forEach((u) => {
364
+ u.forEach((x) => {
365
+ c.push(this.crs.unproject(x));
366
+ });
367
+ }), { headEnd: a, tailEnd: l, latlngs: c };
368
+ },
369
+ /**
370
+ * 计算一次推进的结果
371
+ * @param {L.Point} start 起点
372
+ * @param {Array} segments 线段
373
+ * @param {Number} distance 推进距离
374
+ */
375
+ calcWorkPath(t, e, n) {
376
+ let r = 0, s = -1, i = -1, o;
377
+ e.forEach((d, u) => {
378
+ if (i < 0) {
379
+ let x = d.start;
380
+ s < 0 && L.LineUtil.pointToSegmentDistance(t, d.start, d.end) < 0.01 && (s = u, x = t);
381
+ let g = 0;
382
+ s >= 0 && (g = x.distanceTo(d.end)), r + g >= n && (i = u, o = this.calcEndPointOnLine(x, d.end, n - r)), r += g;
383
+ }
384
+ });
385
+ let h = i;
386
+ i < 0 && (h = e.length - 1, o = _.last(e).end);
387
+ let a = [t];
388
+ for (let d = s; d < h; d++)
389
+ a.push(e[d].end);
390
+ if (a.push(o), a.length == 2 && a[0].x == a[1].x && a[0].y == a[1].y) {
391
+ const d = _.last(e), u = L.GeoUtil.computeRad(d.start, d.end);
392
+ a[0] = a[1].subtract(L.point(0.01 * Math.cos(u), 0.01 * Math.sin(u)));
393
+ }
394
+ let l = [];
395
+ if (h == i) {
396
+ l = [o];
397
+ for (let d = h; d < e.length - 1; d++)
398
+ l.push(e[d].end);
399
+ l.push(_.last(e).end);
400
+ }
401
+ let c = e[i];
402
+ i < 0 && (c = _.last(e));
403
+ let f = L.GeoUtil.computeRad(c.start, c.end);
404
+ return { path: a, remainingPath: l, endRad: f };
405
+ },
406
+ // 获取a点向b点方向延伸distance后的坐标
407
+ calcEndPointOnLine(t, e, n) {
408
+ const r = L.GeoUtil.computeRad(t, e), s = n * Math.cos(r), i = n * Math.sin(r);
409
+ return t.add(L.point(s, i));
410
+ }
411
+ });
412
+ function p(t) {
413
+ return t instanceof L.LatLng || (t = L.latLng(t)), t;
414
+ }
415
+ L.footageCalculator = L.footageCalculator || {};
416
+ L.footageCalculator.area = function(t) {
417
+ return new L.FootageCalculator.Area(t);
418
+ };
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
8
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
9
+ <style type="text/css">
10
+ html {
11
+ width: 100%;
12
+ height: 100%;
13
+ }
14
+
15
+ body {
16
+ width: 100%;
17
+ height: 100%;
18
+ margin: 0;
19
+ padding: 0;
20
+ overflow: hidden;
21
+ }
22
+ </style>
23
+ <title>...</title>
24
+ </head>
25
+
26
+ <body>
27
+ <div id="app"></div>
28
+ </body>
29
+
30
+ </html>