@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.
- package/lib/index.js +5376 -0
- package/lib/style.css +1 -0
- package/lib/vae-amap/favicon.ico +0 -0
- package/lib/vae-amap/images/game.png +0 -0
- package/lib/vae-amap/images/grid.png +0 -0
- package/lib/vae-amap/images/marker.png +0 -0
- package/lib/vae-amap/index.js +209 -0
- package/lib/vae-amap/style.css +1 -0
- package/lib/vae-cloudmap/favicon.ico +0 -0
- package/lib/vae-cloudmap/images/game.png +0 -0
- package/lib/vae-cloudmap/images/grid.png +0 -0
- package/lib/vae-cloudmap/images/marker.png +0 -0
- package/lib/vae-cloudmap/index.html +30 -0
- package/lib/vae-cloudmap/index.js +4085 -0
- package/lib/vae-cloudmap/style.css +1 -0
- package/lib/vae-map/favicon.ico +0 -0
- package/lib/vae-map/images/game.png +0 -0
- package/lib/vae-map/images/grid.png +0 -0
- package/lib/vae-map/images/marker.png +0 -0
- package/lib/vae-map/index.html +30 -0
- package/lib/vae-map/index.js +4322 -0
- package/lib/vae-map/style.css +1 -0
- package/package.json +1 -1
- package/plugins/L.AnimatedMarker/favicon.ico +0 -0
- package/plugins/L.AnimatedMarker/images/game.png +0 -0
- package/plugins/L.AnimatedMarker/images/grid.png +0 -0
- package/plugins/L.AnimatedMarker/images/marker.png +0 -0
- package/plugins/L.AnimatedMarker/index.html +30 -0
- package/plugins/L.AnimatedMarker/index.js +83 -0
- package/plugins/L.EchartsLayer/favicon.ico +0 -0
- package/plugins/L.EchartsLayer/images/game.png +0 -0
- package/plugins/L.EchartsLayer/images/grid.png +0 -0
- package/plugins/L.EchartsLayer/images/marker.png +0 -0
- package/plugins/L.EchartsLayer/index.html +30 -0
- package/plugins/L.EchartsLayer/index.js +176 -0
- package/plugins/L.FootageCalculator.Area/favicon.ico +0 -0
- package/plugins/L.FootageCalculator.Area/images/game.png +0 -0
- package/plugins/L.FootageCalculator.Area/images/grid.png +0 -0
- package/plugins/L.FootageCalculator.Area/images/marker.png +0 -0
- package/plugins/L.FootageCalculator.Area/index.html +30 -0
- package/plugins/L.FootageCalculator.Area/index.js +418 -0
- package/plugins/L.FootageCalculator.Line/favicon.ico +0 -0
- package/plugins/L.FootageCalculator.Line/images/game.png +0 -0
- package/plugins/L.FootageCalculator.Line/images/grid.png +0 -0
- package/plugins/L.FootageCalculator.Line/images/marker.png +0 -0
- package/plugins/L.FootageCalculator.Line/index.html +30 -0
- package/plugins/L.FootageCalculator.Line/index.js +416 -0
- package/plugins/L.GeoUtil/favicon.ico +0 -0
- package/plugins/L.GeoUtil/images/game.png +0 -0
- package/plugins/L.GeoUtil/images/grid.png +0 -0
- package/plugins/L.GeoUtil/images/marker.png +0 -0
- package/plugins/L.GeoUtil/index.html +30 -0
- package/plugins/L.GeoUtil/index.js +279 -0
- package/plugins/L.Glyphicon/favicon.ico +0 -0
- package/plugins/L.Glyphicon/images/game.png +0 -0
- package/plugins/L.Glyphicon/images/grid.png +0 -0
- package/plugins/L.Glyphicon/images/marker.png +0 -0
- package/plugins/L.Glyphicon/index.html +30 -0
- package/plugins/L.Glyphicon/index.js +57 -0
- package/plugins/L.Glyphicon/style.css +1 -0
- package/plugins/L.MarkerClusterX/favicon.ico +0 -0
- package/plugins/L.MarkerClusterX/images/game.png +0 -0
- package/plugins/L.MarkerClusterX/images/grid.png +0 -0
- package/plugins/L.MarkerClusterX/images/marker.png +0 -0
- package/plugins/L.MarkerClusterX/index.html +30 -0
- package/plugins/L.MarkerClusterX/index.js +33 -0
- package/plugins/L.MarkerClusterX/style.css +1 -0
- package/plugins/L.SafeDivOverlay/favicon.ico +0 -0
- package/plugins/L.SafeDivOverlay/images/game.png +0 -0
- package/plugins/L.SafeDivOverlay/images/grid.png +0 -0
- package/plugins/L.SafeDivOverlay/images/marker.png +0 -0
- package/plugins/L.SafeDivOverlay/index.html +30 -0
- package/plugins/L.SafeDivOverlay/index.js +26 -0
- package/plugins/L.TileLayer.ChinaProvider/favicon.ico +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/game.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/grid.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/marker.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/index.html +30 -0
- package/plugins/L.TileLayer.ChinaProvider/index.js +91 -0
- package/plugins/L.VuePopup/favicon.ico +0 -0
- package/plugins/L.VuePopup/images/game.png +0 -0
- package/plugins/L.VuePopup/images/grid.png +0 -0
- package/plugins/L.VuePopup/images/marker.png +0 -0
- package/plugins/L.VuePopup/index.html +30 -0
- package/plugins/L.VuePopup/index.js +68 -0
- package/plugins/L.VueTooltip/favicon.ico +0 -0
- package/plugins/L.VueTooltip/images/game.png +0 -0
- package/plugins/L.VueTooltip/images/grid.png +0 -0
- package/plugins/L.VueTooltip/images/marker.png +0 -0
- package/plugins/L.VueTooltip/index.html +30 -0
- package/plugins/L.VueTooltip/index.js +68 -0
- package/plugins/Mixin.Map.Measure/favicon.ico +0 -0
- package/plugins/Mixin.Map.Measure/images/game.png +0 -0
- package/plugins/Mixin.Map.Measure/images/grid.png +0 -0
- package/plugins/Mixin.Map.Measure/images/marker.png +0 -0
- package/plugins/Mixin.Map.Measure/index.html +30 -0
- package/plugins/Mixin.Map.Measure/index.js +84 -0
- package/plugins/globals/favicon.ico +0 -0
- package/plugins/globals/images/game.png +0 -0
- package/plugins/globals/images/grid.png +0 -0
- package/plugins/globals/images/marker.png +0 -0
- package/plugins/globals/index.html +30 -0
- package/plugins/globals/index.js +4 -0
- package/build/index.mjs +0 -113
- package/examples/App.vue +0 -18
- package/examples/index.js +0 -13
- package/examples/router/index.js +0 -35
- package/examples/views/amap.vue +0 -29
- package/examples/views/amarker.vue +0 -58
- package/examples/views/buffer.vue +0 -66
- package/examples/views/cluster.vue +0 -74
- package/examples/views/cover.vue +0 -85
- package/examples/views/draw-line.vue +0 -49
- package/examples/views/draw.vue +0 -54
- package/examples/views/echarts.vue +0 -142
- package/examples/views/emarker.vue +0 -39
- package/examples/views/image.vue +0 -182
- package/examples/views/index.vue +0 -61
- package/examples/views/lrmap.vue +0 -108
- package/examples/views/map.vue +0 -82
- package/examples/views/measure.vue +0 -86
- package/examples/views/parts/popup.vue +0 -39
- package/examples/views/parts/tooltip.vue +0 -39
- package/examples/views/push-area.vue +0 -52
- package/examples/views/push-line.vue +0 -84
- package/examples/views/trace.vue +0 -49
- package/jsconfig.json +0 -17
- package/src/components/resize-listener/component.jsx +0 -30
- package/src/components/resize-listener/index.js +0 -3
- package/src/composables/useAutoMessage.js +0 -41
- package/src/composables/useContextMenu.js +0 -99
- package/src/composables/useMapMeasure.js +0 -191
- package/src/composables/useResizeObserver.js +0 -81
- package/src/mixins/message.js +0 -1
- package/src/packages/index.js +0 -16
- package/src/packages/vae-amap/index.js +0 -8
- package/src/packages/vae-amap/style.less +0 -9
- package/src/packages/vae-amap/vae-amap.jsx +0 -98
- package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +0 -74
- package/src/packages/vae-cloudmap/ctrl-draw/index.vue +0 -499
- package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +0 -161
- package/src/packages/vae-cloudmap/index.js +0 -57
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +0 -2690
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +0 -14
- package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +0 -212
- package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +0 -780
- package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +0 -101
- package/src/packages/vae-cloudmap/style.less +0 -163
- package/src/packages/vae-cloudmap/vae-cloudmap.jsx +0 -272
- package/src/packages/vae-map/ctrl-context-menu/index.vue +0 -74
- package/src/packages/vae-map/ctrl-draw/index.vue +0 -498
- package/src/packages/vae-map/ctrl-draw-line/index.vue +0 -128
- package/src/packages/vae-map/index.js +0 -59
- package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +0 -2690
- package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +0 -14
- package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +0 -114
- package/src/packages/vae-map/scripts/L.Vae.Client/index.js +0 -548
- package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +0 -1
- package/src/packages/vae-map/style.less +0 -161
- package/src/packages/vae-map/vae-lrmap.jsx +0 -237
- package/src/packages/vae-map/vae-map.jsx +0 -135
- package/src/plugins/L.AnimatedMarker/index.js +0 -158
- package/src/plugins/L.EchartsLayer/index.js +0 -339
- package/src/plugins/L.ElasticMarker/index.js +0 -162
- package/src/plugins/L.FootageCalculator.Area/index.js +0 -263
- package/src/plugins/L.FootageCalculator.Line/index.js +0 -273
- package/src/plugins/L.GeoUtil/buffer.js +0 -67
- package/src/plugins/L.GeoUtil/index.js +0 -284
- package/src/plugins/L.Glyphicon/index.js +0 -91
- package/src/plugins/L.Glyphicon/style.less +0 -37
- package/src/plugins/L.MarkerClusterX/index.js +0 -93
- package/src/plugins/L.MarkerClusterX/style.less +0 -162
- package/src/plugins/L.SafeDivOverlay/index.js +0 -55
- package/src/plugins/L.TileLayer.ChinaProvider/index.js +0 -108
- package/src/plugins/L.VuePopup/index.js +0 -67
- package/src/plugins/L.VueTooltip/index.js +0 -63
- package/src/plugins/Mixin.Map.Measure/index.js +0 -248
- package/src/plugins/globals/index.js +0 -7
- package/src/utils/index.js +0 -36
- package/src/utils/resize-event.js +0 -45
- /package/{public → lib}/favicon.ico +0 -0
- /package/{public → lib}/images/game.png +0 -0
- /package/{public → lib}/images/grid.png +0 -0
- /package/{public → lib}/images/marker.png +0 -0
- /package/{public → lib/vae-amap}/index.html +0 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import x from "@turf/buffer";
|
|
2
|
+
function m(t, e, n = {}) {
|
|
3
|
+
const o = { type: "Feature" };
|
|
4
|
+
return (n.id === 0 || n.id) && (o.id = n.id), n.bbox && (o.bbox = n.bbox), o.properties = {}, o.geometry = t, o;
|
|
5
|
+
}
|
|
6
|
+
function w(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 m({
|
|
16
|
+
type: "Point",
|
|
17
|
+
coordinates: t
|
|
18
|
+
}, e, n);
|
|
19
|
+
}
|
|
20
|
+
function O(t, e, n = {}) {
|
|
21
|
+
for (const r of t) {
|
|
22
|
+
if (r.length < 4)
|
|
23
|
+
throw new Error(
|
|
24
|
+
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
25
|
+
);
|
|
26
|
+
if (r[r.length - 1].length !== r[0].length)
|
|
27
|
+
throw new Error("First and last Position are not equivalent.");
|
|
28
|
+
for (let s = 0; s < r[r.length - 1].length; s++)
|
|
29
|
+
if (r[r.length - 1][s] !== r[0][s])
|
|
30
|
+
throw new Error("First and last Position are not equivalent.");
|
|
31
|
+
}
|
|
32
|
+
return m({
|
|
33
|
+
type: "Polygon",
|
|
34
|
+
coordinates: t
|
|
35
|
+
}, e, n);
|
|
36
|
+
}
|
|
37
|
+
function R(t, e, n = {}) {
|
|
38
|
+
if (t.length < 2)
|
|
39
|
+
throw new Error("coordinates must be an array of two or more positions");
|
|
40
|
+
return m({
|
|
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 P = (t) => {
|
|
49
|
+
let e = [];
|
|
50
|
+
return t.geometry.coordinates.forEach((o) => {
|
|
51
|
+
e.push(o.map((r) => ({
|
|
52
|
+
lat: r[1],
|
|
53
|
+
lng: r[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 o = [t.lng, t.lat], r = x(w(o), e, { units: n });
|
|
66
|
+
return P(r);
|
|
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 o = t.map((s) => [s.lng, s.lat]), r = x(R(o), e, { units: n });
|
|
77
|
+
return P(r);
|
|
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 o = t.map((s) => [s.lng, s.lat]);
|
|
88
|
+
o.push(o[0]);
|
|
89
|
+
const r = x(O([o]), e, { units: n });
|
|
90
|
+
return P(r);
|
|
91
|
+
}
|
|
92
|
+
}, U = {
|
|
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 o = e.x - t.x, r = e.y - t.y, s = n.x - t.x, i = n.y - t.y, l = o * s + r * i, a = o * i - r * s;
|
|
139
|
+
return Math.atan2(a, l);
|
|
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 o = (e.x - n.x) * (e.x - n.x) + (e.y - n.y) * (e.y - n.y), s = ((t.x - e.x) * (n.x - e.x) + (t.y - e.y) * (n.y - e.y)) / o, i = e.x + s * (n.x - e.x), l = e.y + s * (n.y - e.y);
|
|
149
|
+
return L.point(i, l);
|
|
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, o) {
|
|
159
|
+
const r = (e.y - t.y) * (o.x - n.x) - (t.x - e.x) * (n.y - o.y);
|
|
160
|
+
if (r) {
|
|
161
|
+
const s = ((e.x - t.x) * (o.x - n.x) * (n.y - t.y) + (e.y - t.y) * (o.x - n.x) * t.x - (o.y - n.y) * (e.x - t.x) * n.x) / r, i = -((e.y - t.y) * (o.y - n.y) * (n.x - t.x) + (e.x - t.x) * (o.y - n.y) * t.y - (o.x - n.x) * (e.y - t.y) * n.y) / r;
|
|
162
|
+
return L.point(s, i);
|
|
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 o = 0; o < t.length - 1; o++)
|
|
175
|
+
n += e.distance(t[o], t[o + 1]);
|
|
176
|
+
return n;
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* 根据经纬度计算面积,单位平方米
|
|
180
|
+
* @param {Array<L.LatLng>} latLngs
|
|
181
|
+
*/
|
|
182
|
+
areaByLatLngs(t) {
|
|
183
|
+
let e = t.length, n = 0, o = Math.PI / 180, r, s;
|
|
184
|
+
if (e > 2) {
|
|
185
|
+
for (let i = 0; i < e; i++)
|
|
186
|
+
r = t[i], s = t[(i + 1) % e], n += (s.lng - r.lng) * o * (2 + Math.sin(r.lat * o) + Math.sin(s.lat * o));
|
|
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 o = 0; o < t.length; o++)
|
|
200
|
+
o + 1 == t.length ? n += t[o].x * t[0].y - t[0].x * t[o].y : n += t[o].x * t[o + 1].y - t[o + 1].x * t[o].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, o = t.y;
|
|
221
|
+
let r = !1, s = !1;
|
|
222
|
+
const i = e.length;
|
|
223
|
+
for (let l = 0, a = i - 1; l < i; a = l, l++) {
|
|
224
|
+
const c = e[l].x, u = e[l].y, h = e[a].x, f = e[a].y;
|
|
225
|
+
if ((c === n && u === o || h === n && f === o) && (s = !0), u < o && f >= o || u >= o && f < o) {
|
|
226
|
+
const g = c + (o - u) * (h - c) / (f - u);
|
|
227
|
+
s = g === n, g > n && (r = !r);
|
|
228
|
+
}
|
|
229
|
+
if (s)
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
return s || r;
|
|
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 o = 0;
|
|
243
|
+
if (!this.isPointInPoly(t, e)) {
|
|
244
|
+
let r = [], s = [];
|
|
245
|
+
const i = e.length;
|
|
246
|
+
for (let c = 0, u = i - 1; c < i; u = c, c++)
|
|
247
|
+
r.push(L.LineUtil.pointToSegmentDistance(t, e[c], e[u])), s.push(L.LineUtil.closestPointOnSegment(t, e[c], e[u]));
|
|
248
|
+
o = _.min(r);
|
|
249
|
+
const l = _.indexOf(r, o), a = s[l];
|
|
250
|
+
if (n && n.unproject) {
|
|
251
|
+
const c = n.unproject(t), u = n.unproject(a);
|
|
252
|
+
o = n.distance(c, u);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return o;
|
|
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 o = 0, r = [], s = [];
|
|
266
|
+
if (Array.isArray(e) && e.length > 1) {
|
|
267
|
+
for (let a = 0; a < e.length - 1; a++)
|
|
268
|
+
r.push(L.LineUtil.pointToSegmentDistance(t, e[a], e[a + 1])), s.push(L.LineUtil.closestPointOnSegment(t, e[a], e[a + 1]));
|
|
269
|
+
o = _.min(r);
|
|
270
|
+
const i = _.indexOf(r, o), l = s[i];
|
|
271
|
+
if (n && n.unproject) {
|
|
272
|
+
const a = n.unproject(t), c = n.unproject(l);
|
|
273
|
+
o = n.distance(a, c);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return o;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
L.GeoUtil = L.extend(L.GeoUtil || {}, _.assign(U, A));
|
|
280
|
+
L.FootageCalculator = L.FootageCalculator || {};
|
|
281
|
+
L.FootageCalculator.Line = L.Evented.extend({
|
|
282
|
+
options: {
|
|
283
|
+
crs: L.CRS.EPSG3857,
|
|
284
|
+
// 坐标转换类
|
|
285
|
+
latlngs: [],
|
|
286
|
+
// 中心线
|
|
287
|
+
width: 0
|
|
288
|
+
// 巷道宽度
|
|
289
|
+
},
|
|
290
|
+
initialize(t) {
|
|
291
|
+
L.setOptions(this, t);
|
|
292
|
+
const e = this.options.crs;
|
|
293
|
+
if (e && e.project && e.unproject)
|
|
294
|
+
this.crs = e;
|
|
295
|
+
else
|
|
296
|
+
throw new Error("请传入正确的crs参数");
|
|
297
|
+
const n = this.options.latlngs, o = this.options.width;
|
|
298
|
+
if (Array.isArray(n) && n.length > 1 && o > 0)
|
|
299
|
+
this.latlngs = n, this.width = o;
|
|
300
|
+
else
|
|
301
|
+
throw new Error("请传入正确的latlngs和width参数");
|
|
302
|
+
this.initParams();
|
|
303
|
+
},
|
|
304
|
+
// 初始化参数
|
|
305
|
+
initParams() {
|
|
306
|
+
this.points = this.latlngs.map((t) => (t instanceof L.LatLng || (t = L.latLng(t)), this.crs.project(t))), this.segments = [], this.points.forEach((t, e) => {
|
|
307
|
+
if (e > 0) {
|
|
308
|
+
let n = 0;
|
|
309
|
+
e > 1 && (n = this.calcOffsetDistance(
|
|
310
|
+
this.points[e - 2],
|
|
311
|
+
this.points[e - 1],
|
|
312
|
+
this.points[e],
|
|
313
|
+
this.width / 2
|
|
314
|
+
)), this.segments.push({
|
|
315
|
+
start: this.points[e - 1],
|
|
316
|
+
end: t,
|
|
317
|
+
offsetDistance: n
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
/**
|
|
323
|
+
* 执行计算
|
|
324
|
+
* @param {L.LatLng} start 起点
|
|
325
|
+
* @param {Number} distance 推进距离,米
|
|
326
|
+
*/
|
|
327
|
+
doCalculate({ start: t, distance: e }) {
|
|
328
|
+
if (e > 0) {
|
|
329
|
+
t instanceof L.LatLng || (t = L.latLng(t));
|
|
330
|
+
const n = this.crs.project(t), { path: o, remainingPath: r, endRad: s } = this.calcWorkPath(n, this.segments, e), i = this.calcWorkArea({ path: o, width: this.width / 2 }), l = o.map((h) => this.crs.unproject(h)), a = i.map((h) => this.crs.unproject(h)), c = r.map((h) => this.crs.unproject(h)), u = L.GeoUtil.toClockwiseAngle(L.GeoUtil.radToAngle(s));
|
|
331
|
+
return { path: l, remainingPath: c, area: a, endAngle: u };
|
|
332
|
+
} else
|
|
333
|
+
throw new Error("distance参数必须大于0");
|
|
334
|
+
},
|
|
335
|
+
/**
|
|
336
|
+
* 计算一次推进的结果
|
|
337
|
+
* @param {L.Point} start 起点
|
|
338
|
+
* @param {Array} segments 线段
|
|
339
|
+
* @param {Number} distance 推进距离
|
|
340
|
+
*/
|
|
341
|
+
calcWorkPath(t, e, n) {
|
|
342
|
+
let o = 0, r = -1, s = -1, i;
|
|
343
|
+
e.forEach((f, g) => {
|
|
344
|
+
if (s < 0) {
|
|
345
|
+
n += f.offsetDistance;
|
|
346
|
+
let y = f.start;
|
|
347
|
+
r < 0 && L.LineUtil.pointToSegmentDistance(t, f.start, f.end) < 0.01 && (r = g, y = t);
|
|
348
|
+
let d = 0;
|
|
349
|
+
r >= 0 && (d = y.distanceTo(f.end)), o + d >= n && (s = g, i = this.calcEndPointOnLine(y, f.end, n - o)), o += d;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
let l = s;
|
|
353
|
+
s < 0 && (l = e.length - 1, i = _.last(e).end);
|
|
354
|
+
let a = [t];
|
|
355
|
+
for (let f = r; f < l; f++)
|
|
356
|
+
a.push(e[f].end);
|
|
357
|
+
if (a.push(i), a.length == 2 && a[0].x == a[1].x && a[0].y == a[1].y) {
|
|
358
|
+
const f = _.last(e), g = L.GeoUtil.computeRad(f.start, f.end);
|
|
359
|
+
a[0] = a[1].subtract(L.point(0.01 * Math.cos(g), 0.01 * Math.sin(g)));
|
|
360
|
+
}
|
|
361
|
+
let c = [];
|
|
362
|
+
if (l == s) {
|
|
363
|
+
c = [i];
|
|
364
|
+
for (let f = l; f < e.length - 1; f++)
|
|
365
|
+
c.push(e[f].end);
|
|
366
|
+
c.push(_.last(e).end);
|
|
367
|
+
}
|
|
368
|
+
let u = e[s];
|
|
369
|
+
s < 0 && (u = _.last(e));
|
|
370
|
+
let h = L.GeoUtil.computeRad(u.start, u.end);
|
|
371
|
+
return { path: a, remainingPath: c, endRad: h };
|
|
372
|
+
},
|
|
373
|
+
/**
|
|
374
|
+
* 根据中心线路径和法线长度,计算推进范围
|
|
375
|
+
* @param {Array<L.Point>} path 推进路径
|
|
376
|
+
* @param {Number} width 法线长度
|
|
377
|
+
*/
|
|
378
|
+
calcWorkArea({ path: t, width: e }) {
|
|
379
|
+
let n = [], o = [];
|
|
380
|
+
return t.map((s, i) => {
|
|
381
|
+
if (i == 0) {
|
|
382
|
+
const l = L.GeoUtil.computeRad(t[i], t[i + 1]);
|
|
383
|
+
return this.calcVerticalOffestPoints(s, l, e);
|
|
384
|
+
} else if (i == t.length - 1) {
|
|
385
|
+
const l = L.GeoUtil.computeRad(t[i - 1], t[i]);
|
|
386
|
+
return this.calcVerticalOffestPoints(s, l, e);
|
|
387
|
+
} else {
|
|
388
|
+
const l = L.GeoUtil.computeRad(t[i - 1], t[i]), a = L.GeoUtil.computeRad(t[i], t[i + 1]), c = this.calcVerticalOffestPoints(t[i - 1], l, e), u = this.calcVerticalOffestPoints(t[i], l, e), h = this.calcVerticalOffestPoints(t[i], a, e), f = this.calcVerticalOffestPoints(t[i + 1], a, e), g = L.GeoUtil.linesIntersection(c[0], u[0], h[0], f[0]), y = L.GeoUtil.linesIntersection(c[1], u[1], h[1], f[1]);
|
|
389
|
+
if (g && y)
|
|
390
|
+
return [g, y];
|
|
391
|
+
}
|
|
392
|
+
}).forEach((s) => {
|
|
393
|
+
s && (n.push(s[0]), o.push(s[1]));
|
|
394
|
+
}), _.concat(n, _.reverse(o));
|
|
395
|
+
},
|
|
396
|
+
// 获取a点向b点方向延伸distance后的坐标
|
|
397
|
+
calcEndPointOnLine(t, e, n) {
|
|
398
|
+
const o = L.GeoUtil.computeRad(t, e), r = n * Math.cos(o), s = n * Math.sin(o);
|
|
399
|
+
return t.add(L.point(r, s));
|
|
400
|
+
},
|
|
401
|
+
// 计算补足距离
|
|
402
|
+
calcOffsetDistance(t, e, n, o) {
|
|
403
|
+
const r = L.GeoUtil.segmentsRad(e, t, n, o), s = L.GeoUtil.computeRad(t, e), i = L.GeoUtil.computeRad(e, n), l = this.calcVerticalOffestPoints(t, s, o), a = this.calcVerticalOffestPoints(e, s, o), c = this.calcVerticalOffestPoints(e, i, o), u = this.calcVerticalOffestPoints(n, i, o);
|
|
404
|
+
let h = null;
|
|
405
|
+
return r > 0 ? h = L.GeoUtil.linesIntersection(l[1], a[1], c[1], u[1]) : h = L.GeoUtil.linesIntersection(l[0], a[0], c[0], u[0]), h ? L.GeoUtil.footPointOnLine(h, e, n).distanceTo(e) : 0;
|
|
406
|
+
},
|
|
407
|
+
// 获取目标点的在给定方向的法线上的两个偏移点
|
|
408
|
+
calcVerticalOffestPoints(t, e, n) {
|
|
409
|
+
const o = e - Math.PI / 2, r = L.point(n * Math.cos(o), n * Math.sin(o));
|
|
410
|
+
return [t.add(r), t.subtract(r)];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
L.footageCalculator = L.footageCalculator || {};
|
|
414
|
+
L.footageCalculator.line = function(t) {
|
|
415
|
+
return new L.FootageCalculator(t);
|
|
416
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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>
|