@openglobus/ext-elevation-profile 0.0.0-stage → 1.0.0
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/LICENSE.md +217 -0
- package/README.md +30 -2
- package/dist/Deferred.d.ts +6 -0
- package/dist/ElevationProfile.d.ts +75 -0
- package/dist/ElevationProfileButtonsView.d.ts +13 -0
- package/dist/ElevationProfileControl.d.ts +31 -0
- package/dist/ElevationProfileLegend.d.ts +20 -0
- package/dist/ElevationProfileScene.d.ts +69 -0
- package/dist/ElevationProfileView.d.ts +78 -0
- package/dist/PointListDialog.d.ts +12 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +848 -0
- package/dist/style.d.ts +8 -0
- package/package.json +30 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,848 @@
|
|
|
1
|
+
import { Control as e, Entity as t, Extent as n, LonLat as r, Object3d as i, Plane as a, Ray as o, SHADE_UNLIT as s, Scene as c, Vec2 as l, Vec3 as u, Vector as d, createEvents as f, defineExtension as p, math as m, ui as h, utils as g } from "@openglobus/og";
|
|
2
|
+
// src/Deferred.ts
|
|
3
|
+
var _ = class {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.resolve = () => {}, this.reject = () => {}, this.promise = new Promise((e, t) => {
|
|
6
|
+
this.resolve = e, this.reject = t;
|
|
7
|
+
}), Object.freeze(this);
|
|
8
|
+
}
|
|
9
|
+
}, v = 5, y = [
|
|
10
|
+
"startcollecting",
|
|
11
|
+
"profilecollected",
|
|
12
|
+
"clear"
|
|
13
|
+
], ee = 0, te = 1, b = 2, x = 0, S = 1, C = 1, w = 1, T = .1, ne = .2, re = .1, E = class {
|
|
14
|
+
constructor(e = {}) {
|
|
15
|
+
this.events = f(y), this.planet = e.planet || null, this._warningHeightLevel = v, this._pointsReady = !1, this._isWarning = !1, this._minX = 0, this._planeDistance = this._maxX = 1e3, this._minY = 0, this._maxY = 200, this._drawData = [[], []], this._promiseArr = [], this._promiseCounter = 0, this._pMaxY = 0, this._pMinY = 0, this._pDist = 0, this._pTrackCoords = [], this._pGroundCoords = [], this._pIndex = 0;
|
|
16
|
+
}
|
|
17
|
+
bindPlanet(e) {
|
|
18
|
+
this.planet = e;
|
|
19
|
+
}
|
|
20
|
+
setWarningHeightLevel(e = 0) {
|
|
21
|
+
this._warningHeightLevel = e;
|
|
22
|
+
}
|
|
23
|
+
setRange(e, t, n, r) {
|
|
24
|
+
this._minX = e, this._maxX = t, n && (this._minY = n), r && (this._maxY = r);
|
|
25
|
+
}
|
|
26
|
+
_getHeightAsync(e, t, n) {
|
|
27
|
+
let r = new _();
|
|
28
|
+
if (this.planet) {
|
|
29
|
+
let i = this.planet.terrain.geoid.getHeightLonLat(e);
|
|
30
|
+
this.planet.terrain.getHeightAsync(e, (a) => {
|
|
31
|
+
this.planet && n === this._promiseCounter ? (a += i, this._pGroundCoords[t][1] = a, this._pGroundCoords[t][2] = 0, this._pGroundCoords[t][3] = e.height, a > this._pMaxY && (this._pMaxY = a), a < this._pMinY && (this._pMinY = a), this._updatePointType(t), r.resolve(a)) : r.reject();
|
|
32
|
+
});
|
|
33
|
+
} else r.reject();
|
|
34
|
+
return r.promise;
|
|
35
|
+
}
|
|
36
|
+
_collectCoordsBetweenTwoTrackPoints(e, t, n, r, i, a) {
|
|
37
|
+
if (this.planet) for (let o = 1; o <= t; o++) {
|
|
38
|
+
this._pDist += C, this._pIndex++;
|
|
39
|
+
let t = o * n, s = r.add(i.scaleTo(t)), c = this.planet.ellipsoid.cartesianToLonLat(s);
|
|
40
|
+
this._pGroundCoords[this._pIndex] = [
|
|
41
|
+
this._pDist,
|
|
42
|
+
0,
|
|
43
|
+
0,
|
|
44
|
+
0,
|
|
45
|
+
e
|
|
46
|
+
], ((e, t) => {
|
|
47
|
+
this._promiseArr.push(this._getHeightAsync(e, t, a));
|
|
48
|
+
})(c, this._pIndex);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
_collectAllPoints(e, t) {
|
|
52
|
+
if (!this.planet || t !== this._promiseCounter) return;
|
|
53
|
+
let n = new u(), r = new u();
|
|
54
|
+
for (let i = 1, a = e.length; i < a; i++) {
|
|
55
|
+
let a = e[i - 1], o = e[i];
|
|
56
|
+
this.planet.ellipsoid.lonLatToCartesianRes(a, n), this.planet.ellipsoid.lonLatToCartesianRes(o, r);
|
|
57
|
+
let s = r.sub(n), c = s.length(), l = this.planet.ellipsoid.getSurfaceNormal3v(n), d = u.proj_b_to_plane(s, l), f = d.length(), p = Math.floor(f / C), m = C * c / f;
|
|
58
|
+
this._getGroundElevation(a, i - 1, t), d.normalize(), s.normalize(), this._collectCoordsBetweenTwoTrackPoints(i - 1, p, m, n, s, t), this._pDist += f - p * C, this._pIndex++;
|
|
59
|
+
let h = o.height;
|
|
60
|
+
h > this._pMaxY && (this._pMaxY = h), h < this._pMinY && (this._pMinY = h), this._pTrackCoords[i] = [
|
|
61
|
+
this._pDist,
|
|
62
|
+
h,
|
|
63
|
+
this._pIndex
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_getGroundElevation(e, t, n) {
|
|
68
|
+
this._pGroundCoords[this._pIndex] = [
|
|
69
|
+
this._pDist,
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
0,
|
|
73
|
+
t
|
|
74
|
+
], this._promiseArr.push(this._getHeightAsync(e, this._pIndex, n));
|
|
75
|
+
}
|
|
76
|
+
_calcPointsAsync(e, t) {
|
|
77
|
+
return new Promise((n, r) => {
|
|
78
|
+
this._pTrackCoords = [[
|
|
79
|
+
0,
|
|
80
|
+
e[0].height,
|
|
81
|
+
0
|
|
82
|
+
]], this._pMaxY = e[0].height, this._pMinY = this._pMaxY, this._pDist = 0, this._pGroundCoords = [], this._pIndex = 0, this._promiseArr = [], this._collectAllPoints(e, t), this._getGroundElevation(e[e.length - 1], e.length - 1, t), Promise.all(this._promiseArr).then(() => {
|
|
83
|
+
n({
|
|
84
|
+
dist: this._pDist,
|
|
85
|
+
minY: this._pMinY,
|
|
86
|
+
maxY: this._pMaxY,
|
|
87
|
+
trackCoords: this._pTrackCoords,
|
|
88
|
+
groundCoords: this._pGroundCoords
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
get minX() {
|
|
94
|
+
return this._minX;
|
|
95
|
+
}
|
|
96
|
+
get planeDistance() {
|
|
97
|
+
return this._planeDistance;
|
|
98
|
+
}
|
|
99
|
+
get maxX() {
|
|
100
|
+
return this._maxX;
|
|
101
|
+
}
|
|
102
|
+
get minY() {
|
|
103
|
+
return this._minY;
|
|
104
|
+
}
|
|
105
|
+
get maxY() {
|
|
106
|
+
return this._maxY;
|
|
107
|
+
}
|
|
108
|
+
get pointsReady() {
|
|
109
|
+
return this._pointsReady;
|
|
110
|
+
}
|
|
111
|
+
get isWarningOrCollision() {
|
|
112
|
+
return this._isWarning;
|
|
113
|
+
}
|
|
114
|
+
get drawData() {
|
|
115
|
+
return this._drawData;
|
|
116
|
+
}
|
|
117
|
+
collectProfile(e) {
|
|
118
|
+
let t = new _();
|
|
119
|
+
return this.planet || t.reject(), this._pointsReady = !1, this._isWarning = !1, !e || !e.length ? (t.reject(), t.promise) : (this.events.dispatch(this.events.startcollecting, this), this._promiseCounter++, ((n) => {
|
|
120
|
+
this._calcPointsAsync(e, n).then((e) => {
|
|
121
|
+
n === this._promiseCounter && (this._planeDistance = e.dist, this.setRange(0, e.dist, e.minY - T * Math.abs(e.minY), e.maxY + Math.abs(e.maxY) * ne), this._pointsReady = !0, this._drawData = [e.trackCoords, e.groundCoords], this.events.dispatch(this.events.profilecollected, this._drawData, this), t.resolve(this._drawData));
|
|
122
|
+
});
|
|
123
|
+
})(this._promiseCounter), t.promise);
|
|
124
|
+
}
|
|
125
|
+
_updatePointType(e) {
|
|
126
|
+
this._pGroundCoords[e][3] >= this._pGroundCoords[e][1] && this._pGroundCoords[e][3] < this._pGroundCoords[e][1] + this._warningHeightLevel - re && (this._pGroundCoords[e][2] = 1), this._pGroundCoords[e][3] <= this._pGroundCoords[e][1] + w && (this._pGroundCoords[e][2] = 2), (this._pGroundCoords[e][2] === 1 || this._pGroundCoords[e][2] === 2) && (this._isWarning = !0);
|
|
127
|
+
}
|
|
128
|
+
_setPointsType() {
|
|
129
|
+
this._isWarning = !1, this._pTrackCoords = this._drawData[x], this._pGroundCoords = this._drawData[S];
|
|
130
|
+
for (let e = 0; e < this._pGroundCoords.length; e++) this._updatePointType(e);
|
|
131
|
+
this._drawData[S] = this._pGroundCoords, this.events.dispatch(this.events.profilecollected, this._drawData, this);
|
|
132
|
+
}
|
|
133
|
+
clear() {
|
|
134
|
+
this._promiseCounter = 0, this._pointsReady = !1, this._isWarning = !1, this._drawData = [[], []], this._pMaxY = 0, this._pMinY = 0, this._pDist = 0, this._pTrackCoords = [], this._pGroundCoords = [], this._pIndex = 0, this.events.dispatch(this.events.clear, this._drawData, this);
|
|
135
|
+
}
|
|
136
|
+
}, { distanceFormatExt: ie, binarySearch: D } = g, O = "#26282c", k = "rgb(0, 255, 50)", A = "rgb(198, 198, 198)", j = "rgb(64, 68, 82)", M = [
|
|
137
|
+
A,
|
|
138
|
+
"rgb(255, 255, 0)",
|
|
139
|
+
"rgb(255, 0, 0)"
|
|
140
|
+
], N = .5, P = 5, F = [
|
|
141
|
+
"startdrag",
|
|
142
|
+
"stopdrag",
|
|
143
|
+
"pointer",
|
|
144
|
+
"mouseenter",
|
|
145
|
+
"mouseleave",
|
|
146
|
+
"dblclick",
|
|
147
|
+
"tracklength",
|
|
148
|
+
"groundlength",
|
|
149
|
+
"warninglength",
|
|
150
|
+
"collisionlength"
|
|
151
|
+
], I = "<div class=\"og-elevationprofile\">\n <div class=\"og-elevationprofile-loading\" style=\"display: none;\">\n <div class=\"loadingio-spinner-bars-r354qqyl5v\">\n <div class=\"ldio-p0v5a1f6oz\">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n </div>\n </div>", L = class extends h.View {
|
|
152
|
+
constructor(e = {}) {
|
|
153
|
+
super({
|
|
154
|
+
template: I,
|
|
155
|
+
model: new E()
|
|
156
|
+
}), this._onMouseDblClick = (e) => {
|
|
157
|
+
let t = this.$canvas.getBoundingClientRect(), n = e.clientX - t.left, r = this._leftDistance + (this._rightDistance - this._leftDistance) * n / this.clientWidth, i = this.model.drawData[1], a = this.model.drawData[0], o;
|
|
158
|
+
r < 0 ? (o = 1, r = 0) : r > this.model.planeDistance ? (o = i.length - 1, r = this.model.planeDistance) : o = -1 - D(i, r, (e, t) => e - t[0]);
|
|
159
|
+
let s = i[o - 1], c = i[o], l = (r - s[0]) / (c[0] - s[0]), u = s[1] + l * (c[1] - s[1]), d = s[4], f = a[d], p = a[d + 1];
|
|
160
|
+
l = (r - f[0]) / (p[0] - f[0]);
|
|
161
|
+
let m = f[1] + l * (p[1] - f[1]);
|
|
162
|
+
this.events.dispatch(this.events.dblclick, r, f, p, s, c, d, o - 1, m - u);
|
|
163
|
+
}, this._onMouseEnter = (e) => {
|
|
164
|
+
this._isMouseOver = !0, this.events.dispatch(this.events.mouseenter, e);
|
|
165
|
+
}, this._onMouseOut = (e) => {
|
|
166
|
+
this._isMouseOver = !1, this.events.dispatch(this.events.mouseleave, e);
|
|
167
|
+
}, this._onMouseDown = (e) => {
|
|
168
|
+
this._isMouseOver && (this._isDragging = !0, document.body.classList.add("og-timeline-unselectable"), this._clickPosX = e.clientX, this._customFrame || (this._leftDistance = this.model.minX, this._rightDistance = this.model.maxX), this._clickLeftDistance = this._leftDistance, this._clickRightDistance = this._rightDistance, this.events.dispatch(this.events.startdrag, e));
|
|
169
|
+
}, this._onMouseUp = (e) => {
|
|
170
|
+
this._isDragging && (this._isDragging = !1, document.body.classList.remove("og-timeline-unselectable"), this.events.dispatch(this.events.stopdrag, e));
|
|
171
|
+
}, this._onCanvasMouseMove = (e) => {
|
|
172
|
+
if (this.model.pointsReady) {
|
|
173
|
+
if (this._isDragging) this.clearPointerCanvas();
|
|
174
|
+
else {
|
|
175
|
+
this._customFrame || (this._leftDistance = this.model.minX, this._rightDistance = this.model.maxX);
|
|
176
|
+
let t = this.$pointerCanvas.getBoundingClientRect(), n = e.clientX - t.left;
|
|
177
|
+
this.redrawPointerCanvas(n);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}, this._onMouseMove = (e) => {
|
|
181
|
+
if (this._isDragging && this.model.pointsReady) {
|
|
182
|
+
let t = (this._clickPosX - e.clientX) * this._canvasScale / this._pixelsInMeter_x;
|
|
183
|
+
this.setFrame(this._clickLeftDistance + t, this._clickRightDistance + t);
|
|
184
|
+
}
|
|
185
|
+
}, this._onMouseWheelFF = (e) => {
|
|
186
|
+
this._onMouseWheel(e);
|
|
187
|
+
}, this._onMouseWheel = (e) => {
|
|
188
|
+
if (this._isMouseOver && this.model.pointsReady) {
|
|
189
|
+
this._customFrame || (this._leftDistance = this.model.minX, this._rightDistance = this.model.maxX), this._customFrame = !0;
|
|
190
|
+
let t = Math.sign(e.wheelDelta) * (this._rightDistance - this._leftDistance) / 20, n = this.$canvas.getBoundingClientRect(), r = e.clientX - n.left, i = r - this.$canvas.clientWidth * .5, a = i * this._canvasScale / this._pixelsInMeter_x, o = a + this._leftDistance + t, s = a + this._rightDistance - t;
|
|
191
|
+
a = -i * (s - o) / this.clientWidth, this.setFrame(o + a, s + a), this.redrawPointerCanvas(r);
|
|
192
|
+
}
|
|
193
|
+
}, this.events = this.events.registerNames(F), this.fillStyle = e.fillStyle || O, this._customFrame = !1, this._leftDistance = 0, this._rightDistance = 0, this._pixelsInMeter_x = 0, this._pixelsInMeter_y = 0, this._canvasScale = 2, this.$canvas = document.createElement("canvas"), this.$canvas.style.position = "absolute", this._ctx = this.$canvas.getContext("2d"), this.$pointerCanvas = document.createElement("canvas"), this.$pointerCanvas.style.pointerEvents = "none", this.$pointerCanvas.style.position = "absolute", this._pointerCtx = this.$pointerCanvas.getContext("2d"), this.$loading = null, this._isMouseOver = !1, this._isDragging = !1, this._clickPosX = 0, this._clickLeftDistance = 0, this._clickRightDistance = 0, this._timeStartHandler = 0, this._onResizeObserver_ = this._onResizeObserver.bind(this), this._resizeObserver = new ResizeObserver(this._onResizeObserver_);
|
|
194
|
+
}
|
|
195
|
+
_onResizeObserver() {
|
|
196
|
+
this.resize();
|
|
197
|
+
}
|
|
198
|
+
get canvasScale() {
|
|
199
|
+
return this._canvasScale;
|
|
200
|
+
}
|
|
201
|
+
set canvasScale(e) {
|
|
202
|
+
e !== this._canvasScale && (this._canvasScale = e, this.resize());
|
|
203
|
+
}
|
|
204
|
+
resize() {
|
|
205
|
+
this._resize(), this.draw();
|
|
206
|
+
}
|
|
207
|
+
render() {
|
|
208
|
+
return super.render(), this._resizeObserver.observe(this.el), this.el.appendChild(this.$canvas), this.el.appendChild(this.$pointerCanvas), this.model.events.on("profilecollected", (e) => {
|
|
209
|
+
this._hideLoading(), this.clearPointerCanvas(), this.draw();
|
|
210
|
+
}), this.model.events.on("startcollecting", () => {
|
|
211
|
+
clearTimeout(this._timeStartHandler), this._timeStartHandler = setTimeout(() => {
|
|
212
|
+
this._showLoading();
|
|
213
|
+
}, 450);
|
|
214
|
+
}), this.model.events.on("clear", () => {
|
|
215
|
+
this._customFrame = !1, this._leftDistance = 0, this.clearCanvas(), this.clearPointerCanvas();
|
|
216
|
+
}), this.$loading = this.select(".og-elevationprofile-loading"), this.$canvas.addEventListener("mouseenter", this._onMouseEnter), this.$canvas.addEventListener("mouseout", this._onMouseOut), this.$canvas.addEventListener("dblclick", this._onMouseDblClick), this.$canvas.addEventListener("mousemove", this._onCanvasMouseMove), document.body.addEventListener("mousemove", this._onMouseMove), document.body.addEventListener("mousedown", this._onMouseDown), document.body.addEventListener("mouseup", this._onMouseUp), document.body.addEventListener("wheel", this._onMouseWheelFF), this;
|
|
217
|
+
}
|
|
218
|
+
remove() {
|
|
219
|
+
clearTimeout(this._timeStartHandler), this._resizeObserver.disconnect(), document.body.removeEventListener("mousemove", this._onMouseMove), document.body.removeEventListener("mousedown", this._onMouseDown), document.body.removeEventListener("mouseup", this._onMouseUp), document.body.removeEventListener("wheel", this._onMouseWheelFF), super.remove();
|
|
220
|
+
}
|
|
221
|
+
_hideLoading() {
|
|
222
|
+
clearTimeout(this._timeStartHandler), this.$loading.style.display = "none";
|
|
223
|
+
}
|
|
224
|
+
_showLoading() {
|
|
225
|
+
this.$loading.style.display = "flex";
|
|
226
|
+
}
|
|
227
|
+
redrawPointerCanvas(e) {
|
|
228
|
+
this.clearPointerCanvas();
|
|
229
|
+
let t = this._leftDistance + (this._rightDistance - this._leftDistance) * e / this.clientWidth, n = this.model.drawData[1], r = this.model.drawData[0], i;
|
|
230
|
+
t < 0 ? (i = 1, t = 0, e = (0 - this._leftDistance) * this.clientWidth / (this._rightDistance - this._leftDistance)) : t > this.model.planeDistance ? (i = n.length - 1, t = this.model.planeDistance, e = (t - this._leftDistance) * this.clientWidth / (this._rightDistance - this._leftDistance)) : i = -1 - D(n, t, (e, t) => e - t[0]);
|
|
231
|
+
let a = n[i - 1], o = n[i], s = (t - a[0]) / (o[0] - a[0]), c = a[1] + s * (o[1] - a[1]), l = a[4], u = r[l], d = r[l + 1];
|
|
232
|
+
s = (t - u[0]) / (d[0] - u[0]);
|
|
233
|
+
let f = u[1] + s * (d[1] - u[1]), p = (this.model.maxY - f) * this._pixelsInMeter_y, m = (this.model.maxY - c) * this._pixelsInMeter_y;
|
|
234
|
+
this.events.dispatch(this.events.pointer, t, u, d, a, o, l, i - 1, f - c);
|
|
235
|
+
let h = this._pointerCtx;
|
|
236
|
+
h.lineWidth = 3, h.strokeStyle = "rgba(64,64,64,0.6)", h.beginPath(), h.moveTo(e * this._canvasScale, 0), h.lineTo(e * this._canvasScale, this.clientHeight * this._canvasScale), h.stroke(), h.beginPath(), h.arc(e * this._canvasScale, m, 4, 0, 2 * Math.PI, !1), h.fillStyle = "#FFB277", h.fill(), h.lineWidth = 4, h.strokeStyle = "#FFB277", h.stroke(), h.beginPath(), h.arc(e * this._canvasScale, p, 4, 0, 2 * Math.PI, !1), h.fillStyle = "#FFB277", h.fill(), h.lineWidth = 4, h.strokeStyle = "#FFB277", h.stroke(), h.lineWidth = 3, h.strokeStyle = "#FFB277", h.beginPath(), h.moveTo(e * this._canvasScale, m), h.lineTo(e * this._canvasScale, p), h.stroke(), h.fillStyle = "white", h.font = `${28 / devicePixelRatio}px Arial`, h.textBaseline = "middle", h.textAlign = "left", h.fillText(`${Math.round(f - c).toString()} m`, (e + 5) * this._canvasScale, m + (p - m) * .5), h.fillStyle = "white", h.font = `${28 / devicePixelRatio}px Arial`, h.textAlign = "right";
|
|
237
|
+
let g = ie(t);
|
|
238
|
+
h.fillText(`${g[0]} ${g[1]}`, (e - 5) * this._canvasScale, (this.clientHeight - 7) * this._canvasScale);
|
|
239
|
+
}
|
|
240
|
+
get clientWidth() {
|
|
241
|
+
return this.$canvas ? this.$canvas.width / this._canvasScale : 0;
|
|
242
|
+
}
|
|
243
|
+
get clientHeight() {
|
|
244
|
+
return this.$canvas ? this.$canvas.height / this._canvasScale : 0;
|
|
245
|
+
}
|
|
246
|
+
_resize() {
|
|
247
|
+
this.el && (this.$canvas.width = this.el.clientWidth * this._canvasScale, this.$canvas.height = this.el.clientHeight * this._canvasScale, this.$canvas.style.width = `${this.el.clientWidth}px`, this.$canvas.style.height = `${this.el.clientHeight}px`, this.$pointerCanvas.width = this.el.clientWidth * this._canvasScale, this.$pointerCanvas.height = this.el.clientHeight * this._canvasScale, this.$pointerCanvas.style.width = `${this.el.clientWidth}px`, this.$pointerCanvas.style.height = `${this.el.clientHeight}px`, this._customFrame && (this._pixelsInMeter_x = this._canvasScale * this.clientWidth / (this._rightDistance - this._leftDistance)));
|
|
248
|
+
}
|
|
249
|
+
clearPointerCanvas() {
|
|
250
|
+
this._pointerCtx.fillStyle = "rgba(0,0,0,0)", this._pointerCtx.clearRect(0, 0, this.clientWidth * this._canvasScale, this.clientHeight * this._canvasScale);
|
|
251
|
+
}
|
|
252
|
+
clearCanvas() {
|
|
253
|
+
let e = this._ctx.createLinearGradient(0, 0, 0, this.clientHeight * this._canvasScale);
|
|
254
|
+
e.addColorStop(0, "#191a1c"), e.addColorStop(1, this.fillStyle), this._ctx.fillStyle = e, this._ctx.fillRect(0, 0, this.clientWidth * this._canvasScale, this.clientHeight * this._canvasScale);
|
|
255
|
+
}
|
|
256
|
+
setFrame(e, t) {
|
|
257
|
+
this._leftDistance = e, this._rightDistance = t, this._customFrame = !0, this._pixelsInMeter_x = this._canvasScale * this.clientWidth / (this._rightDistance - this._leftDistance), this.model.setRange(e, t), this.draw();
|
|
258
|
+
}
|
|
259
|
+
_updateUnits() {
|
|
260
|
+
this._customFrame || (this._pixelsInMeter_x = this._canvasScale * this.clientWidth / (this.model.maxX - this.model.minX)), this._pixelsInMeter_y = this._canvasScale * this.clientHeight / (this.model.maxY - this.model.minY);
|
|
261
|
+
}
|
|
262
|
+
clear() {
|
|
263
|
+
this.model.clear(), this.clearCanvas();
|
|
264
|
+
}
|
|
265
|
+
draw() {
|
|
266
|
+
let e = this.model.drawData[0];
|
|
267
|
+
if (e.length > 1) {
|
|
268
|
+
this._updateUnits(), this.clearCanvas();
|
|
269
|
+
let t = this.model.drawData[1];
|
|
270
|
+
this._drawTrack(e, t), this._drawTerrain(t), this._drawWarningAndCollision(t), this._drawLabels(e, t);
|
|
271
|
+
} else this.clearCanvas();
|
|
272
|
+
}
|
|
273
|
+
_drawLabels(e, t) {
|
|
274
|
+
let n = this._ctx;
|
|
275
|
+
if (n) {
|
|
276
|
+
let r = e[0], i = this.model.maxY, a = (-this._leftDistance + r[0]) * this._pixelsInMeter_x, o = (i - r[1]) * this._pixelsInMeter_y;
|
|
277
|
+
(i - t[r[2]][1]) * this._pixelsInMeter_y, n.beginPath(), n.fillStyle = "#F7F718", n.fillRect(a - 4, o - 4, 8, 8), n.stroke(), n.fillStyle = "white", n.font = `${26 / devicePixelRatio}px Arial`, n.textBaseline = "bottom", n.textAlign = "left", n.fillText(`${Math.round(r[1] - t[r[2]][1]).toString()} m`, a + 1, o - 10), n.stroke();
|
|
278
|
+
for (let r = 1, s = e.length; r < s; r++) {
|
|
279
|
+
let s = e[r];
|
|
280
|
+
a = (-this._leftDistance + s[0]) * this._pixelsInMeter_x, o = (i - s[1]) * this._pixelsInMeter_y, (i - t[s[2]][1]) * this._pixelsInMeter_y, n.beginPath(), n.fillStyle = "#F7F718", n.fillRect(a - 4, o - 4, 8, 8), n.stroke(), n.fillStyle = "white", n.fillText(`${Math.round(s[1] - t[s[2]][1]).toString()} m`, a + 1, o - 10), n.stroke();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
_drawTrack(e, t) {
|
|
285
|
+
let n = e[0], r = this._ctx;
|
|
286
|
+
if (r) {
|
|
287
|
+
let i = this.model.maxY;
|
|
288
|
+
r.lineWidth = P, r.strokeStyle = k, r.beginPath(), r.moveTo((-this._leftDistance + n[0]) * this._pixelsInMeter_x, (i - n[1]) * this._pixelsInMeter_y);
|
|
289
|
+
let a = 0;
|
|
290
|
+
for (let t = 1, n = e.length; t < n; t++) {
|
|
291
|
+
let n = e[t];
|
|
292
|
+
r.lineTo((-this._leftDistance + n[0]) * this._pixelsInMeter_x, (i - n[1]) * this._pixelsInMeter_y);
|
|
293
|
+
let o = e[t - 1], s = n[0] - o[0], c = n[1] - o[1], l = s * s, u = c * c;
|
|
294
|
+
a += Math.sqrt(l + u);
|
|
295
|
+
}
|
|
296
|
+
r.stroke(), r.lineWidth = 2, r.strokeStyle = "rgba(255,255,255,0.7)", r.beginPath();
|
|
297
|
+
let o = (-this._leftDistance + n[0]) * this._pixelsInMeter_x, s = (i - n[1]) * this._pixelsInMeter_y, c = (i - t[n[2]][1]) * this._pixelsInMeter_y;
|
|
298
|
+
r.moveTo(o, s), r.lineTo(o, c);
|
|
299
|
+
for (let n = 1, a = e.length; n < a; n++) {
|
|
300
|
+
let a = e[n];
|
|
301
|
+
o = (-this._leftDistance + a[0]) * this._pixelsInMeter_x, s = (i - a[1]) * this._pixelsInMeter_y, c = (i - t[a[2]][1]) * this._pixelsInMeter_y, r.strokeStyle = "rgba(255,255,255,0.7)", r.moveTo(o, s), r.lineTo(o, c);
|
|
302
|
+
}
|
|
303
|
+
r.stroke(), this.events.dispatch(this.events.tracklength, a);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
_drawTerrain(e) {
|
|
307
|
+
let t = e[0], n = this._ctx;
|
|
308
|
+
if (n) {
|
|
309
|
+
let r = this.model.maxY;
|
|
310
|
+
n.lineWidth = P, n.strokeStyle = A, n.beginPath(), n.moveTo((-this._leftDistance + t[0]) * this._pixelsInMeter_x, this.$canvas.height), n.lineTo((-this._leftDistance + t[0]) * this._pixelsInMeter_x, (r - t[1]) * this._pixelsInMeter_y);
|
|
311
|
+
let i = 0;
|
|
312
|
+
for (let t = 1, a = e.length; t < a; t++) {
|
|
313
|
+
let a = e[t];
|
|
314
|
+
n.lineTo((-this._leftDistance + a[0]) * this._pixelsInMeter_x, (r - a[1]) * this._pixelsInMeter_y);
|
|
315
|
+
let o = e[t - 1], s = a[0] - o[0], c = a[1] - o[1], l = s * s, u = c * c;
|
|
316
|
+
i += Math.sqrt(l + u);
|
|
317
|
+
}
|
|
318
|
+
n.lineTo((-this._leftDistance + e[e.length - 1][0]) * this._pixelsInMeter_x, this.$canvas.height), n.closePath(), n.stroke(), n.save(), n.fillStyle = j, n.globalAlpha = N, n.fill(), n.restore(), n.globalAlpha = 1, this.events.dispatch(this.events.groundlength, i);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
_drawWarningAndCollision(e) {
|
|
322
|
+
let t = this._ctx;
|
|
323
|
+
if (t && e.length > 1) {
|
|
324
|
+
let n = this.model.maxY;
|
|
325
|
+
t.lineWidth = P, t.beginPath();
|
|
326
|
+
let r = 0, i = 0;
|
|
327
|
+
for (let a = 0, o = e.length - 1; a < o; a++) {
|
|
328
|
+
let o = e[a], s = e[a + 1];
|
|
329
|
+
if (o[2] !== 0 && s[2] !== 0) {
|
|
330
|
+
let e = s[0] - o[0], a = s[1] - o[1], c = e * e, l = a * a;
|
|
331
|
+
o[2] === 2 ? (t.stroke(), t.beginPath(), t.strokeStyle = M[2], i += Math.sqrt(c + l)) : o[2] === 1 && (t.stroke(), t.beginPath(), t.strokeStyle = M[1], r += Math.sqrt(c + l)), t.moveTo((-this._leftDistance + o[0]) * this._pixelsInMeter_x, (n - o[1]) * this._pixelsInMeter_y), t.lineTo((-this._leftDistance + s[0]) * this._pixelsInMeter_x, (n - s[1]) * this._pixelsInMeter_y);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
t.stroke(), this.events.dispatch(this.events.warninglength, r), this.events.dispatch(this.events.collisionlength, i);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}, R = i.createCylinder(.33, 0, 1, 20, 1, !0, !1, 0, 0, 0), z = i.createCylinder(.33, .33, 1.1, 20, 1, !0, !0, 0, -.55, 0), B = {
|
|
338
|
+
startPosition: new u(),
|
|
339
|
+
endPosition: new u(),
|
|
340
|
+
startColor: "rgba(255,131,0,0.2)",
|
|
341
|
+
endColor: "rgba(255,131,0,1.0)",
|
|
342
|
+
thickness: 2.7
|
|
343
|
+
}, V = {
|
|
344
|
+
src: "data:image/png;base64,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",
|
|
345
|
+
color: "rgb(255,131,0)",
|
|
346
|
+
size: [8, 8]
|
|
347
|
+
}, H = {
|
|
348
|
+
text: "",
|
|
349
|
+
face: "arial",
|
|
350
|
+
size: 12,
|
|
351
|
+
color: "rgba(255,255,255,1.0)",
|
|
352
|
+
outlineColor: "rgba(0,0,0,1)",
|
|
353
|
+
outline: 2,
|
|
354
|
+
align: "left",
|
|
355
|
+
offset: [5, 15]
|
|
356
|
+
}, U = {
|
|
357
|
+
face: "arial",
|
|
358
|
+
text: "",
|
|
359
|
+
size: 12,
|
|
360
|
+
color: "rgba(255,255,255,1)",
|
|
361
|
+
outlineColor: "rgba(0,0,0,1)",
|
|
362
|
+
outline: 2,
|
|
363
|
+
align: "right",
|
|
364
|
+
offset: [-47, 25]
|
|
365
|
+
}, W = {
|
|
366
|
+
instanced: !0,
|
|
367
|
+
tag: "ground-pointer",
|
|
368
|
+
color: "rgb(0,305,0)",
|
|
369
|
+
object3d: R
|
|
370
|
+
}, G = {
|
|
371
|
+
instanced: !0,
|
|
372
|
+
tag: "head-pointer",
|
|
373
|
+
color: "rgb(305,305,0)",
|
|
374
|
+
object3d: z
|
|
375
|
+
}, K = class extends c {
|
|
376
|
+
constructor(e = {}) {
|
|
377
|
+
super("ElevationProfileScene"), this._onLClick = (e) => {
|
|
378
|
+
let t = this._planet.getCartesianFromPixelTerrain(e.pos);
|
|
379
|
+
t && (this.renderer.setRelativeCenter(), this.addGroundPoint3vAsync(t));
|
|
380
|
+
}, this._onMouseMove = (e) => {
|
|
381
|
+
if (this._pickedGroundEntity) {
|
|
382
|
+
let t = new l(e.x, e.y).sub(this._startClickPos), n = this._startEntityPos.add(t), r = this._planet.getCartesianFromPixelTerrain(n);
|
|
383
|
+
r && this.setGroundPointCartesian3v(this._pickedGroundEntity.properties.index, r);
|
|
384
|
+
} else if (this._pickedHeadEntity) {
|
|
385
|
+
let t = this._planet.camera, n = this._pickedHeadEntity.properties.groundEntity.getCartesian(), r = this._planet.ellipsoid.getSurfaceNormal3v(n), i = n.add(r), s = n.add(t.getRight()), c = new u();
|
|
386
|
+
if (e.ray.hitPlaneRes(a.fromPoints(n, i, s), c) === o.INSIDE) {
|
|
387
|
+
let e = u.proj_b_to_a(c, n), t = e.sub(n).dot(n), i = n.add(r.scale(Math.sign(t) * e.distance(n)));
|
|
388
|
+
this.setHeadPointCartesian3v(this._pickedHeadEntity.properties.index, i);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}, this._onLUp = (e) => {}, this._onGroundPointerEnter = (e) => {
|
|
392
|
+
e.renderer.handler.canvas.style.cursor = "pointer";
|
|
393
|
+
}, this._onGroundPointerLeave = (e) => {
|
|
394
|
+
e.renderer.handler.canvas.style.cursor = "default";
|
|
395
|
+
}, this._onGroundPointerLDown = (e) => {
|
|
396
|
+
this._clampToGround = !1, this.renderer.controls.navigation.deactivate(), this.renderer.setRelativeCenter(), this._pickedGroundEntity = e.pickingObject;
|
|
397
|
+
let t = this._pickedGroundEntity.getCartesian();
|
|
398
|
+
this._startClickPos.set(e.x, e.y), this._startEntityPos = this._planet.getPixelFromCartesian(t);
|
|
399
|
+
}, this._onGroundPointerLUp = (e) => {
|
|
400
|
+
this._clampToGround = !0, this.renderer.controls.navigation.activate(), this._pickedGroundEntity = null;
|
|
401
|
+
}, this._onHeadPointerEnter = (e) => {
|
|
402
|
+
e.renderer.handler.canvas.style.cursor = "pointer";
|
|
403
|
+
}, this._onHeadPointerLeave = (e) => {
|
|
404
|
+
e.renderer.handler.canvas.style.cursor = "default";
|
|
405
|
+
}, this._onHeadPointerLDown = (e) => {
|
|
406
|
+
this.renderer.controls.navigation.deactivate(), this.renderer.setRelativeCenter(), this._pickedHeadEntity = e.pickingObject;
|
|
407
|
+
}, this._onHeadPointerLUp = (e) => {
|
|
408
|
+
this.renderer.controls.navigation.activate(), this._pickedHeadEntity = null;
|
|
409
|
+
}, this._onForwardpass = () => {
|
|
410
|
+
if (this._clampToGround) {
|
|
411
|
+
let e = new u(), t = this._planet.quadTreeStrategy._renderedNodes, n = this._groundPointersLayer.getEntities();
|
|
412
|
+
for (let r = 0; r < n.length; r++) {
|
|
413
|
+
let i = n[r];
|
|
414
|
+
for (let n = 0; n < t.length; n++) {
|
|
415
|
+
let r = t[n];
|
|
416
|
+
if (r.segment.isEntityInside(i)) {
|
|
417
|
+
r.segment.getEntityTerrainPoint(i, e), i.setCartesian3v(e), i.properties.columnEntity.ray.setStartPosition3v(e);
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}, this.disableDepthCamera = !0, this.events = f(q), this._planet = e.planet || null, this._pickedGroundEntity = null, this._pickedHeadEntity = null, this._startClickPos = new l(), this._startEntityPos = new l(), this._clampToGround = !0, this._trackLayer = new d("track", {
|
|
424
|
+
entities: [],
|
|
425
|
+
pickingEnabled: !1,
|
|
426
|
+
depthOffset: -5,
|
|
427
|
+
relativeToGround: !0,
|
|
428
|
+
hideInLayerSwitcher: !0
|
|
429
|
+
}), this._groundPointersLayer = new d("ground-pointers", {
|
|
430
|
+
entities: [],
|
|
431
|
+
pickingEnabled: !0,
|
|
432
|
+
hideInLayerSwitcher: !0,
|
|
433
|
+
scaleByDistance: [
|
|
434
|
+
1,
|
|
435
|
+
5e3,
|
|
436
|
+
m.MAX32,
|
|
437
|
+
.02
|
|
438
|
+
],
|
|
439
|
+
pickingScale: 1,
|
|
440
|
+
shadeMode: s
|
|
441
|
+
}), this._headPointersLayer = new d("head-pointers", {
|
|
442
|
+
entities: [],
|
|
443
|
+
pickingEnabled: !0,
|
|
444
|
+
hideInLayerSwitcher: !0,
|
|
445
|
+
scaleByDistance: [
|
|
446
|
+
1,
|
|
447
|
+
1e4,
|
|
448
|
+
m.MAX32,
|
|
449
|
+
.02
|
|
450
|
+
],
|
|
451
|
+
pickingScale: 1,
|
|
452
|
+
shadeMode: s
|
|
453
|
+
}), this._columnPointersLayer = new d("column-pointers", {
|
|
454
|
+
entities: [],
|
|
455
|
+
pickingEnabled: !1,
|
|
456
|
+
hideInLayerSwitcher: !0
|
|
457
|
+
}), this._trackEntity = new t({ polyline: {
|
|
458
|
+
path3v: [],
|
|
459
|
+
thickness: 3.8,
|
|
460
|
+
color: "rgba(0,305,0,0.8)"
|
|
461
|
+
} }), this._trackLayer = new d("column-pointers", {
|
|
462
|
+
entities: [this._trackEntity],
|
|
463
|
+
pickingEnabled: !1,
|
|
464
|
+
hideInLayerSwitcher: !0
|
|
465
|
+
}), this._heightsLayer = new d("heights-labels", {
|
|
466
|
+
entities: [],
|
|
467
|
+
pickingEnabled: !1,
|
|
468
|
+
hideInLayerSwitcher: !0
|
|
469
|
+
}), this._pointerHeadEntity = new t({
|
|
470
|
+
cartesian: new u(),
|
|
471
|
+
billboard: V
|
|
472
|
+
}), this._pointerLabelEntity = new t({
|
|
473
|
+
cartesian: new u(),
|
|
474
|
+
label: H
|
|
475
|
+
}), this._pointerRayEntity = new t({
|
|
476
|
+
cartesian: new u(),
|
|
477
|
+
ray: B
|
|
478
|
+
}), this._pointerLayer = new d("pointer", {
|
|
479
|
+
entities: [
|
|
480
|
+
this._pointerHeadEntity,
|
|
481
|
+
this._pointerLabelEntity,
|
|
482
|
+
this._pointerRayEntity
|
|
483
|
+
],
|
|
484
|
+
pickingEnabled: !1,
|
|
485
|
+
hideInLayerSwitcher: !0
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
flyExtent() {
|
|
489
|
+
let e = this._headPointersLayer.getEntities(), t = 180, i = 180, a = -180, o = -180, s = -1e6;
|
|
490
|
+
if (e.length > 1) {
|
|
491
|
+
for (let n = 0; n < e.length; n++) {
|
|
492
|
+
let r = e[n].getLonLat();
|
|
493
|
+
r.lon < t && (t = r.lon), r.lat < i && (i = r.lat), r.lon > a && (a = r.lon), r.lat > o && (o = r.lat), r.height > s && (s = r.height);
|
|
494
|
+
}
|
|
495
|
+
this._planet.camera.flyExtent(new n(new r(t, i), new r(a, o)), s, { amplitude: 0 });
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
get planet() {
|
|
499
|
+
return this._planet;
|
|
500
|
+
}
|
|
501
|
+
_createGroundPointer(e, n = 10) {
|
|
502
|
+
let i = this.ellipsoid.getSurfaceNormal3v(e), a = e.add(i.scale(n)), o = new t({ ray: {
|
|
503
|
+
startPosition: e,
|
|
504
|
+
endPosition: a,
|
|
505
|
+
startColor: "rgba(255,255,255,0.2)",
|
|
506
|
+
endColor: "rgba(355,355,355,1.0)",
|
|
507
|
+
thickness: 3.2
|
|
508
|
+
} }), s = new t({
|
|
509
|
+
cartesian: e,
|
|
510
|
+
geoObject: W
|
|
511
|
+
}), c = new t({
|
|
512
|
+
cartesian: a,
|
|
513
|
+
geoObject: G,
|
|
514
|
+
properties: {}
|
|
515
|
+
}), l = new t({
|
|
516
|
+
cartesian: a,
|
|
517
|
+
label: U
|
|
518
|
+
}), u = new t({
|
|
519
|
+
cartesian: a,
|
|
520
|
+
label: {
|
|
521
|
+
...U,
|
|
522
|
+
offset: [-47, 45]
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
return l.appendChild(u), u.relativePosition = !0, o.properties = s.properties = c.properties = {
|
|
526
|
+
index: this._groundPointersLayer.getEntities().length,
|
|
527
|
+
altitude: n,
|
|
528
|
+
lonLatEll: new r(),
|
|
529
|
+
headEntity: c,
|
|
530
|
+
groundEntity: s,
|
|
531
|
+
columnEntity: o,
|
|
532
|
+
heightLabelEntity: l
|
|
533
|
+
}, {
|
|
534
|
+
headEntity: c,
|
|
535
|
+
groundEntity: s,
|
|
536
|
+
columnEntity: o,
|
|
537
|
+
heightLabelEntity: l
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
setPointerCartesian3v(e, t) {
|
|
541
|
+
this._pointerLabelEntity.setCartesian3v(e), this._pointerLabelEntity.label.setText(`${Math.round(t).toString()} m`), this._pointerRayEntity.ray.setEndPosition3v(e);
|
|
542
|
+
let n = this._planet.ellipsoid.getSurfaceNormal3v(e);
|
|
543
|
+
this._pointerRayEntity.ray.setStartPosition3v(e.add(n.scale(-t))), this._pointerHeadEntity.setCartesian3v(e);
|
|
544
|
+
}
|
|
545
|
+
bindPlanet(e) {
|
|
546
|
+
this._planet = e;
|
|
547
|
+
}
|
|
548
|
+
init() {
|
|
549
|
+
this._activate();
|
|
550
|
+
}
|
|
551
|
+
onremove() {
|
|
552
|
+
this._deactivate();
|
|
553
|
+
}
|
|
554
|
+
_activate() {
|
|
555
|
+
this._planet.addLayer(this._trackLayer), this._planet.addLayer(this._groundPointersLayer), this._planet.addLayer(this._columnPointersLayer), this._planet.addLayer(this._headPointersLayer), this._planet.addLayer(this._heightsLayer), this._planet.addLayer(this._pointerLayer), this.renderer.events.on("ldblclick", this._onLClick), this.renderer.events.on("mousemove", this._onMouseMove), this.renderer.events.on("lup", this._onLUp), this._groundPointersLayer.events.on("mouseenter", this._onGroundPointerEnter), this._groundPointersLayer.events.on("mouseleave", this._onGroundPointerLeave), this._groundPointersLayer.events.on("ldown", this._onGroundPointerLDown), this._groundPointersLayer.events.on("lup", this._onGroundPointerLUp), this._headPointersLayer.events.on("mouseenter", this._onHeadPointerEnter), this._headPointersLayer.events.on("mouseleave", this._onHeadPointerLeave), this._headPointersLayer.events.on("ldown", this._onHeadPointerLDown), this._headPointersLayer.events.on("lup", this._onHeadPointerLUp), this.renderer.events.on("forwardpass", this._onForwardpass, this), this.setPointerVisibility(!1);
|
|
556
|
+
}
|
|
557
|
+
getPointLonLat(e) {
|
|
558
|
+
let t = this._headPointersLayer.getEntities()[e];
|
|
559
|
+
if (t) return t.getLonLat();
|
|
560
|
+
}
|
|
561
|
+
getPointsLonLat() {
|
|
562
|
+
let e = this._headPointersLayer.getEntities(), t = Array(e.length);
|
|
563
|
+
for (let n = 0, r = t.length; n < r; n++) {
|
|
564
|
+
let r = e[n];
|
|
565
|
+
t[n] = r.getLonLat();
|
|
566
|
+
}
|
|
567
|
+
return t;
|
|
568
|
+
}
|
|
569
|
+
getHeightMSL(e) {
|
|
570
|
+
return this._planet && this._planet.terrain.geoid ? this._planet.terrain.geoid.getHeightLonLat(e) : 0;
|
|
571
|
+
}
|
|
572
|
+
getHeightELLAsync(e) {
|
|
573
|
+
return new Promise((t, n) => {
|
|
574
|
+
this._planet.terrain.getHeightAsync(e, (r) => {
|
|
575
|
+
this._planet ? t(r + this.getHeightMSL(e)) : n();
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
addPointLonLatArrayAsync(e, t = !1) {
|
|
580
|
+
if (!this._planet) throw Error("Planet is not defined");
|
|
581
|
+
let n = this._planet.ellipsoid;
|
|
582
|
+
for (let t = 0, r = e.length - 1; t < r; t++) {
|
|
583
|
+
let r = n.lonLatToCartesian(e[t]), i = n.lonLatToCartesian(e[t + 1]);
|
|
584
|
+
if (r.distance(i) > 1e5) throw Error("Track is too long! 100 km is maximum.");
|
|
585
|
+
}
|
|
586
|
+
let r = Array(e.length);
|
|
587
|
+
for (let t = 0, n = e.length; t < n; t++) r[t] = this.addPointLonLatAsync(e[t], !0);
|
|
588
|
+
return Promise.all(r).then(() => {
|
|
589
|
+
t || this.events.dispatch(this.events.change, this);
|
|
590
|
+
}), r;
|
|
591
|
+
}
|
|
592
|
+
addPointLonLatAsync(e, t = !1) {
|
|
593
|
+
let n = this._planet.ellipsoid.lonLatToCartesian(e), i = this._planet.ellipsoid.getSurfaceNormal3v(n), a = new r(e.lon, e.lat), o = this._planet.ellipsoid.lonLatToCartesian(a), { headEntity: s, groundEntity: c, columnEntity: l, heightLabelEntity: u } = this._createGroundPointer(o);
|
|
594
|
+
return this._groundPointersLayer.add(c), this._columnPointersLayer.add(l), this._headPointersLayer.add(s), this._heightsLayer.add(u), this._trackEntity.polyline.addPoint3v(s.getCartesian()), c.properties.lonLatEll.lon = a.lon, c.properties.lonLatEll.lat = a.lat, c.properties.lonLatEll.height = a.height, new Promise((r) => {
|
|
595
|
+
this.getHeightELLAsync(e).then((a) => {
|
|
596
|
+
c.properties.lonLatEll.height = a;
|
|
597
|
+
let o = 10, l;
|
|
598
|
+
e.height === 0 ? (l = n.add(i.scaleTo(a)), n = l.add(i.scaleTo(o))) : (o = e.height - a, l = n.sub(i.scaleTo(o))), c.setCartesian3v(l), u.setCartesian3v(n), u.childEntities[0].setAbsoluteCartesian3v(n), u.label.setText(`${a.toFixed(1)} m`), u.childEntities[0].label.setText(`${o.toFixed(1)} m`), s.properties.altitude = o, s.setCartesian3v(n), s.properties.columnEntity.ray.setStartPosition3v(l), s.properties.columnEntity.ray.setEndPosition3v(n), this._trackEntity.polyline?.setPoint3v(n, s.properties.index), t || (this.events.dispatch(this.events.addpoint, s, this), this.events.dispatch(this.events.change, this)), r(s);
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
addGroundPointLonLatAsync(e, t = 10, n = !1) {
|
|
603
|
+
let r = this._planet.ellipsoid.lonLatToCartesian(e);
|
|
604
|
+
return this._addPoint(r, e, t, n);
|
|
605
|
+
}
|
|
606
|
+
addGroundPoint3vAsync(e, t = 10, n = !1) {
|
|
607
|
+
let r = this._planet.ellipsoid.cartesianToLonLat(e);
|
|
608
|
+
return this._addPoint(e, r, t, n);
|
|
609
|
+
}
|
|
610
|
+
_addPoint(e, t, n, r = !1) {
|
|
611
|
+
return new Promise((i, a) => {
|
|
612
|
+
let { headEntity: o, groundEntity: s, columnEntity: c, heightLabelEntity: l } = this._createGroundPointer(e, n);
|
|
613
|
+
this._groundPointersLayer.add(s), this._columnPointersLayer.add(c), this._headPointersLayer.add(o), this._heightsLayer.add(l), this._trackEntity.polyline.addPoint3v(o.getCartesian()), s.properties.lonLatEll.lon = t.lon, s.properties.lonLatEll.lat = t.lat, s.properties.lonLatEll.height = t.height, this.getHeightELLAsync(t).then((e) => {
|
|
614
|
+
s.properties.lonLatEll.height = t.height = e;
|
|
615
|
+
let a = this._planet.ellipsoid.lonLatToCartesian(t), c = this._planet.ellipsoid.getSurfaceNormal3v(a), u = a.add(c.scale(n));
|
|
616
|
+
l.setCartesian3v(u), l.childEntities[0].setAbsoluteCartesian3v(u), l.label.setText(`${e.toFixed(1)} m`), l.childEntities[0].label.setText(`${n.toFixed(1)} m`), o.setCartesian3v(u), o.properties.columnEntity.ray.setEndPosition3v(u), this._trackEntity.polyline?.setPoint3v(u, o.properties.index), r || (this.events.dispatch(this.events.addpoint, o, this), this.events.dispatch(this.events.change, this)), i(o);
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
setHeadPointCartesian3v(e, t) {
|
|
621
|
+
let n = this._headPointersLayer.getEntities()[e];
|
|
622
|
+
if (n) {
|
|
623
|
+
let r = this._planet.ellipsoid.lonLatToCartesian(n.properties.lonLatEll), i = t.length() - r.length();
|
|
624
|
+
i <= 0 && (t = r, i = 0), n.properties.altitude = i, n.setCartesian3v(t), n.properties.columnEntity.ray.setEndPosition3v(t), n.properties.heightLabelEntity.setCartesian3v(t), n.properties.heightLabelEntity.childEntities[0].setAbsoluteCartesian3v(t), n.properties.heightLabelEntity.childEntities[0].label.setText(`${i.toFixed(1)} m`), this._trackEntity.polyline.setPoint3v(t, e), this.events.dispatch(this.events.change, this._pickedHeadEntity);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
setGroundPointCartesian3v(e, t) {
|
|
628
|
+
let n = this._groundPointersLayer.getEntities()[e];
|
|
629
|
+
if (n) {
|
|
630
|
+
let e = this._planet.ellipsoid.cartesianToLonLat(t);
|
|
631
|
+
n.properties.lonLatEll.lon = e.lon, n.properties.lonLatEll.lat = e.lat, n.properties.lonLatEll.height = e.height;
|
|
632
|
+
let r = this._planet.ellipsoid.getSurfaceNormal3v(t), i = n.properties.headEntity, a = n.properties.heightLabelEntity, o = n.properties.altitude;
|
|
633
|
+
n.setCartesian3v(t);
|
|
634
|
+
let s = t.add(r.scale(o));
|
|
635
|
+
i.setCartesian3v(s), i.properties.columnEntity.ray.setStartPosition3v(t), i.properties.columnEntity.ray.setEndPosition3v(s), this._trackEntity.polyline?.setPoint3v(s, i.properties.index), a.setCartesian3v(s), a.childEntities[0].setAbsoluteCartesian3v(s), a.label.setText(`${e.height.toFixed(1)} m`), a.childEntities[0].label.setText(`${o.toFixed(1)} m`), this.events.dispatch(this.events.change, n.properties.headEntity);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
_deactivate() {
|
|
639
|
+
this.renderer.events.off("forwardpass", this._onForwardpass), this.renderer.events.off("ldblclick", this._onLClick), this.renderer.events.off("mousemove", this._onMouseMove), this.renderer.events.off("lup", this._onLUp), this._groundPointersLayer.events.off("mouseenter", this._onGroundPointerEnter), this._groundPointersLayer.events.off("mouseleave", this._onGroundPointerLeave), this._groundPointersLayer.events.off("ldown", this._onGroundPointerLDown), this._groundPointersLayer.events.off("lup", this._onGroundPointerLUp), this._headPointersLayer.events.off("mouseenter", this._onHeadPointerEnter), this._headPointersLayer.events.off("mouseleave", this._onHeadPointerLeave), this._headPointersLayer.events.off("ldown", this._onHeadPointerLDown), this._headPointersLayer.events.off("lup", this._onHeadPointerLUp), this._trackLayer.remove(), this._groundPointersLayer.remove(), this._headPointersLayer.remove(), this._columnPointersLayer.remove(), this._trackLayer.remove(), this._heightsLayer.remove(), this._pointerLayer.remove(), this.clear();
|
|
640
|
+
}
|
|
641
|
+
setPointerVisibility(e) {
|
|
642
|
+
this._pointerLayer.setVisibility(e);
|
|
643
|
+
}
|
|
644
|
+
setVisibility(e) {
|
|
645
|
+
this._groundPointersLayer.setVisibility(e), this._trackLayer.setVisibility(e), this._columnPointersLayer.setVisibility(e), this._headPointersLayer.setVisibility(e), this._trackLayer.setVisibility(e), this._heightsLayer.setVisibility(e), this._pointerLayer.setVisibility(e);
|
|
646
|
+
}
|
|
647
|
+
clear() {
|
|
648
|
+
this._headPointersLayer.setEntities([]), this._groundPointersLayer.setEntities([]), this._columnPointersLayer.setEntities([]), this._heightsLayer.setEntities([]), this._trackEntity.polyline.setPath3v([]);
|
|
649
|
+
}
|
|
650
|
+
get ellipsoid() {
|
|
651
|
+
return this._planet ? this._planet.ellipsoid : null;
|
|
652
|
+
}
|
|
653
|
+
}, q = ["change", "addpoint"], ae = "<div class=\"og-elevationprofile-buttons\"></div>", J = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg width=\"30\" height=\"30\" viewBox=\"0 0 30 30\" version=\"1.1\">\n <g transform=\"translate(0,-289.0625)\">\n <path d=\"M 15 6 C 10.041282 6 6 10.04128 6 15 C 6 19.95872 10.041282 24 15 24 C 16.586491 24 18.07668 23.58246 19.373047 22.857422 L 17.888672 21.375 C 17.00816 21.772814 16.032235 22 15 22 C 11.122162 22 8 18.87784 8 15 C 8 11.12216 11.122162 8 15 8 C 18.877838 8 22 11.12216 22 15 L 19 15 L 23 20 L 27 15 L 24 15 C 24 10.04128 19.958718 6 15 6 z \" transform=\"translate(0,289.0625)\" />\n </g>\n</svg>", oe = "<?xml version=\"1.0\" encoding=\"utf-8\"?><svg width=\"800px\" height=\"800px\" viewBox=\"0 0 32 32\" id=\"icon\" xmlns=\"http://www.w3.org/2000/svg\"><defs><style>.cls-1{fill:none;}</style></defs><title>list</title><rect x=\"10\" y=\"6\" width=\"18\" height=\"2\"/><rect x=\"10\" y=\"24\" width=\"18\" height=\"2\"/><rect x=\"10\" y=\"15\" width=\"18\" height=\"2\"/><rect x=\"4\" y=\"15\" width=\"2\" height=\"2\"/><rect x=\"4\" y=\"6\" width=\"2\" height=\"2\"/><rect x=\"4\" y=\"24\" width=\"2\" height=\"2\"/></svg>", se = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 256 256\" enable-background=\"new 0 0 256 256\" xml:space=\"preserve\">\n<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>\n<g><g><path fill=\"#000000\" d=\"M127,169.4c23.7,0,42.8-18.3,42.8-41s-19.2-41-42.8-41c-23.7,0-42.8,18.4-42.8,41S103.4,169.4,127,169.4z\"/><path fill=\"#000000\" d=\"M221.7,120.2c-3.8-44-40.9-78.9-87-82V15h-16.3v23.6c-44.8,4-80.3,38.5-84.1,81.7H10v15.6h24.3c3.8,43.1,39.3,77.4,84.1,81.7V241h16.3v-23.2c46-3.1,83.2-37.9,87-82H246v-15.6H221.7L221.7,120.2L221.7,120.2z M128,201.6c-42.5,0-76.7-33-76.7-73.4c0-40.4,34.5-73.4,76.7-73.4c42.5,0,76.7,33,76.7,73.4C204.7,168.5,170.5,201.6,128,201.6L128,201.6z\"/></g></g>\n</svg>", ce = [
|
|
654
|
+
"reset",
|
|
655
|
+
"list",
|
|
656
|
+
"location"
|
|
657
|
+
], le = class extends h.View {
|
|
658
|
+
constructor(e = {}) {
|
|
659
|
+
super({
|
|
660
|
+
...e,
|
|
661
|
+
template: ae
|
|
662
|
+
}), this.events = this.events.registerNames(ce), this.pointListBtn = new h.ToggleButton({
|
|
663
|
+
classList: ["og-elevationprofile-button"],
|
|
664
|
+
icon: oe,
|
|
665
|
+
title: "Point List"
|
|
666
|
+
}), this.pointListBtn.events.on("change", (e) => {
|
|
667
|
+
this.events.dispatch(this.events.list, e);
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
render(e) {
|
|
671
|
+
super.render(e);
|
|
672
|
+
let t = new h.Button({
|
|
673
|
+
classList: ["og-elevationprofile-button"],
|
|
674
|
+
icon: J,
|
|
675
|
+
title: "Reset"
|
|
676
|
+
});
|
|
677
|
+
t.appendTo(this.el), t.events.on("click", () => {
|
|
678
|
+
this.model.clear(), this.events.dispatch(this.events.reset, this);
|
|
679
|
+
}), this.pointListBtn.appendTo(this.el);
|
|
680
|
+
let n = new h.Button({
|
|
681
|
+
classList: ["og-elevationprofile-button", "og-elevationprofile-button__location"],
|
|
682
|
+
icon: se,
|
|
683
|
+
title: "View bounds"
|
|
684
|
+
});
|
|
685
|
+
return n.appendTo(this.el), n.events.on("click", () => {
|
|
686
|
+
this.events.dispatch(this.events.location, this);
|
|
687
|
+
}), this;
|
|
688
|
+
}
|
|
689
|
+
}, ue = "<div class=\"og-elevationprofile-list\">\n <textarea placeholder=\"[[lon, lat, height], [lon, lat, height], ..., [lon, lat, height]]\"></textarea>\n <div class=\"og-elevationprofile-list-buttons\"></div>\n </div>", de = class extends h.Dialog {
|
|
690
|
+
constructor(e) {
|
|
691
|
+
super({
|
|
692
|
+
title: "Points List",
|
|
693
|
+
visible: !1,
|
|
694
|
+
resizable: !0,
|
|
695
|
+
useHide: !0,
|
|
696
|
+
top: 150,
|
|
697
|
+
left: 200,
|
|
698
|
+
width: 400,
|
|
699
|
+
height: 300,
|
|
700
|
+
minHeight: 100,
|
|
701
|
+
minWidth: 100,
|
|
702
|
+
...e
|
|
703
|
+
}), this._onApplyClick = () => {
|
|
704
|
+
try {
|
|
705
|
+
this.model.clear();
|
|
706
|
+
let e = JSON.parse(this.$textarea.value), t = Array(e.length);
|
|
707
|
+
for (let n = 0; n < e.length; n++) {
|
|
708
|
+
let i = e[n];
|
|
709
|
+
t[n] = new r(i[0], i[1], i[2]);
|
|
710
|
+
}
|
|
711
|
+
this.model.addPointLonLatArrayAsync(t);
|
|
712
|
+
} catch (e) {
|
|
713
|
+
console.error(e);
|
|
714
|
+
}
|
|
715
|
+
}, this.$textarea = null;
|
|
716
|
+
}
|
|
717
|
+
render(e) {
|
|
718
|
+
super.render(e);
|
|
719
|
+
let t = new h.View({ template: ue });
|
|
720
|
+
t.appendTo(this.container);
|
|
721
|
+
let n = new h.Button({
|
|
722
|
+
classList: ["og-elevationprofile-list-apply"],
|
|
723
|
+
icon: "Apply"
|
|
724
|
+
});
|
|
725
|
+
return n.appendTo(t.select(".og-elevationprofile-list-buttons")), n.events.on("click", this._onApplyClick), this.$textarea = t.select("textarea"), this;
|
|
726
|
+
}
|
|
727
|
+
}, { distanceFormatExt: Y } = g, fe = "<div class=\"og-elevationprofile-legend\">\n <div class=\"og-elevationprofile-legend__row og-elevationprofile-legend__track\">\n <div class=\"og-elevationprofile-square\"></div>\n <div class=\"og-elevationprofile-value\">0</div>\n <div class=\"og-elevationprofile-units\">m</div>\n </div>\n <div class=\"og-elevationprofile-legend__row og-elevationprofile-legend__ground\">\n <div class=\"og-elevationprofile-square\"></div>\n <div class=\"og-elevationprofile-value\">0</div>\n <div class=\"og-elevationprofile-units\">m</div>\n </div>\n <div class=\"og-elevationprofile-legend__row og-elevationprofile-legend__warning\"> \n <div class=\"og-elevationprofile-square\"></div>\n <div class=\"og-elevationprofile-value\">0</div>\n <div class=\"og-elevationprofile-units\">m</div>\n </div>\n <div class=\"og-elevationprofile-legend__row og-elevationprofile-legend__collision\">\n <div class=\"og-elevationprofile-square\"></div>\n <div class=\"og-elevationprofile-value\">0</div>\n <div class=\"og-elevationprofile-units\">m</div>\n </div>\n </div>", pe = class extends h.View {
|
|
728
|
+
constructor(e = {}) {
|
|
729
|
+
super({
|
|
730
|
+
...e,
|
|
731
|
+
template: fe
|
|
732
|
+
}), this.$groundValue = null, this.$trackValue = null, this.$warningValue = null, this.$collisionValue = null, this.$trackUnits = null, this.$groundUnits = null, this.$warningUnits = null, this.$collisionUnits = null;
|
|
733
|
+
}
|
|
734
|
+
render(e) {
|
|
735
|
+
return super.render(e), this.$trackValue = this.select(".og-elevationprofile-legend__track .og-elevationprofile-value"), this.$groundValue = this.select(".og-elevationprofile-legend__ground .og-elevationprofile-value"), this.$warningValue = this.select(".og-elevationprofile-legend__warning .og-elevationprofile-value"), this.$collisionValue = this.select(".og-elevationprofile-legend__collision .og-elevationprofile-value"), this.$trackUnits = this.select(".og-elevationprofile-legend__track .og-elevationprofile-units"), this.$groundUnits = this.select(".og-elevationprofile-legend__ground .og-elevationprofile-units"), this.$warningUnits = this.select(".og-elevationprofile-legend__warning .og-elevationprofile-units"), this.$collisionUnits = this.select(".og-elevationprofile-legend__collision .og-elevationprofile-units"), this;
|
|
736
|
+
}
|
|
737
|
+
clear() {
|
|
738
|
+
this.$trackValue && (this.$trackValue.innerText = "0"), this.$trackUnits && (this.$trackUnits.innerText = "m"), this.$groundValue && (this.$groundValue.innerText = "0"), this.$groundUnits && (this.$groundUnits.innerText = "m"), this.$warningValue && (this.$warningValue.innerText = "0"), this.$warningUnits && (this.$warningUnits.innerText = "m"), this.$collisionValue && (this.$collisionValue.innerText = "0"), this.$collisionUnits && (this.$collisionUnits.innerText = "m");
|
|
739
|
+
}
|
|
740
|
+
setTrackLength(e) {
|
|
741
|
+
let t = Y(e);
|
|
742
|
+
this.$trackValue.innerText = t[0], this.$trackUnits.innerText = t[1];
|
|
743
|
+
}
|
|
744
|
+
setGroundLength(e) {
|
|
745
|
+
let t = Y(e);
|
|
746
|
+
this.$groundValue.innerText = t[0], this.$groundUnits.innerText = t[1];
|
|
747
|
+
}
|
|
748
|
+
setWarningLength(e) {
|
|
749
|
+
let t = Y(e);
|
|
750
|
+
this.$warningValue.innerText = t[0], this.$warningUnits.innerText = t[1];
|
|
751
|
+
}
|
|
752
|
+
setCollisionLength(e) {
|
|
753
|
+
let t = Y(e);
|
|
754
|
+
this.$collisionValue.innerText = t[0], this.$collisionUnits.innerText = t[1];
|
|
755
|
+
}
|
|
756
|
+
}, me = ".og-elevationprofile{width:100%;height:100%;position:absolute;overflow:hidden}.og-elevationprofile__container{flex-direction:column;align-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative}.og-elevationprofile__menu{width:100%;height:43px;position:relative}.og-elevationprofile__graph{width:100%;height:100%;position:relative}.og-elevationprofile-legend{color:var(--grey6);z-index:1;margin:5px;font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif;font-size:12px;display:flex;position:absolute;top:0;right:0}.og-elevationprofile-legend__row{width:70px;padding:5px;position:relative}.og-elevationprofile-square{float:left;width:6px;height:6px;margin:5px;position:relative}.og-elevationprofile-legend__track .og-elevationprofile-square{background-color:#00ff32}.og-elevationprofile-legend__ground .og-elevationprofile-square{background-color:#c6c6c6}.og-elevationprofile-legend__warning .og-elevationprofile-square{background-color:#ff0}.og-elevationprofile-legend__collision .og-elevationprofile-square{background-color:red}.og-elevationprofile-units{float:left;padding-left:5px;display:inline-block;position:relative}.og-elevationprofile-value{float:left;text-align:right;white-space:nowrap;text-overflow:ellipsis;width:30px;display:inline-block;position:relative;overflow:hidden}.og-elevationprofile-buttons{display:inline-block;position:absolute;top:0;left:0}.og-elevationprofile-button{float:left;width:25px;height:25px;margin:3px}.og-elevationprofile-list{flex-direction:column;width:100%;height:100%;display:flex;position:relative}.og-elevationprofile-list textarea{resize:none;background:var(--grey0);border:1px solid var(--grey2);width:100%;height:100%;color:var(--grey6);padding:5px;position:relative}.og-elevationprofile-list-buttons{flex-direction:row;justify-content:right;align-items:center;height:60px;display:flex;position:relative}.og-elevationprofile-list-apply{float:right;border:1px solid var(--grey2);color:var(--grey6);margin-right:15px;padding:4px 10px 7px}.og-elevationprofile_pointer{height:100%;position:absolute;top:0;left:0}.og-elevationprofile-line{background-color:#fff;width:3px;height:30px;margin-left:-1.5px;position:absolute}.og-elevationprofile-label{color:#fff;position:absolute;top:0;left:0}.og-elevationprofile-button__location svg{width:17px;height:17px}.og-elevationprofile-loading{opacity:.3;z-index:2;background-color:#000;flex-direction:row;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:absolute}@keyframes ldio-p0v5a1f6oz{0%{opacity:1}50%{opacity:.5}to{opacity:1}}.ldio-p0v5a1f6oz div{width:11px;height:40px;animation:.934579s cubic-bezier(.5,0,.5,1) infinite ldio-p0v5a1f6oz;position:absolute;top:30px}.ldio-p0v5a1f6oz div:first-child{background:var(--grey2);animation-delay:-.560748s;transform:translate(14.5px)}.ldio-p0v5a1f6oz div:nth-child(2){background:var(--grey3);animation-delay:-.373832s;transform:translate(34.5px)}.ldio-p0v5a1f6oz div:nth-child(3){background:var(--grey4);animation-delay:-.186916s;transform:translate(54.5px)}.ldio-p0v5a1f6oz div:nth-child(4){background:var(--grey6);animation-delay:-.934579s;transform:translate(74.5px)}.loadingio-spinner-bars-r354qqyl5v{background:0 0;width:88px;height:88px;display:inline-block;overflow:hidden}.ldio-p0v5a1f6oz{backface-visibility:hidden;transform-origin:0 0;width:100%;height:100%;position:relative;transform:translateZ(0)scale(.88)}.ldio-p0v5a1f6oz div{box-sizing:content-box}", X = null, Z = 0;
|
|
757
|
+
function Q() {
|
|
758
|
+
Z++ === 0 && (X = document.createElement("style"), X.textContent = me, document.head.appendChild(X));
|
|
759
|
+
}
|
|
760
|
+
function he() {
|
|
761
|
+
Z > 0 && --Z === 0 && (X?.remove(), X = null);
|
|
762
|
+
}
|
|
763
|
+
// src/ElevationProfileControl.ts
|
|
764
|
+
var { throttle: ge } = g, _e = "<div class=\"og-elevationprofile__container\">\n <div class=\"og-elevationprofile__menu\"></div>\n <div class=\"og-elevationprofile__graph\"></div>\n </div>", ve = "<svg style=\"width: 2em; height: 2em;\" viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M128 896v-158.293333l331.946667-191.573334 160.853333 93.866667L896 480V896H128M896 381.44l-275.2 159.146667-160.853333-92.586667L128 640v-94.293333l331.946667-191.573334 160.853333 93.866667L896 288v93.44z\" fill=\"\" /></svg>", $ = class extends e {
|
|
765
|
+
constructor(e = {}) {
|
|
766
|
+
super({
|
|
767
|
+
name: "ElevationProfileControl",
|
|
768
|
+
...e
|
|
769
|
+
}), this._onSceneChange = () => {
|
|
770
|
+
this._collectProfileThrottled();
|
|
771
|
+
}, this._onElevationProfilePointer = (e, t, n, r, i, a, o, s) => {
|
|
772
|
+
let c = this._elevationProfileScene.getPointLonLat(a), l = this._elevationProfileScene.getPointLonLat(a + 1), u = this.planet.ellipsoid.lonLatToCartesian(c), d = this.planet.ellipsoid.lonLatToCartesian(l), f = (e - t[0]) / (n[0] - t[0]), p = d.sub(u);
|
|
773
|
+
this._elevationProfileScene.setPointerCartesian3v(u.add(p.scale(f)), s);
|
|
774
|
+
}, this._onElevationProfileDblClick = (e, t, n, r, i, a, o, s) => {
|
|
775
|
+
let c = this._elevationProfileScene.getPointLonLat(a), l = this._elevationProfileScene.getPointLonLat(a + 1), u = this.planet.ellipsoid.lonLatToCartesian(c), d = this.planet.ellipsoid.lonLatToCartesian(l), f = (e - t[0]) / (n[0] - t[0]), p = d.sub(u), m = u.add(p.scale(f));
|
|
776
|
+
this.planet.camera.flyDistance(m, this.planet.camera.eye.distance(m));
|
|
777
|
+
}, this._onElevationProfileMouseEnter = () => {
|
|
778
|
+
this._elevationProfileView.model.pointsReady && this._elevationProfileScene.setPointerVisibility(!0);
|
|
779
|
+
}, this._onElevationProfileMouseLeave = () => {}, this._elevationProfileScene = new K(), this._elevationProfileView = new L(), this._elevationProfileLegend = new pe(), this._elevationProfileButtonsView = new le({ model: this._elevationProfileView.model }), this._elevationProfileView.events.on("pointer", this._onElevationProfilePointer), this._elevationProfileView.events.on("dblclick", this._onElevationProfileDblClick), this._elevationProfileView.events.on("mouseenter", this._onElevationProfileMouseEnter), this._elevationProfileView.events.on("mouseleave", this._onElevationProfileMouseLeave), this._dialog = new h.Dialog({
|
|
780
|
+
title: "Elevation Profile",
|
|
781
|
+
visible: !1,
|
|
782
|
+
resizable: !0,
|
|
783
|
+
useHide: !0,
|
|
784
|
+
top: 175,
|
|
785
|
+
left: 65,
|
|
786
|
+
width: 400,
|
|
787
|
+
height: 200,
|
|
788
|
+
minHeight: 100,
|
|
789
|
+
minWidth: 100
|
|
790
|
+
}), this._graphView = new h.View({ template: _e }), this._poiListDialog = new de({ model: this._elevationProfileScene }), this._toggleBtn = new h.ToggleButton({
|
|
791
|
+
classList: ["og-map-button", "og-elevationprofile_button"],
|
|
792
|
+
icon: ve
|
|
793
|
+
}), this._collectProfileThrottled = ge(() => {
|
|
794
|
+
let e = this._elevationProfileScene.getPointsLonLat();
|
|
795
|
+
this._elevationProfileView.model.collectProfile(e);
|
|
796
|
+
}, 250);
|
|
797
|
+
}
|
|
798
|
+
oninit() {
|
|
799
|
+
Q(), this._dialog.appendTo(this.planet.renderer.getUIContainer()), this._graphView.appendTo(this._dialog.container), this._toggleBtn.appendTo(this.renderer.topLeftContainer()), this._dialog.events.on("visibility", (e) => {
|
|
800
|
+
this._toggleBtn.setActive(e), e ? (this._dialog.positionNearElementOnFirstOpen(this._toggleBtn.el, this.renderer.getUIContainer()), this.activate(), this._elevationProfileView.resize()) : this.deactivate();
|
|
801
|
+
}), this._toggleBtn.events.on("change", (e) => {
|
|
802
|
+
this._dialog.setVisibility(e);
|
|
803
|
+
}), this._elevationProfileView.appendTo(this._graphView.select(".og-elevationprofile__graph")), this._elevationProfileView.model.bindPlanet(this.planet), this._elevationProfileView.model.events.on("clear", () => {
|
|
804
|
+
this._elevationProfileScene.clear(), this._elevationProfileLegend.clear();
|
|
805
|
+
}), this._elevationProfileView.model.events.on("startcollecting", () => {
|
|
806
|
+
this._elevationProfileScene.setPointerVisibility(!1);
|
|
807
|
+
}), this._elevationProfileView.events.on("tracklength", (e) => {
|
|
808
|
+
this._elevationProfileLegend.setTrackLength(e);
|
|
809
|
+
}), this._elevationProfileView.events.on("groundlength", (e) => {
|
|
810
|
+
this._elevationProfileLegend.setGroundLength(e);
|
|
811
|
+
}), this._elevationProfileView.events.on("warninglength", (e) => {
|
|
812
|
+
this._elevationProfileLegend.setWarningLength(e);
|
|
813
|
+
}), this._elevationProfileView.events.on("collisionlength", (e) => {
|
|
814
|
+
this._elevationProfileLegend.setCollisionLength(e);
|
|
815
|
+
}), this._poiListDialog.appendTo(this.planet.renderer.getUIContainer()), this._poiListDialog.events.on("visibility", (e) => {
|
|
816
|
+
this._elevationProfileButtonsView.pointListBtn.setActive(e, !0);
|
|
817
|
+
}), this._elevationProfileLegend.appendTo(this._graphView.select(".og-elevationprofile__menu")), this._elevationProfileButtonsView.appendTo(this._graphView.select(".og-elevationprofile__menu")), this._elevationProfileButtonsView.events.on("list", (e) => {
|
|
818
|
+
this._poiListDialog.setVisibility(e);
|
|
819
|
+
}), this._elevationProfileButtonsView.events.on("location", (e) => {
|
|
820
|
+
this._elevationProfileScene.flyExtent();
|
|
821
|
+
}), this._elevationProfileButtonsView.events.on("reset", (e) => {
|
|
822
|
+
this._elevationProfileScene.setPointerVisibility(!1);
|
|
823
|
+
}), this._elevationProfileScene.events.on("change", this._onSceneChange);
|
|
824
|
+
}
|
|
825
|
+
onactivate() {
|
|
826
|
+
this.planet && this._elevationProfileScene.bindPlanet(this.planet), this.renderer && this.renderer.addScene(this._elevationProfileScene);
|
|
827
|
+
}
|
|
828
|
+
ondeactivate() {
|
|
829
|
+
this._poiListDialog.setVisibility(!1), this._elevationProfileView.model.clear(), this.renderer && this.renderer.removeNode(this._elevationProfileScene), this._dialog.hide();
|
|
830
|
+
}
|
|
831
|
+
onremove() {
|
|
832
|
+
this._elevationProfileView.remove(), this._poiListDialog.remove(), this._dialog.remove(), this._toggleBtn.remove(), this._initialized && he();
|
|
833
|
+
}
|
|
834
|
+
}, ye = p({
|
|
835
|
+
id: "og.elevation-profile",
|
|
836
|
+
version: "1.0.0",
|
|
837
|
+
og: "^1.0.0-rc.50",
|
|
838
|
+
extensionApi: "^1",
|
|
839
|
+
activate(e) {
|
|
840
|
+
if (!e.globe) throw Error("og.elevation-profile needs a Globe");
|
|
841
|
+
let t = new $();
|
|
842
|
+
return e.globe.planet.addControl(t), t;
|
|
843
|
+
},
|
|
844
|
+
deactivate(e) {
|
|
845
|
+
e.get("og.elevation-profile")?.exports?.remove();
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
export { b as COLLISION, E as ElevationProfile, $ as ElevationProfileControl, K as ElevationProfileScene, L as ElevationProfileView, ee as SAFE, te as WARNING, ye as default };
|