@powsybl/network-map-layers 3.1.0 → 3.3.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/dist/index.d.cts +3 -11
- package/dist/index.d.ts +3 -11
- package/dist/powsybl-network-map-layers.cjs +371 -1941
- package/dist/powsybl-network-map-layers.js +366 -1936
- package/package.json +23 -12
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const CheapRuler = require("cheap-ruler");
|
|
4
|
+
const geolib = require("geolib");
|
|
5
|
+
const constants = require("@luma.gl/constants");
|
|
4
6
|
const engine = require("@luma.gl/engine");
|
|
5
7
|
const core = require("@deck.gl/core");
|
|
6
8
|
const extensions = require("@deck.gl/extensions");
|
|
@@ -27,1648 +29,7 @@ var EQUIPMENT_TYPES = /* @__PURE__ */ ((EQUIPMENT_TYPES2) => {
|
|
|
27
29
|
})(EQUIPMENT_TYPES || {});
|
|
28
30
|
const isMapSubstation = (object) => "voltageLevels" in object;
|
|
29
31
|
const isMapLine = (object) => "id" in object && "voltageLevelId1" in object && "voltageLevelId2" in object;
|
|
30
|
-
const
|
|
31
|
-
kilometers: 1,
|
|
32
|
-
miles: 1e3 / 1609.344,
|
|
33
|
-
nauticalmiles: 1e3 / 1852,
|
|
34
|
-
meters: 1e3,
|
|
35
|
-
metres: 1e3,
|
|
36
|
-
yards: 1e3 / 0.9144,
|
|
37
|
-
feet: 1e3 / 0.3048,
|
|
38
|
-
inches: 1e3 / 0.0254
|
|
39
|
-
};
|
|
40
|
-
const RE = 6378.137;
|
|
41
|
-
const FE = 1 / 298.257223563;
|
|
42
|
-
const E2 = FE * (2 - FE);
|
|
43
|
-
const RAD = Math.PI / 180;
|
|
44
|
-
class CheapRuler {
|
|
45
|
-
/**
|
|
46
|
-
* Creates a ruler object from tile coordinates (y and z).
|
|
47
|
-
*
|
|
48
|
-
* @param {number} y
|
|
49
|
-
* @param {number} z
|
|
50
|
-
* @param {keyof typeof factors} [units='kilometers']
|
|
51
|
-
* @returns {CheapRuler}
|
|
52
|
-
* @example
|
|
53
|
-
* const ruler = cheapRuler.fromTile(1567, 12);
|
|
54
|
-
* //=ruler
|
|
55
|
-
*/
|
|
56
|
-
static fromTile(y, z, units) {
|
|
57
|
-
const n = Math.PI * (1 - 2 * (y + 0.5) / Math.pow(2, z));
|
|
58
|
-
const lat = Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) / RAD;
|
|
59
|
-
return new CheapRuler(lat, units);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Multipliers for converting between units.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* // convert 50 meters to yards
|
|
66
|
-
* 50 * CheapRuler.units.yards / CheapRuler.units.meters;
|
|
67
|
-
*/
|
|
68
|
-
static get units() {
|
|
69
|
-
return factors;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
|
|
73
|
-
*
|
|
74
|
-
* @param {number} lat latitude
|
|
75
|
-
* @param {keyof typeof factors} [units='kilometers']
|
|
76
|
-
* @example
|
|
77
|
-
* const ruler = cheapRuler(35.05, 'miles');
|
|
78
|
-
* //=ruler
|
|
79
|
-
*/
|
|
80
|
-
constructor(lat, units) {
|
|
81
|
-
if (lat === void 0) throw new Error("No latitude given.");
|
|
82
|
-
if (units && !factors[units]) throw new Error(`Unknown unit ${units}. Use one of: ${Object.keys(factors).join(", ")}`);
|
|
83
|
-
const m = RAD * RE * (units ? factors[units] : 1);
|
|
84
|
-
const coslat = Math.cos(lat * RAD);
|
|
85
|
-
const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
|
|
86
|
-
const w = Math.sqrt(w2);
|
|
87
|
-
this.kx = m * w * coslat;
|
|
88
|
-
this.ky = m * w * w2 * (1 - E2);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Given two points of the form [longitude, latitude], returns the distance.
|
|
92
|
-
*
|
|
93
|
-
* @param {[number, number]} a point [longitude, latitude]
|
|
94
|
-
* @param {[number, number]} b point [longitude, latitude]
|
|
95
|
-
* @returns {number} distance
|
|
96
|
-
* @example
|
|
97
|
-
* const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
|
|
98
|
-
* //=distance
|
|
99
|
-
*/
|
|
100
|
-
distance(a, b) {
|
|
101
|
-
const dx = wrap(a[0] - b[0]) * this.kx;
|
|
102
|
-
const dy = (a[1] - b[1]) * this.ky;
|
|
103
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns the bearing between two points in angles.
|
|
107
|
-
*
|
|
108
|
-
* @param {[number, number]} a point [longitude, latitude]
|
|
109
|
-
* @param {[number, number]} b point [longitude, latitude]
|
|
110
|
-
* @returns {number} bearing
|
|
111
|
-
* @example
|
|
112
|
-
* const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
|
|
113
|
-
* //=bearing
|
|
114
|
-
*/
|
|
115
|
-
bearing(a, b) {
|
|
116
|
-
const dx = wrap(b[0] - a[0]) * this.kx;
|
|
117
|
-
const dy = (b[1] - a[1]) * this.ky;
|
|
118
|
-
return Math.atan2(dx, dy) / RAD;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns a new point given distance and bearing from the starting point.
|
|
122
|
-
*
|
|
123
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
124
|
-
* @param {number} dist distance
|
|
125
|
-
* @param {number} bearing
|
|
126
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
127
|
-
* @example
|
|
128
|
-
* const point = ruler.destination([30.5, 50.5], 0.1, 90);
|
|
129
|
-
* //=point
|
|
130
|
-
*/
|
|
131
|
-
destination(p, dist, bearing) {
|
|
132
|
-
const a = bearing * RAD;
|
|
133
|
-
return this.offset(
|
|
134
|
-
p,
|
|
135
|
-
Math.sin(a) * dist,
|
|
136
|
-
Math.cos(a) * dist
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Returns a new point given easting and northing offsets (in ruler units) from the starting point.
|
|
141
|
-
*
|
|
142
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
143
|
-
* @param {number} dx easting
|
|
144
|
-
* @param {number} dy northing
|
|
145
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
146
|
-
* @example
|
|
147
|
-
* const point = ruler.offset([30.5, 50.5], 10, 10);
|
|
148
|
-
* //=point
|
|
149
|
-
*/
|
|
150
|
-
offset(p, dx, dy) {
|
|
151
|
-
return [
|
|
152
|
-
p[0] + dx / this.kx,
|
|
153
|
-
p[1] + dy / this.ky
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Given a line (an array of points), returns the total line distance.
|
|
158
|
-
*
|
|
159
|
-
* @param {[number, number][]} points [longitude, latitude]
|
|
160
|
-
* @returns {number} total line distance
|
|
161
|
-
* @example
|
|
162
|
-
* const length = ruler.lineDistance([
|
|
163
|
-
* [-67.031, 50.458], [-67.031, 50.534],
|
|
164
|
-
* [-66.929, 50.534], [-66.929, 50.458]
|
|
165
|
-
* ]);
|
|
166
|
-
* //=length
|
|
167
|
-
*/
|
|
168
|
-
lineDistance(points) {
|
|
169
|
-
let total = 0;
|
|
170
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
171
|
-
total += this.distance(points[i], points[i + 1]);
|
|
172
|
-
}
|
|
173
|
-
return total;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Given a polygon (an array of rings, where each ring is an array of points), returns the area.
|
|
177
|
-
*
|
|
178
|
-
* @param {[number, number][][]} polygon
|
|
179
|
-
* @returns {number} area value in the specified units (square kilometers by default)
|
|
180
|
-
* @example
|
|
181
|
-
* const area = ruler.area([[
|
|
182
|
-
* [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
|
|
183
|
-
* [-66.929, 50.458], [-67.031, 50.458]
|
|
184
|
-
* ]]);
|
|
185
|
-
* //=area
|
|
186
|
-
*/
|
|
187
|
-
area(polygon) {
|
|
188
|
-
let sum = 0;
|
|
189
|
-
for (let i = 0; i < polygon.length; i++) {
|
|
190
|
-
const ring = polygon[i];
|
|
191
|
-
for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
|
|
192
|
-
sum += wrap(ring[j][0] - ring[k][0]) * (ring[j][1] + ring[k][1]) * (i ? -1 : 1);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return Math.abs(sum) / 2 * this.kx * this.ky;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Returns the point at a specified distance along the line.
|
|
199
|
-
*
|
|
200
|
-
* @param {[number, number][]} line
|
|
201
|
-
* @param {number} dist distance
|
|
202
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
203
|
-
* @example
|
|
204
|
-
* const point = ruler.along(line, 2.5);
|
|
205
|
-
* //=point
|
|
206
|
-
*/
|
|
207
|
-
along(line, dist) {
|
|
208
|
-
let sum = 0;
|
|
209
|
-
if (dist <= 0) return line[0];
|
|
210
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
211
|
-
const p0 = line[i];
|
|
212
|
-
const p1 = line[i + 1];
|
|
213
|
-
const d = this.distance(p0, p1);
|
|
214
|
-
sum += d;
|
|
215
|
-
if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
|
|
216
|
-
}
|
|
217
|
-
return line[line.length - 1];
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Returns the distance from a point `p` to a line segment `a` to `b`.
|
|
221
|
-
*
|
|
222
|
-
* @pointToSegmentDistance
|
|
223
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
224
|
-
* @param {[number, number]} a segment point 1 [longitude, latitude]
|
|
225
|
-
* @param {[number, number]} b segment point 2 [longitude, latitude]
|
|
226
|
-
* @returns {number} distance
|
|
227
|
-
* @example
|
|
228
|
-
* const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
|
|
229
|
-
* //=distance
|
|
230
|
-
*/
|
|
231
|
-
pointToSegmentDistance(p, a, b) {
|
|
232
|
-
let [x, y] = a;
|
|
233
|
-
let dx = wrap(b[0] - x) * this.kx;
|
|
234
|
-
let dy = (b[1] - y) * this.ky;
|
|
235
|
-
if (dx !== 0 || dy !== 0) {
|
|
236
|
-
const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
237
|
-
if (t > 1) {
|
|
238
|
-
x = b[0];
|
|
239
|
-
y = b[1];
|
|
240
|
-
} else if (t > 0) {
|
|
241
|
-
x += dx / this.kx * t;
|
|
242
|
-
y += dy / this.ky * t;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
dx = wrap(p[0] - x) * this.kx;
|
|
246
|
-
dy = (p[1] - y) * this.ky;
|
|
247
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Returns an object of the form {point, index, t}, where point is closest point on the line
|
|
251
|
-
* from the given point, index is the start index of the segment with the closest point,
|
|
252
|
-
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
|
|
253
|
-
*
|
|
254
|
-
* @param {[number, number][]} line
|
|
255
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
256
|
-
* @returns {{point: [number, number], index: number, t: number}} {point, index, t}
|
|
257
|
-
* @example
|
|
258
|
-
* const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
|
|
259
|
-
* //=point
|
|
260
|
-
*/
|
|
261
|
-
pointOnLine(line, p) {
|
|
262
|
-
let minDist = Infinity;
|
|
263
|
-
let minX = line[0][0];
|
|
264
|
-
let minY = line[0][1];
|
|
265
|
-
let minI = 0;
|
|
266
|
-
let minT = 0;
|
|
267
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
268
|
-
let x = line[i][0];
|
|
269
|
-
let y = line[i][1];
|
|
270
|
-
let dx = wrap(line[i + 1][0] - x) * this.kx;
|
|
271
|
-
let dy = (line[i + 1][1] - y) * this.ky;
|
|
272
|
-
let t = 0;
|
|
273
|
-
if (dx !== 0 || dy !== 0) {
|
|
274
|
-
t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
275
|
-
if (t > 1) {
|
|
276
|
-
x = line[i + 1][0];
|
|
277
|
-
y = line[i + 1][1];
|
|
278
|
-
} else if (t > 0) {
|
|
279
|
-
x += dx / this.kx * t;
|
|
280
|
-
y += dy / this.ky * t;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
dx = wrap(p[0] - x) * this.kx;
|
|
284
|
-
dy = (p[1] - y) * this.ky;
|
|
285
|
-
const sqDist = dx * dx + dy * dy;
|
|
286
|
-
if (sqDist < minDist) {
|
|
287
|
-
minDist = sqDist;
|
|
288
|
-
minX = x;
|
|
289
|
-
minY = y;
|
|
290
|
-
minI = i;
|
|
291
|
-
minT = t;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return {
|
|
295
|
-
point: [minX, minY],
|
|
296
|
-
index: minI,
|
|
297
|
-
t: Math.max(0, Math.min(1, minT))
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Returns a part of the given line between the start and the stop points (or their closest points on the line).
|
|
302
|
-
*
|
|
303
|
-
* @param {[number, number]} start point [longitude, latitude]
|
|
304
|
-
* @param {[number, number]} stop point [longitude, latitude]
|
|
305
|
-
* @param {[number, number][]} line
|
|
306
|
-
* @returns {[number, number][]} line part of a line
|
|
307
|
-
* @example
|
|
308
|
-
* const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
|
|
309
|
-
* //=line2
|
|
310
|
-
*/
|
|
311
|
-
lineSlice(start, stop, line) {
|
|
312
|
-
let p1 = this.pointOnLine(line, start);
|
|
313
|
-
let p2 = this.pointOnLine(line, stop);
|
|
314
|
-
if (p1.index > p2.index || p1.index === p2.index && p1.t > p2.t) {
|
|
315
|
-
const tmp = p1;
|
|
316
|
-
p1 = p2;
|
|
317
|
-
p2 = tmp;
|
|
318
|
-
}
|
|
319
|
-
const slice = [p1.point];
|
|
320
|
-
const l = p1.index + 1;
|
|
321
|
-
const r = p2.index;
|
|
322
|
-
if (!equals(line[l], slice[0]) && l <= r)
|
|
323
|
-
slice.push(line[l]);
|
|
324
|
-
for (let i = l + 1; i <= r; i++) {
|
|
325
|
-
slice.push(line[i]);
|
|
326
|
-
}
|
|
327
|
-
if (!equals(line[r], p2.point))
|
|
328
|
-
slice.push(p2.point);
|
|
329
|
-
return slice;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
|
|
333
|
-
*
|
|
334
|
-
* @param {number} start start distance
|
|
335
|
-
* @param {number} stop stop distance
|
|
336
|
-
* @param {[number, number][]} line
|
|
337
|
-
* @returns {[number, number][]} part of a line
|
|
338
|
-
* @example
|
|
339
|
-
* const line2 = ruler.lineSliceAlong(10, 20, line1);
|
|
340
|
-
* //=line2
|
|
341
|
-
*/
|
|
342
|
-
lineSliceAlong(start, stop, line) {
|
|
343
|
-
let sum = 0;
|
|
344
|
-
const slice = [];
|
|
345
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
346
|
-
const p0 = line[i];
|
|
347
|
-
const p1 = line[i + 1];
|
|
348
|
-
const d = this.distance(p0, p1);
|
|
349
|
-
sum += d;
|
|
350
|
-
if (sum > start && slice.length === 0) {
|
|
351
|
-
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
|
|
352
|
-
}
|
|
353
|
-
if (sum >= stop) {
|
|
354
|
-
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
|
|
355
|
-
return slice;
|
|
356
|
-
}
|
|
357
|
-
if (sum > start) slice.push(p1);
|
|
358
|
-
}
|
|
359
|
-
return slice;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
|
|
363
|
-
*
|
|
364
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
365
|
-
* @param {number} buffer
|
|
366
|
-
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
367
|
-
* @example
|
|
368
|
-
* const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
|
|
369
|
-
* //=bbox
|
|
370
|
-
*/
|
|
371
|
-
bufferPoint(p, buffer) {
|
|
372
|
-
const v = buffer / this.ky;
|
|
373
|
-
const h = buffer / this.kx;
|
|
374
|
-
return [
|
|
375
|
-
p[0] - h,
|
|
376
|
-
p[1] - v,
|
|
377
|
-
p[0] + h,
|
|
378
|
-
p[1] + v
|
|
379
|
-
];
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Given a bounding box, returns the box buffered by a given distance.
|
|
383
|
-
*
|
|
384
|
-
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
385
|
-
* @param {number} buffer
|
|
386
|
-
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
387
|
-
* @example
|
|
388
|
-
* const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
|
|
389
|
-
* //=bbox
|
|
390
|
-
*/
|
|
391
|
-
bufferBBox(bbox, buffer) {
|
|
392
|
-
const v = buffer / this.ky;
|
|
393
|
-
const h = buffer / this.kx;
|
|
394
|
-
return [
|
|
395
|
-
bbox[0] - h,
|
|
396
|
-
bbox[1] - v,
|
|
397
|
-
bbox[2] + h,
|
|
398
|
-
bbox[3] + v
|
|
399
|
-
];
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Returns true if the given point is inside in the given bounding box, otherwise false.
|
|
403
|
-
*
|
|
404
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
405
|
-
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
406
|
-
* @returns {boolean}
|
|
407
|
-
* @example
|
|
408
|
-
* const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
|
|
409
|
-
* //=inside
|
|
410
|
-
*/
|
|
411
|
-
insideBBox(p, bbox) {
|
|
412
|
-
return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
function equals(a, b) {
|
|
416
|
-
return a[0] === b[0] && a[1] === b[1];
|
|
417
|
-
}
|
|
418
|
-
function interpolate(a, b, t) {
|
|
419
|
-
const dx = wrap(b[0] - a[0]);
|
|
420
|
-
const dy = b[1] - a[1];
|
|
421
|
-
return [
|
|
422
|
-
a[0] + dx * t,
|
|
423
|
-
a[1] + dy * t
|
|
424
|
-
];
|
|
425
|
-
}
|
|
426
|
-
function wrap(deg) {
|
|
427
|
-
while (deg < -180) deg += 360;
|
|
428
|
-
while (deg > 180) deg -= 360;
|
|
429
|
-
return deg;
|
|
430
|
-
}
|
|
431
|
-
var es = {};
|
|
432
|
-
var computeDestinationPoint$1 = {};
|
|
433
|
-
var getLatitude$1 = {};
|
|
434
|
-
var constants = {};
|
|
435
|
-
Object.defineProperty(constants, "__esModule", { value: true });
|
|
436
|
-
constants.areaConversion = constants.timeConversion = constants.distanceConversion = constants.altitudeKeys = constants.latitudeKeys = constants.longitudeKeys = constants.MAXLON = constants.MINLON = constants.MAXLAT = constants.MINLAT = constants.earthRadius = constants.sexagesimalPattern = void 0;
|
|
437
|
-
var sexagesimalPattern = /^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}(\.([0-9]{1,}))?)["″]\s*)?([NEOSW]?)$/;
|
|
438
|
-
constants.sexagesimalPattern = sexagesimalPattern;
|
|
439
|
-
var earthRadius = 6378137;
|
|
440
|
-
constants.earthRadius = earthRadius;
|
|
441
|
-
var MINLAT = -90;
|
|
442
|
-
constants.MINLAT = MINLAT;
|
|
443
|
-
var MAXLAT = 90;
|
|
444
|
-
constants.MAXLAT = MAXLAT;
|
|
445
|
-
var MINLON = -180;
|
|
446
|
-
constants.MINLON = MINLON;
|
|
447
|
-
var MAXLON = 180;
|
|
448
|
-
constants.MAXLON = MAXLON;
|
|
449
|
-
var longitudeKeys = ["lng", "lon", "longitude", 0];
|
|
450
|
-
constants.longitudeKeys = longitudeKeys;
|
|
451
|
-
var latitudeKeys = ["lat", "latitude", 1];
|
|
452
|
-
constants.latitudeKeys = latitudeKeys;
|
|
453
|
-
var altitudeKeys = ["alt", "altitude", "elevation", "elev", 2];
|
|
454
|
-
constants.altitudeKeys = altitudeKeys;
|
|
455
|
-
var distanceConversion = { m: 1, km: 1e-3, cm: 100, mm: 1e3, mi: 1 / 1609.344, sm: 1 / 1852.216, ft: 100 / 30.48, in: 100 / 2.54, yd: 1 / 0.9144 };
|
|
456
|
-
constants.distanceConversion = distanceConversion;
|
|
457
|
-
var timeConversion = { m: 60, h: 3600, d: 86400 };
|
|
458
|
-
constants.timeConversion = timeConversion;
|
|
459
|
-
var areaConversion = { m2: 1, km2: 1e-6, ha: 1e-4, a: 0.01, ft2: 10.763911, yd2: 1.19599, in2: 1550.0031 };
|
|
460
|
-
constants.areaConversion = areaConversion;
|
|
461
|
-
areaConversion.sqm = areaConversion.m2;
|
|
462
|
-
areaConversion.sqkm = areaConversion.km2;
|
|
463
|
-
areaConversion.sqft = areaConversion.ft2;
|
|
464
|
-
areaConversion.sqyd = areaConversion.yd2;
|
|
465
|
-
areaConversion.sqin = areaConversion.in2;
|
|
466
|
-
var getCoordinateKey$1 = {};
|
|
467
|
-
Object.defineProperty(getCoordinateKey$1, "__esModule", { value: true });
|
|
468
|
-
getCoordinateKey$1.default = void 0;
|
|
469
|
-
var getCoordinateKey = function getCoordinateKey2(point, keysToLookup) {
|
|
470
|
-
return keysToLookup.reduce(function(foundKey, key) {
|
|
471
|
-
if (typeof point === "undefined" || point === null) {
|
|
472
|
-
throw new Error("'".concat(point, "' is no valid coordinate."));
|
|
473
|
-
}
|
|
474
|
-
if (Object.prototype.hasOwnProperty.call(point, key) && typeof key !== "undefined" && typeof foundKey === "undefined") {
|
|
475
|
-
foundKey = key;
|
|
476
|
-
return key;
|
|
477
|
-
}
|
|
478
|
-
return foundKey;
|
|
479
|
-
}, void 0);
|
|
480
|
-
};
|
|
481
|
-
var _default$D = getCoordinateKey;
|
|
482
|
-
getCoordinateKey$1.default = _default$D;
|
|
483
|
-
var toDecimal$1 = {};
|
|
484
|
-
var isDecimal$1 = {};
|
|
485
|
-
Object.defineProperty(isDecimal$1, "__esModule", { value: true });
|
|
486
|
-
isDecimal$1.default = void 0;
|
|
487
|
-
var isDecimal = function isDecimal2(value) {
|
|
488
|
-
var checkedValue = value.toString().trim();
|
|
489
|
-
if (isNaN(parseFloat(checkedValue))) {
|
|
490
|
-
return false;
|
|
491
|
-
}
|
|
492
|
-
return parseFloat(checkedValue) === Number(checkedValue);
|
|
493
|
-
};
|
|
494
|
-
var _default$C = isDecimal;
|
|
495
|
-
isDecimal$1.default = _default$C;
|
|
496
|
-
var isSexagesimal$1 = {};
|
|
497
|
-
Object.defineProperty(isSexagesimal$1, "__esModule", { value: true });
|
|
498
|
-
isSexagesimal$1.default = void 0;
|
|
499
|
-
var _constants$e = constants;
|
|
500
|
-
var isSexagesimal = function isSexagesimal2(value) {
|
|
501
|
-
return _constants$e.sexagesimalPattern.test(value.toString().trim());
|
|
502
|
-
};
|
|
503
|
-
var _default$B = isSexagesimal;
|
|
504
|
-
isSexagesimal$1.default = _default$B;
|
|
505
|
-
var sexagesimalToDecimal$1 = {};
|
|
506
|
-
Object.defineProperty(sexagesimalToDecimal$1, "__esModule", { value: true });
|
|
507
|
-
sexagesimalToDecimal$1.default = void 0;
|
|
508
|
-
var _constants$d = constants;
|
|
509
|
-
var sexagesimalToDecimal = function sexagesimalToDecimal2(sexagesimal) {
|
|
510
|
-
var data = new RegExp(_constants$d.sexagesimalPattern).exec(sexagesimal.toString().trim());
|
|
511
|
-
if (typeof data === "undefined" || data === null) {
|
|
512
|
-
throw new Error("Given value is not in sexagesimal format");
|
|
513
|
-
}
|
|
514
|
-
var min = Number(data[2]) / 60 || 0;
|
|
515
|
-
var sec = Number(data[4]) / 3600 || 0;
|
|
516
|
-
var decimal = parseFloat(data[1]) + min + sec;
|
|
517
|
-
return ["S", "W"].includes(data[7]) ? -decimal : decimal;
|
|
518
|
-
};
|
|
519
|
-
var _default$A = sexagesimalToDecimal;
|
|
520
|
-
sexagesimalToDecimal$1.default = _default$A;
|
|
521
|
-
var isValidCoordinate$1 = {};
|
|
522
|
-
var getCoordinateKeys$1 = {};
|
|
523
|
-
Object.defineProperty(getCoordinateKeys$1, "__esModule", { value: true });
|
|
524
|
-
getCoordinateKeys$1.default = void 0;
|
|
525
|
-
var _constants$c = constants;
|
|
526
|
-
var _getCoordinateKey$2 = _interopRequireDefault$q(getCoordinateKey$1);
|
|
527
|
-
function _interopRequireDefault$q(obj) {
|
|
528
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
529
|
-
}
|
|
530
|
-
function ownKeys$1(object, enumerableOnly) {
|
|
531
|
-
var keys = Object.keys(object);
|
|
532
|
-
if (Object.getOwnPropertySymbols) {
|
|
533
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
534
|
-
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
535
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
536
|
-
});
|
|
537
|
-
keys.push.apply(keys, symbols);
|
|
538
|
-
}
|
|
539
|
-
return keys;
|
|
540
|
-
}
|
|
541
|
-
function _objectSpread$1(target) {
|
|
542
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
543
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
544
|
-
if (i % 2) {
|
|
545
|
-
ownKeys$1(Object(source), true).forEach(function(key) {
|
|
546
|
-
_defineProperty$1(target, key, source[key]);
|
|
547
|
-
});
|
|
548
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
549
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
550
|
-
} else {
|
|
551
|
-
ownKeys$1(Object(source)).forEach(function(key) {
|
|
552
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
return target;
|
|
557
|
-
}
|
|
558
|
-
function _defineProperty$1(obj, key, value) {
|
|
559
|
-
if (key in obj) {
|
|
560
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
561
|
-
} else {
|
|
562
|
-
obj[key] = value;
|
|
563
|
-
}
|
|
564
|
-
return obj;
|
|
565
|
-
}
|
|
566
|
-
var getCoordinateKeys = function getCoordinateKeys2(point) {
|
|
567
|
-
var keysToLookup = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { longitude: _constants$c.longitudeKeys, latitude: _constants$c.latitudeKeys, altitude: _constants$c.altitudeKeys };
|
|
568
|
-
var longitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.longitude);
|
|
569
|
-
var latitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.latitude);
|
|
570
|
-
var altitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.altitude);
|
|
571
|
-
return _objectSpread$1({ latitude, longitude }, altitude ? { altitude } : {});
|
|
572
|
-
};
|
|
573
|
-
var _default$z = getCoordinateKeys;
|
|
574
|
-
getCoordinateKeys$1.default = _default$z;
|
|
575
|
-
var isValidLatitude$1 = {};
|
|
576
|
-
Object.defineProperty(isValidLatitude$1, "__esModule", { value: true });
|
|
577
|
-
isValidLatitude$1.default = void 0;
|
|
578
|
-
var _isDecimal$2 = _interopRequireDefault$p(isDecimal$1);
|
|
579
|
-
var _isSexagesimal$2 = _interopRequireDefault$p(isSexagesimal$1);
|
|
580
|
-
var _sexagesimalToDecimal$2 = _interopRequireDefault$p(sexagesimalToDecimal$1);
|
|
581
|
-
var _constants$b = constants;
|
|
582
|
-
function _interopRequireDefault$p(obj) {
|
|
583
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
584
|
-
}
|
|
585
|
-
var isValidLatitude = function isValidLatitude2(value) {
|
|
586
|
-
if ((0, _isDecimal$2.default)(value)) {
|
|
587
|
-
if (parseFloat(value) > _constants$b.MAXLAT || value < _constants$b.MINLAT) {
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
return true;
|
|
591
|
-
}
|
|
592
|
-
if ((0, _isSexagesimal$2.default)(value)) {
|
|
593
|
-
return isValidLatitude2((0, _sexagesimalToDecimal$2.default)(value));
|
|
594
|
-
}
|
|
595
|
-
return false;
|
|
596
|
-
};
|
|
597
|
-
var _default$y = isValidLatitude;
|
|
598
|
-
isValidLatitude$1.default = _default$y;
|
|
599
|
-
var isValidLongitude$1 = {};
|
|
600
|
-
Object.defineProperty(isValidLongitude$1, "__esModule", { value: true });
|
|
601
|
-
isValidLongitude$1.default = void 0;
|
|
602
|
-
var _isDecimal$1 = _interopRequireDefault$o(isDecimal$1);
|
|
603
|
-
var _isSexagesimal$1 = _interopRequireDefault$o(isSexagesimal$1);
|
|
604
|
-
var _sexagesimalToDecimal$1 = _interopRequireDefault$o(sexagesimalToDecimal$1);
|
|
605
|
-
var _constants$a = constants;
|
|
606
|
-
function _interopRequireDefault$o(obj) {
|
|
607
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
608
|
-
}
|
|
609
|
-
var isValidLongitude = function isValidLongitude2(value) {
|
|
610
|
-
if ((0, _isDecimal$1.default)(value)) {
|
|
611
|
-
if (parseFloat(value) > _constants$a.MAXLON || value < _constants$a.MINLON) {
|
|
612
|
-
return false;
|
|
613
|
-
}
|
|
614
|
-
return true;
|
|
615
|
-
}
|
|
616
|
-
if ((0, _isSexagesimal$1.default)(value)) {
|
|
617
|
-
return isValidLongitude2((0, _sexagesimalToDecimal$1.default)(value));
|
|
618
|
-
}
|
|
619
|
-
return false;
|
|
620
|
-
};
|
|
621
|
-
var _default$x = isValidLongitude;
|
|
622
|
-
isValidLongitude$1.default = _default$x;
|
|
623
|
-
Object.defineProperty(isValidCoordinate$1, "__esModule", { value: true });
|
|
624
|
-
isValidCoordinate$1.default = void 0;
|
|
625
|
-
var _getCoordinateKeys2 = _interopRequireDefault$n(getCoordinateKeys$1);
|
|
626
|
-
var _isValidLatitude = _interopRequireDefault$n(isValidLatitude$1);
|
|
627
|
-
var _isValidLongitude = _interopRequireDefault$n(isValidLongitude$1);
|
|
628
|
-
function _interopRequireDefault$n(obj) {
|
|
629
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
630
|
-
}
|
|
631
|
-
var isValidCoordinate = function isValidCoordinate2(point) {
|
|
632
|
-
var _getCoordinateKeys3 = (0, _getCoordinateKeys2.default)(point), latitude = _getCoordinateKeys3.latitude, longitude = _getCoordinateKeys3.longitude;
|
|
633
|
-
if (Array.isArray(point) && point.length >= 2) {
|
|
634
|
-
return (0, _isValidLongitude.default)(point[0]) && (0, _isValidLatitude.default)(point[1]);
|
|
635
|
-
}
|
|
636
|
-
if (typeof latitude === "undefined" || typeof longitude === "undefined") {
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
var lon = point[longitude];
|
|
640
|
-
var lat = point[latitude];
|
|
641
|
-
if (typeof lat === "undefined" || typeof lon === "undefined") {
|
|
642
|
-
return false;
|
|
643
|
-
}
|
|
644
|
-
if ((0, _isValidLatitude.default)(lat) === false || (0, _isValidLongitude.default)(lon) === false) {
|
|
645
|
-
return false;
|
|
646
|
-
}
|
|
647
|
-
return true;
|
|
648
|
-
};
|
|
649
|
-
var _default$w = isValidCoordinate;
|
|
650
|
-
isValidCoordinate$1.default = _default$w;
|
|
651
|
-
Object.defineProperty(toDecimal$1, "__esModule", { value: true });
|
|
652
|
-
toDecimal$1.default = void 0;
|
|
653
|
-
var _isDecimal = _interopRequireDefault$m(isDecimal$1);
|
|
654
|
-
var _isSexagesimal = _interopRequireDefault$m(isSexagesimal$1);
|
|
655
|
-
var _sexagesimalToDecimal = _interopRequireDefault$m(sexagesimalToDecimal$1);
|
|
656
|
-
var _isValidCoordinate = _interopRequireDefault$m(isValidCoordinate$1);
|
|
657
|
-
var _getCoordinateKeys = _interopRequireDefault$m(getCoordinateKeys$1);
|
|
658
|
-
function _interopRequireDefault$m(obj) {
|
|
659
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
660
|
-
}
|
|
661
|
-
function ownKeys(object, enumerableOnly) {
|
|
662
|
-
var keys = Object.keys(object);
|
|
663
|
-
if (Object.getOwnPropertySymbols) {
|
|
664
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
665
|
-
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
666
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
667
|
-
});
|
|
668
|
-
keys.push.apply(keys, symbols);
|
|
669
|
-
}
|
|
670
|
-
return keys;
|
|
671
|
-
}
|
|
672
|
-
function _objectSpread(target) {
|
|
673
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
674
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
675
|
-
if (i % 2) {
|
|
676
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
677
|
-
_defineProperty(target, key, source[key]);
|
|
678
|
-
});
|
|
679
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
680
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
681
|
-
} else {
|
|
682
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
683
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return target;
|
|
688
|
-
}
|
|
689
|
-
function _defineProperty(obj, key, value) {
|
|
690
|
-
if (key in obj) {
|
|
691
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
692
|
-
} else {
|
|
693
|
-
obj[key] = value;
|
|
694
|
-
}
|
|
695
|
-
return obj;
|
|
696
|
-
}
|
|
697
|
-
var toDecimal = function toDecimal2(value) {
|
|
698
|
-
if ((0, _isDecimal.default)(value)) {
|
|
699
|
-
return Number(value);
|
|
700
|
-
}
|
|
701
|
-
if ((0, _isSexagesimal.default)(value)) {
|
|
702
|
-
return (0, _sexagesimalToDecimal.default)(value);
|
|
703
|
-
}
|
|
704
|
-
if ((0, _isValidCoordinate.default)(value)) {
|
|
705
|
-
var keys = (0, _getCoordinateKeys.default)(value);
|
|
706
|
-
if (Array.isArray(value)) {
|
|
707
|
-
return value.map(function(v, index) {
|
|
708
|
-
return [0, 1].includes(index) ? toDecimal2(v) : v;
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
return _objectSpread(_objectSpread(_objectSpread({}, value), keys.latitude && _defineProperty({}, keys.latitude, toDecimal2(value[keys.latitude]))), keys.longitude && _defineProperty({}, keys.longitude, toDecimal2(value[keys.longitude])));
|
|
712
|
-
}
|
|
713
|
-
if (Array.isArray(value)) {
|
|
714
|
-
return value.map(function(point) {
|
|
715
|
-
return (0, _isValidCoordinate.default)(point) ? toDecimal2(point) : point;
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
return value;
|
|
719
|
-
};
|
|
720
|
-
var _default$v = toDecimal;
|
|
721
|
-
toDecimal$1.default = _default$v;
|
|
722
|
-
Object.defineProperty(getLatitude$1, "__esModule", { value: true });
|
|
723
|
-
getLatitude$1.default = void 0;
|
|
724
|
-
var _constants$9 = constants;
|
|
725
|
-
var _getCoordinateKey$1 = _interopRequireDefault$l(getCoordinateKey$1);
|
|
726
|
-
var _toDecimal$1 = _interopRequireDefault$l(toDecimal$1);
|
|
727
|
-
function _interopRequireDefault$l(obj) {
|
|
728
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
729
|
-
}
|
|
730
|
-
var getLatitude = function getLatitude2(point, raw) {
|
|
731
|
-
var latKey = (0, _getCoordinateKey$1.default)(point, _constants$9.latitudeKeys);
|
|
732
|
-
if (typeof latKey === "undefined" || latKey === null) {
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
var value = point[latKey];
|
|
736
|
-
return raw === true ? value : (0, _toDecimal$1.default)(value);
|
|
737
|
-
};
|
|
738
|
-
var _default$u = getLatitude;
|
|
739
|
-
getLatitude$1.default = _default$u;
|
|
740
|
-
var getLongitude$1 = {};
|
|
741
|
-
Object.defineProperty(getLongitude$1, "__esModule", { value: true });
|
|
742
|
-
getLongitude$1.default = void 0;
|
|
743
|
-
var _constants$8 = constants;
|
|
744
|
-
var _getCoordinateKey = _interopRequireDefault$k(getCoordinateKey$1);
|
|
745
|
-
var _toDecimal = _interopRequireDefault$k(toDecimal$1);
|
|
746
|
-
function _interopRequireDefault$k(obj) {
|
|
747
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
748
|
-
}
|
|
749
|
-
var getLongitude = function getLongitude2(point, raw) {
|
|
750
|
-
var latKey = (0, _getCoordinateKey.default)(point, _constants$8.longitudeKeys);
|
|
751
|
-
if (typeof latKey === "undefined" || latKey === null) {
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
var value = point[latKey];
|
|
755
|
-
return raw === true ? value : (0, _toDecimal.default)(value);
|
|
756
|
-
};
|
|
757
|
-
var _default$t = getLongitude;
|
|
758
|
-
getLongitude$1.default = _default$t;
|
|
759
|
-
var toRad$1 = {};
|
|
760
|
-
Object.defineProperty(toRad$1, "__esModule", { value: true });
|
|
761
|
-
toRad$1.default = void 0;
|
|
762
|
-
var toRad = function toRad2(value) {
|
|
763
|
-
return value * Math.PI / 180;
|
|
764
|
-
};
|
|
765
|
-
var _default$s = toRad;
|
|
766
|
-
toRad$1.default = _default$s;
|
|
767
|
-
var toDeg$1 = {};
|
|
768
|
-
Object.defineProperty(toDeg$1, "__esModule", { value: true });
|
|
769
|
-
toDeg$1.default = void 0;
|
|
770
|
-
var toDeg = function toDeg2(value) {
|
|
771
|
-
return value * 180 / Math.PI;
|
|
772
|
-
};
|
|
773
|
-
var _default$r = toDeg;
|
|
774
|
-
toDeg$1.default = _default$r;
|
|
775
|
-
Object.defineProperty(computeDestinationPoint$1, "__esModule", { value: true });
|
|
776
|
-
computeDestinationPoint$1.default = void 0;
|
|
777
|
-
var _getLatitude$9 = _interopRequireDefault$j(getLatitude$1);
|
|
778
|
-
var _getLongitude$9 = _interopRequireDefault$j(getLongitude$1);
|
|
779
|
-
var _toRad$7 = _interopRequireDefault$j(toRad$1);
|
|
780
|
-
var _toDeg$4 = _interopRequireDefault$j(toDeg$1);
|
|
781
|
-
var _constants$7 = constants;
|
|
782
|
-
function _interopRequireDefault$j(obj) {
|
|
783
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
784
|
-
}
|
|
785
|
-
var computeDestinationPoint = function computeDestinationPoint2(start, distance, bearing) {
|
|
786
|
-
var radius = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 6371e3;
|
|
787
|
-
var lat = (0, _getLatitude$9.default)(start);
|
|
788
|
-
var lng = (0, _getLongitude$9.default)(start);
|
|
789
|
-
var delta = distance / radius;
|
|
790
|
-
var theta = (0, _toRad$7.default)(bearing);
|
|
791
|
-
var phi1 = (0, _toRad$7.default)(lat);
|
|
792
|
-
var lambda1 = (0, _toRad$7.default)(lng);
|
|
793
|
-
var phi2 = Math.asin(Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta));
|
|
794
|
-
var lambda2 = lambda1 + Math.atan2(Math.sin(theta) * Math.sin(delta) * Math.cos(phi1), Math.cos(delta) - Math.sin(phi1) * Math.sin(phi2));
|
|
795
|
-
var longitude = (0, _toDeg$4.default)(lambda2);
|
|
796
|
-
if (longitude < _constants$7.MINLON || longitude > _constants$7.MAXLON) {
|
|
797
|
-
lambda2 = (lambda2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
|
|
798
|
-
longitude = (0, _toDeg$4.default)(lambda2);
|
|
799
|
-
}
|
|
800
|
-
return { latitude: (0, _toDeg$4.default)(phi2), longitude };
|
|
801
|
-
};
|
|
802
|
-
var _default$q = computeDestinationPoint;
|
|
803
|
-
computeDestinationPoint$1.default = _default$q;
|
|
804
|
-
var convertArea$1 = {};
|
|
805
|
-
Object.defineProperty(convertArea$1, "__esModule", { value: true });
|
|
806
|
-
convertArea$1.default = void 0;
|
|
807
|
-
var _constants$6 = constants;
|
|
808
|
-
var convertArea = function convertArea2(squareMeters) {
|
|
809
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
810
|
-
var factor = _constants$6.areaConversion[targetUnit];
|
|
811
|
-
if (factor) {
|
|
812
|
-
return squareMeters * factor;
|
|
813
|
-
}
|
|
814
|
-
throw new Error("Invalid unit used for area conversion.");
|
|
815
|
-
};
|
|
816
|
-
var _default$p = convertArea;
|
|
817
|
-
convertArea$1.default = _default$p;
|
|
818
|
-
var convertDistance$1 = {};
|
|
819
|
-
Object.defineProperty(convertDistance$1, "__esModule", { value: true });
|
|
820
|
-
convertDistance$1.default = void 0;
|
|
821
|
-
var _constants$5 = constants;
|
|
822
|
-
var convertDistance = function convertDistance2(meters) {
|
|
823
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
824
|
-
var factor = _constants$5.distanceConversion[targetUnit];
|
|
825
|
-
if (factor) {
|
|
826
|
-
return meters * factor;
|
|
827
|
-
}
|
|
828
|
-
throw new Error("Invalid unit used for distance conversion.");
|
|
829
|
-
};
|
|
830
|
-
var _default$o = convertDistance;
|
|
831
|
-
convertDistance$1.default = _default$o;
|
|
832
|
-
var convertSpeed$1 = {};
|
|
833
|
-
Object.defineProperty(convertSpeed$1, "__esModule", { value: true });
|
|
834
|
-
convertSpeed$1.default = void 0;
|
|
835
|
-
var _constants$4 = constants;
|
|
836
|
-
var convertSpeed = function convertSpeed2(metersPerSecond) {
|
|
837
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "kmh";
|
|
838
|
-
switch (targetUnit) {
|
|
839
|
-
case "kmh":
|
|
840
|
-
return metersPerSecond * _constants$4.timeConversion.h * _constants$4.distanceConversion.km;
|
|
841
|
-
case "mph":
|
|
842
|
-
return metersPerSecond * _constants$4.timeConversion.h * _constants$4.distanceConversion.mi;
|
|
843
|
-
default:
|
|
844
|
-
return metersPerSecond;
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
var _default$n = convertSpeed;
|
|
848
|
-
convertSpeed$1.default = _default$n;
|
|
849
|
-
var decimalToSexagesimal = {};
|
|
850
|
-
Object.defineProperty(decimalToSexagesimal, "__esModule", { value: true });
|
|
851
|
-
decimalToSexagesimal.default = void 0;
|
|
852
|
-
function _slicedToArray$1(arr, i) {
|
|
853
|
-
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
854
|
-
}
|
|
855
|
-
function _nonIterableRest$1() {
|
|
856
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
857
|
-
}
|
|
858
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
859
|
-
if (!o) return;
|
|
860
|
-
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
861
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
862
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
863
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
864
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
865
|
-
}
|
|
866
|
-
function _arrayLikeToArray$1(arr, len) {
|
|
867
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
868
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
869
|
-
arr2[i] = arr[i];
|
|
870
|
-
}
|
|
871
|
-
return arr2;
|
|
872
|
-
}
|
|
873
|
-
function _iterableToArrayLimit$1(arr, i) {
|
|
874
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
875
|
-
var _arr = [];
|
|
876
|
-
var _n = true;
|
|
877
|
-
var _d = false;
|
|
878
|
-
var _e = void 0;
|
|
879
|
-
try {
|
|
880
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
881
|
-
_arr.push(_s.value);
|
|
882
|
-
if (i && _arr.length === i) break;
|
|
883
|
-
}
|
|
884
|
-
} catch (err) {
|
|
885
|
-
_d = true;
|
|
886
|
-
_e = err;
|
|
887
|
-
} finally {
|
|
888
|
-
try {
|
|
889
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
890
|
-
} finally {
|
|
891
|
-
if (_d) throw _e;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
return _arr;
|
|
895
|
-
}
|
|
896
|
-
function _arrayWithHoles$1(arr) {
|
|
897
|
-
if (Array.isArray(arr)) return arr;
|
|
898
|
-
}
|
|
899
|
-
var imprecise = function imprecise2(number) {
|
|
900
|
-
var decimals = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
901
|
-
var factor = Math.pow(10, decimals);
|
|
902
|
-
return Math.round(number * factor) / factor;
|
|
903
|
-
};
|
|
904
|
-
var decimal2sexagesimalNext = function decimal2sexagesimalNext2(decimal) {
|
|
905
|
-
var _decimal$toString$spl = decimal.toString().split("."), _decimal$toString$spl2 = _slicedToArray$1(_decimal$toString$spl, 2), pre = _decimal$toString$spl2[0], post = _decimal$toString$spl2[1];
|
|
906
|
-
var deg = Math.abs(Number(pre));
|
|
907
|
-
var min0 = Number("0." + (post || 0)) * 60;
|
|
908
|
-
var sec0 = min0.toString().split(".");
|
|
909
|
-
var min = Math.floor(min0);
|
|
910
|
-
var sec = imprecise(Number("0." + (sec0[1] || 0)) * 60).toString();
|
|
911
|
-
var _sec$split = sec.split("."), _sec$split2 = _slicedToArray$1(_sec$split, 2), secPreDec = _sec$split2[0], _sec$split2$ = _sec$split2[1], secDec = _sec$split2$ === void 0 ? "0" : _sec$split2$;
|
|
912
|
-
return deg + "° " + min.toString().padStart(2, "0") + "' " + secPreDec.padStart(2, "0") + "." + secDec.padEnd(1, "0") + '"';
|
|
913
|
-
};
|
|
914
|
-
var _default$m = decimal2sexagesimalNext;
|
|
915
|
-
decimalToSexagesimal.default = _default$m;
|
|
916
|
-
var findNearest$1 = {};
|
|
917
|
-
var orderByDistance$1 = {};
|
|
918
|
-
var getDistance$2 = {};
|
|
919
|
-
var robustAcos$1 = {};
|
|
920
|
-
Object.defineProperty(robustAcos$1, "__esModule", { value: true });
|
|
921
|
-
robustAcos$1.default = void 0;
|
|
922
|
-
var robustAcos = function robustAcos2(value) {
|
|
923
|
-
if (value > 1) {
|
|
924
|
-
return 1;
|
|
925
|
-
}
|
|
926
|
-
if (value < -1) {
|
|
927
|
-
return -1;
|
|
928
|
-
}
|
|
929
|
-
return value;
|
|
930
|
-
};
|
|
931
|
-
var _default$l = robustAcos;
|
|
932
|
-
robustAcos$1.default = _default$l;
|
|
933
|
-
Object.defineProperty(getDistance$2, "__esModule", { value: true });
|
|
934
|
-
getDistance$2.default = void 0;
|
|
935
|
-
var _getLatitude$8 = _interopRequireDefault$i(getLatitude$1);
|
|
936
|
-
var _getLongitude$8 = _interopRequireDefault$i(getLongitude$1);
|
|
937
|
-
var _toRad$6 = _interopRequireDefault$i(toRad$1);
|
|
938
|
-
var _robustAcos$1 = _interopRequireDefault$i(robustAcos$1);
|
|
939
|
-
var _constants$3 = constants;
|
|
940
|
-
function _interopRequireDefault$i(obj) {
|
|
941
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
942
|
-
}
|
|
943
|
-
var getDistance$1 = function getDistance(from, to) {
|
|
944
|
-
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
945
|
-
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
946
|
-
var fromLat = (0, _getLatitude$8.default)(from);
|
|
947
|
-
var fromLon = (0, _getLongitude$8.default)(from);
|
|
948
|
-
var toLat = (0, _getLatitude$8.default)(to);
|
|
949
|
-
var toLon = (0, _getLongitude$8.default)(to);
|
|
950
|
-
var distance = Math.acos((0, _robustAcos$1.default)(Math.sin((0, _toRad$6.default)(toLat)) * Math.sin((0, _toRad$6.default)(fromLat)) + Math.cos((0, _toRad$6.default)(toLat)) * Math.cos((0, _toRad$6.default)(fromLat)) * Math.cos((0, _toRad$6.default)(fromLon) - (0, _toRad$6.default)(toLon)))) * _constants$3.earthRadius;
|
|
951
|
-
return Math.round(distance / accuracy) * accuracy;
|
|
952
|
-
};
|
|
953
|
-
var _default$k = getDistance$1;
|
|
954
|
-
getDistance$2.default = _default$k;
|
|
955
|
-
Object.defineProperty(orderByDistance$1, "__esModule", { value: true });
|
|
956
|
-
orderByDistance$1.default = void 0;
|
|
957
|
-
var _getDistance$5 = _interopRequireDefault$h(getDistance$2);
|
|
958
|
-
function _interopRequireDefault$h(obj) {
|
|
959
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
960
|
-
}
|
|
961
|
-
var orderByDistance = function orderByDistance2(point, coords) {
|
|
962
|
-
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance$5.default;
|
|
963
|
-
distanceFn = typeof distanceFn === "function" ? distanceFn : _getDistance$5.default;
|
|
964
|
-
return coords.slice().sort(function(a, b) {
|
|
965
|
-
return distanceFn(point, a) - distanceFn(point, b);
|
|
966
|
-
});
|
|
967
|
-
};
|
|
968
|
-
var _default$j = orderByDistance;
|
|
969
|
-
orderByDistance$1.default = _default$j;
|
|
970
|
-
Object.defineProperty(findNearest$1, "__esModule", { value: true });
|
|
971
|
-
findNearest$1.default = void 0;
|
|
972
|
-
var _orderByDistance = _interopRequireDefault$g(orderByDistance$1);
|
|
973
|
-
function _interopRequireDefault$g(obj) {
|
|
974
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
975
|
-
}
|
|
976
|
-
var findNearest = function findNearest2(point, coords) {
|
|
977
|
-
return (0, _orderByDistance.default)(point, coords)[0];
|
|
978
|
-
};
|
|
979
|
-
var _default$i = findNearest;
|
|
980
|
-
findNearest$1.default = _default$i;
|
|
981
|
-
var getAreaOfPolygon$1 = {};
|
|
982
|
-
Object.defineProperty(getAreaOfPolygon$1, "__esModule", { value: true });
|
|
983
|
-
getAreaOfPolygon$1.default = void 0;
|
|
984
|
-
var _toRad$5 = _interopRequireDefault$f(toRad$1);
|
|
985
|
-
var _getLatitude$7 = _interopRequireDefault$f(getLatitude$1);
|
|
986
|
-
var _getLongitude$7 = _interopRequireDefault$f(getLongitude$1);
|
|
987
|
-
var _constants$2 = constants;
|
|
988
|
-
function _interopRequireDefault$f(obj) {
|
|
989
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
990
|
-
}
|
|
991
|
-
var getAreaOfPolygon = function getAreaOfPolygon2(points) {
|
|
992
|
-
var area = 0;
|
|
993
|
-
if (points.length > 2) {
|
|
994
|
-
var lowerIndex;
|
|
995
|
-
var middleIndex;
|
|
996
|
-
var upperIndex;
|
|
997
|
-
for (var i = 0; i < points.length; i++) {
|
|
998
|
-
if (i === points.length - 2) {
|
|
999
|
-
lowerIndex = points.length - 2;
|
|
1000
|
-
middleIndex = points.length - 1;
|
|
1001
|
-
upperIndex = 0;
|
|
1002
|
-
} else if (i === points.length - 1) {
|
|
1003
|
-
lowerIndex = points.length - 1;
|
|
1004
|
-
middleIndex = 0;
|
|
1005
|
-
upperIndex = 1;
|
|
1006
|
-
} else {
|
|
1007
|
-
lowerIndex = i;
|
|
1008
|
-
middleIndex = i + 1;
|
|
1009
|
-
upperIndex = i + 2;
|
|
1010
|
-
}
|
|
1011
|
-
var p1lon = (0, _getLongitude$7.default)(points[lowerIndex]);
|
|
1012
|
-
var p2lat = (0, _getLatitude$7.default)(points[middleIndex]);
|
|
1013
|
-
var p3lon = (0, _getLongitude$7.default)(points[upperIndex]);
|
|
1014
|
-
area += ((0, _toRad$5.default)(p3lon) - (0, _toRad$5.default)(p1lon)) * Math.sin((0, _toRad$5.default)(p2lat));
|
|
1015
|
-
}
|
|
1016
|
-
area = area * _constants$2.earthRadius * _constants$2.earthRadius / 2;
|
|
1017
|
-
}
|
|
1018
|
-
return Math.abs(area);
|
|
1019
|
-
};
|
|
1020
|
-
var _default$h = getAreaOfPolygon;
|
|
1021
|
-
getAreaOfPolygon$1.default = _default$h;
|
|
1022
|
-
var getBounds$1 = {};
|
|
1023
|
-
Object.defineProperty(getBounds$1, "__esModule", { value: true });
|
|
1024
|
-
getBounds$1.default = void 0;
|
|
1025
|
-
var _getLatitude$6 = _interopRequireDefault$e(getLatitude$1);
|
|
1026
|
-
var _getLongitude$6 = _interopRequireDefault$e(getLongitude$1);
|
|
1027
|
-
function _interopRequireDefault$e(obj) {
|
|
1028
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1029
|
-
}
|
|
1030
|
-
var getBounds = function getBounds2(points) {
|
|
1031
|
-
if (Array.isArray(points) === false || points.length === 0) {
|
|
1032
|
-
throw new Error("No points were given.");
|
|
1033
|
-
}
|
|
1034
|
-
return points.reduce(function(stats, point) {
|
|
1035
|
-
var latitude = (0, _getLatitude$6.default)(point);
|
|
1036
|
-
var longitude = (0, _getLongitude$6.default)(point);
|
|
1037
|
-
return { maxLat: Math.max(latitude, stats.maxLat), minLat: Math.min(latitude, stats.minLat), maxLng: Math.max(longitude, stats.maxLng), minLng: Math.min(longitude, stats.minLng) };
|
|
1038
|
-
}, { maxLat: -Infinity, minLat: Infinity, maxLng: -Infinity, minLng: Infinity });
|
|
1039
|
-
};
|
|
1040
|
-
var _default$g = getBounds;
|
|
1041
|
-
getBounds$1.default = _default$g;
|
|
1042
|
-
var getBoundsOfDistance$1 = {};
|
|
1043
|
-
Object.defineProperty(getBoundsOfDistance$1, "__esModule", { value: true });
|
|
1044
|
-
getBoundsOfDistance$1.default = void 0;
|
|
1045
|
-
var _getLatitude$5 = _interopRequireDefault$d(getLatitude$1);
|
|
1046
|
-
var _getLongitude$5 = _interopRequireDefault$d(getLongitude$1);
|
|
1047
|
-
var _toRad$4 = _interopRequireDefault$d(toRad$1);
|
|
1048
|
-
var _toDeg$3 = _interopRequireDefault$d(toDeg$1);
|
|
1049
|
-
var _constants$1 = constants;
|
|
1050
|
-
function _interopRequireDefault$d(obj) {
|
|
1051
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1052
|
-
}
|
|
1053
|
-
var getBoundsOfDistance = function getBoundsOfDistance2(point, distance) {
|
|
1054
|
-
var latitude = (0, _getLatitude$5.default)(point);
|
|
1055
|
-
var longitude = (0, _getLongitude$5.default)(point);
|
|
1056
|
-
var radLat = (0, _toRad$4.default)(latitude);
|
|
1057
|
-
var radLon = (0, _toRad$4.default)(longitude);
|
|
1058
|
-
var radDist = distance / _constants$1.earthRadius;
|
|
1059
|
-
var minLat = radLat - radDist;
|
|
1060
|
-
var maxLat = radLat + radDist;
|
|
1061
|
-
var MAX_LAT_RAD = (0, _toRad$4.default)(_constants$1.MAXLAT);
|
|
1062
|
-
var MIN_LAT_RAD = (0, _toRad$4.default)(_constants$1.MINLAT);
|
|
1063
|
-
var MAX_LON_RAD = (0, _toRad$4.default)(_constants$1.MAXLON);
|
|
1064
|
-
var MIN_LON_RAD = (0, _toRad$4.default)(_constants$1.MINLON);
|
|
1065
|
-
var minLon;
|
|
1066
|
-
var maxLon;
|
|
1067
|
-
if (minLat > MIN_LAT_RAD && maxLat < MAX_LAT_RAD) {
|
|
1068
|
-
var deltaLon = Math.asin(Math.sin(radDist) / Math.cos(radLat));
|
|
1069
|
-
minLon = radLon - deltaLon;
|
|
1070
|
-
if (minLon < MIN_LON_RAD) {
|
|
1071
|
-
minLon += Math.PI * 2;
|
|
1072
|
-
}
|
|
1073
|
-
maxLon = radLon + deltaLon;
|
|
1074
|
-
if (maxLon > MAX_LON_RAD) {
|
|
1075
|
-
maxLon -= Math.PI * 2;
|
|
1076
|
-
}
|
|
1077
|
-
} else {
|
|
1078
|
-
minLat = Math.max(minLat, MIN_LAT_RAD);
|
|
1079
|
-
maxLat = Math.min(maxLat, MAX_LAT_RAD);
|
|
1080
|
-
minLon = MIN_LON_RAD;
|
|
1081
|
-
maxLon = MAX_LON_RAD;
|
|
1082
|
-
}
|
|
1083
|
-
return [{ latitude: (0, _toDeg$3.default)(minLat), longitude: (0, _toDeg$3.default)(minLon) }, { latitude: (0, _toDeg$3.default)(maxLat), longitude: (0, _toDeg$3.default)(maxLon) }];
|
|
1084
|
-
};
|
|
1085
|
-
var _default$f = getBoundsOfDistance;
|
|
1086
|
-
getBoundsOfDistance$1.default = _default$f;
|
|
1087
|
-
var getCenter$1 = {};
|
|
1088
|
-
Object.defineProperty(getCenter$1, "__esModule", { value: true });
|
|
1089
|
-
getCenter$1.default = void 0;
|
|
1090
|
-
var _getLatitude$4 = _interopRequireDefault$c(getLatitude$1);
|
|
1091
|
-
var _getLongitude$4 = _interopRequireDefault$c(getLongitude$1);
|
|
1092
|
-
var _toRad$3 = _interopRequireDefault$c(toRad$1);
|
|
1093
|
-
var _toDeg$2 = _interopRequireDefault$c(toDeg$1);
|
|
1094
|
-
function _interopRequireDefault$c(obj) {
|
|
1095
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1096
|
-
}
|
|
1097
|
-
var getCenter = function getCenter2(points) {
|
|
1098
|
-
if (Array.isArray(points) === false || points.length === 0) {
|
|
1099
|
-
return false;
|
|
1100
|
-
}
|
|
1101
|
-
var numberOfPoints = points.length;
|
|
1102
|
-
var sum = points.reduce(function(acc, point) {
|
|
1103
|
-
var pointLat = (0, _toRad$3.default)((0, _getLatitude$4.default)(point));
|
|
1104
|
-
var pointLon = (0, _toRad$3.default)((0, _getLongitude$4.default)(point));
|
|
1105
|
-
return { X: acc.X + Math.cos(pointLat) * Math.cos(pointLon), Y: acc.Y + Math.cos(pointLat) * Math.sin(pointLon), Z: acc.Z + Math.sin(pointLat) };
|
|
1106
|
-
}, { X: 0, Y: 0, Z: 0 });
|
|
1107
|
-
var X = sum.X / numberOfPoints;
|
|
1108
|
-
var Y = sum.Y / numberOfPoints;
|
|
1109
|
-
var Z = sum.Z / numberOfPoints;
|
|
1110
|
-
return { longitude: (0, _toDeg$2.default)(Math.atan2(Y, X)), latitude: (0, _toDeg$2.default)(Math.atan2(Z, Math.sqrt(X * X + Y * Y))) };
|
|
1111
|
-
};
|
|
1112
|
-
var _default$e = getCenter;
|
|
1113
|
-
getCenter$1.default = _default$e;
|
|
1114
|
-
var getCenterOfBounds$1 = {};
|
|
1115
|
-
Object.defineProperty(getCenterOfBounds$1, "__esModule", { value: true });
|
|
1116
|
-
getCenterOfBounds$1.default = void 0;
|
|
1117
|
-
var _getBounds = _interopRequireDefault$b(getBounds$1);
|
|
1118
|
-
function _interopRequireDefault$b(obj) {
|
|
1119
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1120
|
-
}
|
|
1121
|
-
var getCenterOfBounds = function getCenterOfBounds2(coords) {
|
|
1122
|
-
var bounds = (0, _getBounds.default)(coords);
|
|
1123
|
-
var latitude = bounds.minLat + (bounds.maxLat - bounds.minLat) / 2;
|
|
1124
|
-
var longitude = bounds.minLng + (bounds.maxLng - bounds.minLng) / 2;
|
|
1125
|
-
return { latitude: parseFloat(latitude.toFixed(6)), longitude: parseFloat(longitude.toFixed(6)) };
|
|
1126
|
-
};
|
|
1127
|
-
var _default$d = getCenterOfBounds;
|
|
1128
|
-
getCenterOfBounds$1.default = _default$d;
|
|
1129
|
-
var getCompassDirection$1 = {};
|
|
1130
|
-
var getRhumbLineBearing$1 = {};
|
|
1131
|
-
Object.defineProperty(getRhumbLineBearing$1, "__esModule", { value: true });
|
|
1132
|
-
getRhumbLineBearing$1.default = void 0;
|
|
1133
|
-
var _getLatitude$3 = _interopRequireDefault$a(getLatitude$1);
|
|
1134
|
-
var _getLongitude$3 = _interopRequireDefault$a(getLongitude$1);
|
|
1135
|
-
var _toRad$2 = _interopRequireDefault$a(toRad$1);
|
|
1136
|
-
var _toDeg$1 = _interopRequireDefault$a(toDeg$1);
|
|
1137
|
-
function _interopRequireDefault$a(obj) {
|
|
1138
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1139
|
-
}
|
|
1140
|
-
var getRhumbLineBearing = function getRhumbLineBearing2(origin, dest) {
|
|
1141
|
-
var diffLon = (0, _toRad$2.default)((0, _getLongitude$3.default)(dest)) - (0, _toRad$2.default)((0, _getLongitude$3.default)(origin));
|
|
1142
|
-
var diffPhi = Math.log(Math.tan((0, _toRad$2.default)((0, _getLatitude$3.default)(dest)) / 2 + Math.PI / 4) / Math.tan((0, _toRad$2.default)((0, _getLatitude$3.default)(origin)) / 2 + Math.PI / 4));
|
|
1143
|
-
if (Math.abs(diffLon) > Math.PI) {
|
|
1144
|
-
if (diffLon > 0) {
|
|
1145
|
-
diffLon = (Math.PI * 2 - diffLon) * -1;
|
|
1146
|
-
} else {
|
|
1147
|
-
diffLon = Math.PI * 2 + diffLon;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
return ((0, _toDeg$1.default)(Math.atan2(diffLon, diffPhi)) + 360) % 360;
|
|
1151
|
-
};
|
|
1152
|
-
var _default$c = getRhumbLineBearing;
|
|
1153
|
-
getRhumbLineBearing$1.default = _default$c;
|
|
1154
|
-
Object.defineProperty(getCompassDirection$1, "__esModule", { value: true });
|
|
1155
|
-
getCompassDirection$1.default = void 0;
|
|
1156
|
-
var _getRhumbLineBearing = _interopRequireDefault$9(getRhumbLineBearing$1);
|
|
1157
|
-
function _interopRequireDefault$9(obj) {
|
|
1158
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1159
|
-
}
|
|
1160
|
-
var getCompassDirection = function getCompassDirection2(origin, dest) {
|
|
1161
|
-
var bearingFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getRhumbLineBearing.default;
|
|
1162
|
-
var bearing = typeof bearingFn === "function" ? bearingFn(origin, dest) : (0, _getRhumbLineBearing.default)(origin, dest);
|
|
1163
|
-
if (isNaN(bearing)) {
|
|
1164
|
-
throw new Error("Could not calculate bearing for given points. Check your bearing function");
|
|
1165
|
-
}
|
|
1166
|
-
switch (Math.round(bearing / 22.5)) {
|
|
1167
|
-
case 1:
|
|
1168
|
-
return "NNE";
|
|
1169
|
-
case 2:
|
|
1170
|
-
return "NE";
|
|
1171
|
-
case 3:
|
|
1172
|
-
return "ENE";
|
|
1173
|
-
case 4:
|
|
1174
|
-
return "E";
|
|
1175
|
-
case 5:
|
|
1176
|
-
return "ESE";
|
|
1177
|
-
case 6:
|
|
1178
|
-
return "SE";
|
|
1179
|
-
case 7:
|
|
1180
|
-
return "SSE";
|
|
1181
|
-
case 8:
|
|
1182
|
-
return "S";
|
|
1183
|
-
case 9:
|
|
1184
|
-
return "SSW";
|
|
1185
|
-
case 10:
|
|
1186
|
-
return "SW";
|
|
1187
|
-
case 11:
|
|
1188
|
-
return "WSW";
|
|
1189
|
-
case 12:
|
|
1190
|
-
return "W";
|
|
1191
|
-
case 13:
|
|
1192
|
-
return "WNW";
|
|
1193
|
-
case 14:
|
|
1194
|
-
return "NW";
|
|
1195
|
-
case 15:
|
|
1196
|
-
return "NNW";
|
|
1197
|
-
default:
|
|
1198
|
-
return "N";
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
var _default$b = getCompassDirection;
|
|
1202
|
-
getCompassDirection$1.default = _default$b;
|
|
1203
|
-
var getDistanceFromLine$1 = {};
|
|
1204
|
-
Object.defineProperty(getDistanceFromLine$1, "__esModule", { value: true });
|
|
1205
|
-
getDistanceFromLine$1.default = void 0;
|
|
1206
|
-
var _getDistance$4 = _interopRequireDefault$8(getDistance$2);
|
|
1207
|
-
var _robustAcos = _interopRequireDefault$8(robustAcos$1);
|
|
1208
|
-
function _interopRequireDefault$8(obj) {
|
|
1209
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1210
|
-
}
|
|
1211
|
-
var getDistanceFromLine = function getDistanceFromLine2(point, lineStart, lineEnd) {
|
|
1212
|
-
var accuracy = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
|
|
1213
|
-
var d1 = (0, _getDistance$4.default)(lineStart, point, accuracy);
|
|
1214
|
-
var d2 = (0, _getDistance$4.default)(point, lineEnd, accuracy);
|
|
1215
|
-
var d3 = (0, _getDistance$4.default)(lineStart, lineEnd, accuracy);
|
|
1216
|
-
var alpha = Math.acos((0, _robustAcos.default)((d1 * d1 + d3 * d3 - d2 * d2) / (2 * d1 * d3)));
|
|
1217
|
-
var beta = Math.acos((0, _robustAcos.default)((d2 * d2 + d3 * d3 - d1 * d1) / (2 * d2 * d3)));
|
|
1218
|
-
if (alpha > Math.PI / 2) {
|
|
1219
|
-
return d1;
|
|
1220
|
-
}
|
|
1221
|
-
if (beta > Math.PI / 2) {
|
|
1222
|
-
return d2;
|
|
1223
|
-
}
|
|
1224
|
-
return Math.sin(alpha) * d1;
|
|
1225
|
-
};
|
|
1226
|
-
var _default$a = getDistanceFromLine;
|
|
1227
|
-
getDistanceFromLine$1.default = _default$a;
|
|
1228
|
-
var getGreatCircleBearing$1 = {};
|
|
1229
|
-
Object.defineProperty(getGreatCircleBearing$1, "__esModule", { value: true });
|
|
1230
|
-
getGreatCircleBearing$1.default = void 0;
|
|
1231
|
-
var _getLatitude$2 = _interopRequireDefault$7(getLatitude$1);
|
|
1232
|
-
var _getLongitude$2 = _interopRequireDefault$7(getLongitude$1);
|
|
1233
|
-
var _toRad$1 = _interopRequireDefault$7(toRad$1);
|
|
1234
|
-
var _toDeg = _interopRequireDefault$7(toDeg$1);
|
|
1235
|
-
function _interopRequireDefault$7(obj) {
|
|
1236
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1237
|
-
}
|
|
1238
|
-
var getGreatCircleBearing = function getGreatCircleBearing2(origin, dest) {
|
|
1239
|
-
var destLat = (0, _getLatitude$2.default)(dest);
|
|
1240
|
-
var detLon = (0, _getLongitude$2.default)(dest);
|
|
1241
|
-
var originLat = (0, _getLatitude$2.default)(origin);
|
|
1242
|
-
var originLon = (0, _getLongitude$2.default)(origin);
|
|
1243
|
-
var bearing = ((0, _toDeg.default)(Math.atan2(Math.sin((0, _toRad$1.default)(detLon) - (0, _toRad$1.default)(originLon)) * Math.cos((0, _toRad$1.default)(destLat)), Math.cos((0, _toRad$1.default)(originLat)) * Math.sin((0, _toRad$1.default)(destLat)) - Math.sin((0, _toRad$1.default)(originLat)) * Math.cos((0, _toRad$1.default)(destLat)) * Math.cos((0, _toRad$1.default)(detLon) - (0, _toRad$1.default)(originLon)))) + 360) % 360;
|
|
1244
|
-
return bearing;
|
|
1245
|
-
};
|
|
1246
|
-
var _default$9 = getGreatCircleBearing;
|
|
1247
|
-
getGreatCircleBearing$1.default = _default$9;
|
|
1248
|
-
var getPathLength$1 = {};
|
|
1249
|
-
Object.defineProperty(getPathLength$1, "__esModule", { value: true });
|
|
1250
|
-
getPathLength$1.default = void 0;
|
|
1251
|
-
var _getDistance$3 = _interopRequireDefault$6(getDistance$2);
|
|
1252
|
-
function _interopRequireDefault$6(obj) {
|
|
1253
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1254
|
-
}
|
|
1255
|
-
function _typeof(obj) {
|
|
1256
|
-
"@babel/helpers - typeof";
|
|
1257
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
1258
|
-
_typeof = function _typeof2(obj2) {
|
|
1259
|
-
return typeof obj2;
|
|
1260
|
-
};
|
|
1261
|
-
} else {
|
|
1262
|
-
_typeof = function _typeof2(obj2) {
|
|
1263
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
return _typeof(obj);
|
|
1267
|
-
}
|
|
1268
|
-
var getPathLength = function getPathLength2(points) {
|
|
1269
|
-
var distanceFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _getDistance$3.default;
|
|
1270
|
-
return points.reduce(function(acc, point) {
|
|
1271
|
-
if (_typeof(acc) === "object" && acc.last !== null) {
|
|
1272
|
-
acc.distance += distanceFn(point, acc.last);
|
|
1273
|
-
}
|
|
1274
|
-
acc.last = point;
|
|
1275
|
-
return acc;
|
|
1276
|
-
}, { last: null, distance: 0 }).distance;
|
|
1277
|
-
};
|
|
1278
|
-
var _default$8 = getPathLength;
|
|
1279
|
-
getPathLength$1.default = _default$8;
|
|
1280
|
-
var getPreciseDistance = {};
|
|
1281
|
-
Object.defineProperty(getPreciseDistance, "__esModule", { value: true });
|
|
1282
|
-
getPreciseDistance.default = void 0;
|
|
1283
|
-
var _getLatitude$1 = _interopRequireDefault$5(getLatitude$1);
|
|
1284
|
-
var _getLongitude$1 = _interopRequireDefault$5(getLongitude$1);
|
|
1285
|
-
var _toRad = _interopRequireDefault$5(toRad$1);
|
|
1286
|
-
var _constants = constants;
|
|
1287
|
-
function _interopRequireDefault$5(obj) {
|
|
1288
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1289
|
-
}
|
|
1290
|
-
var getDistance2 = function getDistance3(start, end) {
|
|
1291
|
-
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
1292
|
-
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
1293
|
-
var startLat = (0, _getLatitude$1.default)(start);
|
|
1294
|
-
var startLon = (0, _getLongitude$1.default)(start);
|
|
1295
|
-
var endLat = (0, _getLatitude$1.default)(end);
|
|
1296
|
-
var endLon = (0, _getLongitude$1.default)(end);
|
|
1297
|
-
var b = 6356752314245e-6;
|
|
1298
|
-
var ellipsoidParams = 1 / 298.257223563;
|
|
1299
|
-
var L = (0, _toRad.default)(endLon - startLon);
|
|
1300
|
-
var cosSigma;
|
|
1301
|
-
var sigma;
|
|
1302
|
-
var sinAlpha;
|
|
1303
|
-
var cosSqAlpha;
|
|
1304
|
-
var cos2SigmaM;
|
|
1305
|
-
var sinSigma;
|
|
1306
|
-
var U1 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(startLat))));
|
|
1307
|
-
var U2 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(endLat))));
|
|
1308
|
-
var sinU1 = Math.sin(U1);
|
|
1309
|
-
var cosU1 = Math.cos(U1);
|
|
1310
|
-
var sinU2 = Math.sin(U2);
|
|
1311
|
-
var cosU2 = Math.cos(U2);
|
|
1312
|
-
var lambda = L;
|
|
1313
|
-
var lambdaP;
|
|
1314
|
-
var iterLimit = 100;
|
|
1315
|
-
do {
|
|
1316
|
-
var sinLambda = Math.sin(lambda);
|
|
1317
|
-
var cosLambda = Math.cos(lambda);
|
|
1318
|
-
sinSigma = Math.sqrt(cosU2 * sinLambda * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
|
|
1319
|
-
if (sinSigma === 0) {
|
|
1320
|
-
return 0;
|
|
1321
|
-
}
|
|
1322
|
-
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
|
|
1323
|
-
sigma = Math.atan2(sinSigma, cosSigma);
|
|
1324
|
-
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
|
|
1325
|
-
cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
|
1326
|
-
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
|
|
1327
|
-
if (isNaN(cos2SigmaM)) {
|
|
1328
|
-
cos2SigmaM = 0;
|
|
1329
|
-
}
|
|
1330
|
-
var C = ellipsoidParams / 16 * cosSqAlpha * (4 + ellipsoidParams * (4 - 3 * cosSqAlpha));
|
|
1331
|
-
lambdaP = lambda;
|
|
1332
|
-
lambda = L + (1 - C) * ellipsoidParams * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
1333
|
-
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
|
|
1334
|
-
if (iterLimit === 0) {
|
|
1335
|
-
return NaN;
|
|
1336
|
-
}
|
|
1337
|
-
var uSq = cosSqAlpha * (_constants.earthRadius * _constants.earthRadius - b * b) / (b * b);
|
|
1338
|
-
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
|
1339
|
-
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
|
1340
|
-
var deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
|
1341
|
-
var distance = b * A * (sigma - deltaSigma);
|
|
1342
|
-
return Math.round(distance / accuracy) * accuracy;
|
|
1343
|
-
};
|
|
1344
|
-
var _default$7 = getDistance2;
|
|
1345
|
-
getPreciseDistance.default = _default$7;
|
|
1346
|
-
var getRoughCompassDirection$1 = {};
|
|
1347
|
-
Object.defineProperty(getRoughCompassDirection$1, "__esModule", { value: true });
|
|
1348
|
-
getRoughCompassDirection$1.default = void 0;
|
|
1349
|
-
var getRoughCompassDirection = function getRoughCompassDirection2(exact) {
|
|
1350
|
-
if (/^(NNE|NE|NNW|N)$/.test(exact)) {
|
|
1351
|
-
return "N";
|
|
1352
|
-
}
|
|
1353
|
-
if (/^(ENE|E|ESE|SE)$/.test(exact)) {
|
|
1354
|
-
return "E";
|
|
1355
|
-
}
|
|
1356
|
-
if (/^(SSE|S|SSW|SW)$/.test(exact)) {
|
|
1357
|
-
return "S";
|
|
1358
|
-
}
|
|
1359
|
-
if (/^(WSW|W|WNW|NW)$/.test(exact)) {
|
|
1360
|
-
return "W";
|
|
1361
|
-
}
|
|
1362
|
-
};
|
|
1363
|
-
var _default$6 = getRoughCompassDirection;
|
|
1364
|
-
getRoughCompassDirection$1.default = _default$6;
|
|
1365
|
-
var getSpeed$1 = {};
|
|
1366
|
-
Object.defineProperty(getSpeed$1, "__esModule", { value: true });
|
|
1367
|
-
getSpeed$1.default = void 0;
|
|
1368
|
-
var _getDistance$2 = _interopRequireDefault$4(getDistance$2);
|
|
1369
|
-
function _interopRequireDefault$4(obj) {
|
|
1370
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1371
|
-
}
|
|
1372
|
-
var getSpeed = function getSpeed2(start, end) {
|
|
1373
|
-
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance$2.default;
|
|
1374
|
-
var distance = distanceFn(start, end);
|
|
1375
|
-
var time = Number(end.time) - Number(start.time);
|
|
1376
|
-
var metersPerSecond = distance / time * 1e3;
|
|
1377
|
-
return metersPerSecond;
|
|
1378
|
-
};
|
|
1379
|
-
var _default$5 = getSpeed;
|
|
1380
|
-
getSpeed$1.default = _default$5;
|
|
1381
|
-
var isPointInLine$1 = {};
|
|
1382
|
-
Object.defineProperty(isPointInLine$1, "__esModule", { value: true });
|
|
1383
|
-
isPointInLine$1.default = void 0;
|
|
1384
|
-
var _getDistance$1 = _interopRequireDefault$3(getDistance$2);
|
|
1385
|
-
function _interopRequireDefault$3(obj) {
|
|
1386
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1387
|
-
}
|
|
1388
|
-
var isPointInLine = function isPointInLine2(point, lineStart, lineEnd) {
|
|
1389
|
-
return (0, _getDistance$1.default)(lineStart, point) + (0, _getDistance$1.default)(point, lineEnd) === (0, _getDistance$1.default)(lineStart, lineEnd);
|
|
1390
|
-
};
|
|
1391
|
-
var _default$4 = isPointInLine;
|
|
1392
|
-
isPointInLine$1.default = _default$4;
|
|
1393
|
-
var isPointInPolygon$1 = {};
|
|
1394
|
-
Object.defineProperty(isPointInPolygon$1, "__esModule", { value: true });
|
|
1395
|
-
isPointInPolygon$1.default = void 0;
|
|
1396
|
-
var _getLatitude = _interopRequireDefault$2(getLatitude$1);
|
|
1397
|
-
var _getLongitude = _interopRequireDefault$2(getLongitude$1);
|
|
1398
|
-
function _interopRequireDefault$2(obj) {
|
|
1399
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1400
|
-
}
|
|
1401
|
-
var isPointInPolygon = function isPointInPolygon2(point, polygon) {
|
|
1402
|
-
var isInside = false;
|
|
1403
|
-
var totalPolys = polygon.length;
|
|
1404
|
-
for (var i = -1, j = totalPolys - 1; ++i < totalPolys; j = i) {
|
|
1405
|
-
if (((0, _getLongitude.default)(polygon[i]) <= (0, _getLongitude.default)(point) && (0, _getLongitude.default)(point) < (0, _getLongitude.default)(polygon[j]) || (0, _getLongitude.default)(polygon[j]) <= (0, _getLongitude.default)(point) && (0, _getLongitude.default)(point) < (0, _getLongitude.default)(polygon[i])) && (0, _getLatitude.default)(point) < ((0, _getLatitude.default)(polygon[j]) - (0, _getLatitude.default)(polygon[i])) * ((0, _getLongitude.default)(point) - (0, _getLongitude.default)(polygon[i])) / ((0, _getLongitude.default)(polygon[j]) - (0, _getLongitude.default)(polygon[i])) + (0, _getLatitude.default)(polygon[i])) {
|
|
1406
|
-
isInside = !isInside;
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
return isInside;
|
|
1410
|
-
};
|
|
1411
|
-
var _default$3 = isPointInPolygon;
|
|
1412
|
-
isPointInPolygon$1.default = _default$3;
|
|
1413
|
-
var isPointNearLine$1 = {};
|
|
1414
|
-
Object.defineProperty(isPointNearLine$1, "__esModule", { value: true });
|
|
1415
|
-
isPointNearLine$1.default = void 0;
|
|
1416
|
-
var _getDistanceFromLine = _interopRequireDefault$1(getDistanceFromLine$1);
|
|
1417
|
-
function _interopRequireDefault$1(obj) {
|
|
1418
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1419
|
-
}
|
|
1420
|
-
var isPointNearLine = function isPointNearLine2(point, start, end, distance) {
|
|
1421
|
-
return (0, _getDistanceFromLine.default)(point, start, end) < distance;
|
|
1422
|
-
};
|
|
1423
|
-
var _default$2 = isPointNearLine;
|
|
1424
|
-
isPointNearLine$1.default = _default$2;
|
|
1425
|
-
var isPointWithinRadius$1 = {};
|
|
1426
|
-
Object.defineProperty(isPointWithinRadius$1, "__esModule", { value: true });
|
|
1427
|
-
isPointWithinRadius$1.default = void 0;
|
|
1428
|
-
var _getDistance = _interopRequireDefault(getDistance$2);
|
|
1429
|
-
function _interopRequireDefault(obj) {
|
|
1430
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1431
|
-
}
|
|
1432
|
-
var isPointWithinRadius = function isPointWithinRadius2(point, center, radius) {
|
|
1433
|
-
var accuracy = 0.01;
|
|
1434
|
-
return (0, _getDistance.default)(point, center, accuracy) < radius;
|
|
1435
|
-
};
|
|
1436
|
-
var _default$1 = isPointWithinRadius;
|
|
1437
|
-
isPointWithinRadius$1.default = _default$1;
|
|
1438
|
-
var wktToPolygon$1 = {};
|
|
1439
|
-
Object.defineProperty(wktToPolygon$1, "__esModule", { value: true });
|
|
1440
|
-
wktToPolygon$1.default = void 0;
|
|
1441
|
-
function _slicedToArray(arr, i) {
|
|
1442
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1443
|
-
}
|
|
1444
|
-
function _nonIterableRest() {
|
|
1445
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1446
|
-
}
|
|
1447
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1448
|
-
if (!o) return;
|
|
1449
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1450
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1451
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1452
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1453
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1454
|
-
}
|
|
1455
|
-
function _arrayLikeToArray(arr, len) {
|
|
1456
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1457
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1458
|
-
arr2[i] = arr[i];
|
|
1459
|
-
}
|
|
1460
|
-
return arr2;
|
|
1461
|
-
}
|
|
1462
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1463
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
1464
|
-
var _arr = [];
|
|
1465
|
-
var _n = true;
|
|
1466
|
-
var _d = false;
|
|
1467
|
-
var _e = void 0;
|
|
1468
|
-
try {
|
|
1469
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1470
|
-
_arr.push(_s.value);
|
|
1471
|
-
if (i && _arr.length === i) break;
|
|
1472
|
-
}
|
|
1473
|
-
} catch (err) {
|
|
1474
|
-
_d = true;
|
|
1475
|
-
_e = err;
|
|
1476
|
-
} finally {
|
|
1477
|
-
try {
|
|
1478
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1479
|
-
} finally {
|
|
1480
|
-
if (_d) throw _e;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
return _arr;
|
|
1484
|
-
}
|
|
1485
|
-
function _arrayWithHoles(arr) {
|
|
1486
|
-
if (Array.isArray(arr)) return arr;
|
|
1487
|
-
}
|
|
1488
|
-
var wktToPolygon = function wktToPolygon2(wkt) {
|
|
1489
|
-
if (!wkt.startsWith("POLYGON")) {
|
|
1490
|
-
throw new Error("Invalid wkt.");
|
|
1491
|
-
}
|
|
1492
|
-
var coordsText = wkt.slice(wkt.indexOf("(") + 2, wkt.indexOf(")")).split(", ");
|
|
1493
|
-
var polygon = coordsText.map(function(coordText) {
|
|
1494
|
-
var _coordText$split = coordText.split(" "), _coordText$split2 = _slicedToArray(_coordText$split, 2), longitude = _coordText$split2[0], latitude = _coordText$split2[1];
|
|
1495
|
-
return { longitude: parseFloat(longitude), latitude: parseFloat(latitude) };
|
|
1496
|
-
});
|
|
1497
|
-
return polygon;
|
|
1498
|
-
};
|
|
1499
|
-
var _default = wktToPolygon;
|
|
1500
|
-
wktToPolygon$1.default = _default;
|
|
1501
|
-
(function(exports$1) {
|
|
1502
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1503
|
-
var _exportNames = { computeDestinationPoint: true, convertArea: true, convertDistance: true, convertSpeed: true, decimalToSexagesimal: true, findNearest: true, getAreaOfPolygon: true, getBounds: true, getBoundsOfDistance: true, getCenter: true, getCenterOfBounds: true, getCompassDirection: true, getCoordinateKey: true, getCoordinateKeys: true, getDistance: true, getDistanceFromLine: true, getGreatCircleBearing: true, getLatitude: true, getLongitude: true, getPathLength: true, getPreciseDistance: true, getRhumbLineBearing: true, getRoughCompassDirection: true, getSpeed: true, isDecimal: true, isPointInLine: true, isPointInPolygon: true, isPointNearLine: true, isPointWithinRadius: true, isSexagesimal: true, isValidCoordinate: true, isValidLatitude: true, isValidLongitude: true, orderByDistance: true, sexagesimalToDecimal: true, toDecimal: true, toRad: true, toDeg: true, wktToPolygon: true };
|
|
1504
|
-
Object.defineProperty(exports$1, "computeDestinationPoint", { enumerable: true, get: function get() {
|
|
1505
|
-
return _computeDestinationPoint.default;
|
|
1506
|
-
} });
|
|
1507
|
-
Object.defineProperty(exports$1, "convertArea", { enumerable: true, get: function get() {
|
|
1508
|
-
return _convertArea.default;
|
|
1509
|
-
} });
|
|
1510
|
-
Object.defineProperty(exports$1, "convertDistance", { enumerable: true, get: function get() {
|
|
1511
|
-
return _convertDistance.default;
|
|
1512
|
-
} });
|
|
1513
|
-
Object.defineProperty(exports$1, "convertSpeed", { enumerable: true, get: function get() {
|
|
1514
|
-
return _convertSpeed.default;
|
|
1515
|
-
} });
|
|
1516
|
-
Object.defineProperty(exports$1, "decimalToSexagesimal", { enumerable: true, get: function get() {
|
|
1517
|
-
return _decimalToSexagesimal.default;
|
|
1518
|
-
} });
|
|
1519
|
-
Object.defineProperty(exports$1, "findNearest", { enumerable: true, get: function get() {
|
|
1520
|
-
return _findNearest.default;
|
|
1521
|
-
} });
|
|
1522
|
-
Object.defineProperty(exports$1, "getAreaOfPolygon", { enumerable: true, get: function get() {
|
|
1523
|
-
return _getAreaOfPolygon.default;
|
|
1524
|
-
} });
|
|
1525
|
-
Object.defineProperty(exports$1, "getBounds", { enumerable: true, get: function get() {
|
|
1526
|
-
return _getBounds2.default;
|
|
1527
|
-
} });
|
|
1528
|
-
Object.defineProperty(exports$1, "getBoundsOfDistance", { enumerable: true, get: function get() {
|
|
1529
|
-
return _getBoundsOfDistance.default;
|
|
1530
|
-
} });
|
|
1531
|
-
Object.defineProperty(exports$1, "getCenter", { enumerable: true, get: function get() {
|
|
1532
|
-
return _getCenter.default;
|
|
1533
|
-
} });
|
|
1534
|
-
Object.defineProperty(exports$1, "getCenterOfBounds", { enumerable: true, get: function get() {
|
|
1535
|
-
return _getCenterOfBounds.default;
|
|
1536
|
-
} });
|
|
1537
|
-
Object.defineProperty(exports$1, "getCompassDirection", { enumerable: true, get: function get() {
|
|
1538
|
-
return _getCompassDirection.default;
|
|
1539
|
-
} });
|
|
1540
|
-
Object.defineProperty(exports$1, "getCoordinateKey", { enumerable: true, get: function get() {
|
|
1541
|
-
return _getCoordinateKey2.default;
|
|
1542
|
-
} });
|
|
1543
|
-
Object.defineProperty(exports$1, "getCoordinateKeys", { enumerable: true, get: function get() {
|
|
1544
|
-
return _getCoordinateKeys3.default;
|
|
1545
|
-
} });
|
|
1546
|
-
Object.defineProperty(exports$1, "getDistance", { enumerable: true, get: function get() {
|
|
1547
|
-
return _getDistance2.default;
|
|
1548
|
-
} });
|
|
1549
|
-
Object.defineProperty(exports$1, "getDistanceFromLine", { enumerable: true, get: function get() {
|
|
1550
|
-
return _getDistanceFromLine2.default;
|
|
1551
|
-
} });
|
|
1552
|
-
Object.defineProperty(exports$1, "getGreatCircleBearing", { enumerable: true, get: function get() {
|
|
1553
|
-
return _getGreatCircleBearing.default;
|
|
1554
|
-
} });
|
|
1555
|
-
Object.defineProperty(exports$1, "getLatitude", { enumerable: true, get: function get() {
|
|
1556
|
-
return _getLatitude2.default;
|
|
1557
|
-
} });
|
|
1558
|
-
Object.defineProperty(exports$1, "getLongitude", { enumerable: true, get: function get() {
|
|
1559
|
-
return _getLongitude2.default;
|
|
1560
|
-
} });
|
|
1561
|
-
Object.defineProperty(exports$1, "getPathLength", { enumerable: true, get: function get() {
|
|
1562
|
-
return _getPathLength.default;
|
|
1563
|
-
} });
|
|
1564
|
-
Object.defineProperty(exports$1, "getPreciseDistance", { enumerable: true, get: function get() {
|
|
1565
|
-
return _getPreciseDistance.default;
|
|
1566
|
-
} });
|
|
1567
|
-
Object.defineProperty(exports$1, "getRhumbLineBearing", { enumerable: true, get: function get() {
|
|
1568
|
-
return _getRhumbLineBearing2.default;
|
|
1569
|
-
} });
|
|
1570
|
-
Object.defineProperty(exports$1, "getRoughCompassDirection", { enumerable: true, get: function get() {
|
|
1571
|
-
return _getRoughCompassDirection.default;
|
|
1572
|
-
} });
|
|
1573
|
-
Object.defineProperty(exports$1, "getSpeed", { enumerable: true, get: function get() {
|
|
1574
|
-
return _getSpeed.default;
|
|
1575
|
-
} });
|
|
1576
|
-
Object.defineProperty(exports$1, "isDecimal", { enumerable: true, get: function get() {
|
|
1577
|
-
return _isDecimal2.default;
|
|
1578
|
-
} });
|
|
1579
|
-
Object.defineProperty(exports$1, "isPointInLine", { enumerable: true, get: function get() {
|
|
1580
|
-
return _isPointInLine.default;
|
|
1581
|
-
} });
|
|
1582
|
-
Object.defineProperty(exports$1, "isPointInPolygon", { enumerable: true, get: function get() {
|
|
1583
|
-
return _isPointInPolygon.default;
|
|
1584
|
-
} });
|
|
1585
|
-
Object.defineProperty(exports$1, "isPointNearLine", { enumerable: true, get: function get() {
|
|
1586
|
-
return _isPointNearLine.default;
|
|
1587
|
-
} });
|
|
1588
|
-
Object.defineProperty(exports$1, "isPointWithinRadius", { enumerable: true, get: function get() {
|
|
1589
|
-
return _isPointWithinRadius.default;
|
|
1590
|
-
} });
|
|
1591
|
-
Object.defineProperty(exports$1, "isSexagesimal", { enumerable: true, get: function get() {
|
|
1592
|
-
return _isSexagesimal2.default;
|
|
1593
|
-
} });
|
|
1594
|
-
Object.defineProperty(exports$1, "isValidCoordinate", { enumerable: true, get: function get() {
|
|
1595
|
-
return _isValidCoordinate2.default;
|
|
1596
|
-
} });
|
|
1597
|
-
Object.defineProperty(exports$1, "isValidLatitude", { enumerable: true, get: function get() {
|
|
1598
|
-
return _isValidLatitude2.default;
|
|
1599
|
-
} });
|
|
1600
|
-
Object.defineProperty(exports$1, "isValidLongitude", { enumerable: true, get: function get() {
|
|
1601
|
-
return _isValidLongitude2.default;
|
|
1602
|
-
} });
|
|
1603
|
-
Object.defineProperty(exports$1, "orderByDistance", { enumerable: true, get: function get() {
|
|
1604
|
-
return _orderByDistance2.default;
|
|
1605
|
-
} });
|
|
1606
|
-
Object.defineProperty(exports$1, "sexagesimalToDecimal", { enumerable: true, get: function get() {
|
|
1607
|
-
return _sexagesimalToDecimal2.default;
|
|
1608
|
-
} });
|
|
1609
|
-
Object.defineProperty(exports$1, "toDecimal", { enumerable: true, get: function get() {
|
|
1610
|
-
return _toDecimal2.default;
|
|
1611
|
-
} });
|
|
1612
|
-
Object.defineProperty(exports$1, "toRad", { enumerable: true, get: function get() {
|
|
1613
|
-
return _toRad2.default;
|
|
1614
|
-
} });
|
|
1615
|
-
Object.defineProperty(exports$1, "toDeg", { enumerable: true, get: function get() {
|
|
1616
|
-
return _toDeg2.default;
|
|
1617
|
-
} });
|
|
1618
|
-
Object.defineProperty(exports$1, "wktToPolygon", { enumerable: true, get: function get() {
|
|
1619
|
-
return _wktToPolygon.default;
|
|
1620
|
-
} });
|
|
1621
|
-
var _computeDestinationPoint = _interopRequireDefault2(computeDestinationPoint$1);
|
|
1622
|
-
var _convertArea = _interopRequireDefault2(convertArea$1);
|
|
1623
|
-
var _convertDistance = _interopRequireDefault2(convertDistance$1);
|
|
1624
|
-
var _convertSpeed = _interopRequireDefault2(convertSpeed$1);
|
|
1625
|
-
var _decimalToSexagesimal = _interopRequireDefault2(decimalToSexagesimal);
|
|
1626
|
-
var _findNearest = _interopRequireDefault2(findNearest$1);
|
|
1627
|
-
var _getAreaOfPolygon = _interopRequireDefault2(getAreaOfPolygon$1);
|
|
1628
|
-
var _getBounds2 = _interopRequireDefault2(getBounds$1);
|
|
1629
|
-
var _getBoundsOfDistance = _interopRequireDefault2(getBoundsOfDistance$1);
|
|
1630
|
-
var _getCenter = _interopRequireDefault2(getCenter$1);
|
|
1631
|
-
var _getCenterOfBounds = _interopRequireDefault2(getCenterOfBounds$1);
|
|
1632
|
-
var _getCompassDirection = _interopRequireDefault2(getCompassDirection$1);
|
|
1633
|
-
var _getCoordinateKey2 = _interopRequireDefault2(getCoordinateKey$1);
|
|
1634
|
-
var _getCoordinateKeys3 = _interopRequireDefault2(getCoordinateKeys$1);
|
|
1635
|
-
var _getDistance2 = _interopRequireDefault2(getDistance$2);
|
|
1636
|
-
var _getDistanceFromLine2 = _interopRequireDefault2(getDistanceFromLine$1);
|
|
1637
|
-
var _getGreatCircleBearing = _interopRequireDefault2(getGreatCircleBearing$1);
|
|
1638
|
-
var _getLatitude2 = _interopRequireDefault2(getLatitude$1);
|
|
1639
|
-
var _getLongitude2 = _interopRequireDefault2(getLongitude$1);
|
|
1640
|
-
var _getPathLength = _interopRequireDefault2(getPathLength$1);
|
|
1641
|
-
var _getPreciseDistance = _interopRequireDefault2(getPreciseDistance);
|
|
1642
|
-
var _getRhumbLineBearing2 = _interopRequireDefault2(getRhumbLineBearing$1);
|
|
1643
|
-
var _getRoughCompassDirection = _interopRequireDefault2(getRoughCompassDirection$1);
|
|
1644
|
-
var _getSpeed = _interopRequireDefault2(getSpeed$1);
|
|
1645
|
-
var _isDecimal2 = _interopRequireDefault2(isDecimal$1);
|
|
1646
|
-
var _isPointInLine = _interopRequireDefault2(isPointInLine$1);
|
|
1647
|
-
var _isPointInPolygon = _interopRequireDefault2(isPointInPolygon$1);
|
|
1648
|
-
var _isPointNearLine = _interopRequireDefault2(isPointNearLine$1);
|
|
1649
|
-
var _isPointWithinRadius = _interopRequireDefault2(isPointWithinRadius$1);
|
|
1650
|
-
var _isSexagesimal2 = _interopRequireDefault2(isSexagesimal$1);
|
|
1651
|
-
var _isValidCoordinate2 = _interopRequireDefault2(isValidCoordinate$1);
|
|
1652
|
-
var _isValidLatitude2 = _interopRequireDefault2(isValidLatitude$1);
|
|
1653
|
-
var _isValidLongitude2 = _interopRequireDefault2(isValidLongitude$1);
|
|
1654
|
-
var _orderByDistance2 = _interopRequireDefault2(orderByDistance$1);
|
|
1655
|
-
var _sexagesimalToDecimal2 = _interopRequireDefault2(sexagesimalToDecimal$1);
|
|
1656
|
-
var _toDecimal2 = _interopRequireDefault2(toDecimal$1);
|
|
1657
|
-
var _toRad2 = _interopRequireDefault2(toRad$1);
|
|
1658
|
-
var _toDeg2 = _interopRequireDefault2(toDeg$1);
|
|
1659
|
-
var _wktToPolygon = _interopRequireDefault2(wktToPolygon$1);
|
|
1660
|
-
var _constants2 = constants;
|
|
1661
|
-
Object.keys(_constants2).forEach(function(key) {
|
|
1662
|
-
if (key === "default" || key === "__esModule") return;
|
|
1663
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
1664
|
-
Object.defineProperty(exports$1, key, { enumerable: true, get: function get() {
|
|
1665
|
-
return _constants2[key];
|
|
1666
|
-
} });
|
|
1667
|
-
});
|
|
1668
|
-
function _interopRequireDefault2(obj) {
|
|
1669
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1670
|
-
}
|
|
1671
|
-
})(es);
|
|
32
|
+
const fs = '#version 300 es\n#define SHADER_NAME "arrow-layer-fragment-shader"\nprecision highp float;\n\n/**\n * Copyright (c) 2022, RTE (http://www.rte-france.com)\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n\nflat in vec4 vFillColor;\nflat in float shouldDiscard;\nout vec4 fragmentColor;\n\nvoid main(void ) {\n if (shouldDiscard > 0.0) {\n discard;\n }\n fragmentColor = vFillColor;\n}\n';
|
|
1672
33
|
const vs = `#version 300 es
|
|
1673
34
|
#define SHADER_NAME "arrow-layer-vertex-shader"
|
|
1674
35
|
|
|
@@ -1696,17 +57,8 @@ in vec3 instanceLineAngles;
|
|
|
1696
57
|
in vec2 instanceProximityFactors;
|
|
1697
58
|
in float instanceDistanceBetweenLines;
|
|
1698
59
|
|
|
1699
|
-
uniform float sizeMinPixels;
|
|
1700
|
-
uniform float sizeMaxPixels;
|
|
1701
|
-
uniform float timestamp;
|
|
1702
60
|
uniform sampler2D linePositionsTexture;
|
|
1703
61
|
uniform sampler2D lineDistancesTexture;
|
|
1704
|
-
uniform float maxParallelOffset;
|
|
1705
|
-
uniform float minParallelOffset;
|
|
1706
|
-
uniform float opacity;
|
|
1707
|
-
uniform ivec2 linePositionsTextureSize;
|
|
1708
|
-
|
|
1709
|
-
uniform ivec2 lineDistancesTextureSize;
|
|
1710
62
|
|
|
1711
63
|
flat out vec4 vFillColor;
|
|
1712
64
|
flat out float shouldDiscard;
|
|
@@ -1723,7 +75,7 @@ ivec2 calculateTextureIndex(int flatIndex, ivec2 textureSize) {
|
|
|
1723
75
|
*/
|
|
1724
76
|
vec3 fetchLinePosition(int point) {
|
|
1725
77
|
int flatIndex = instanceLinePositionsTextureOffset + point;
|
|
1726
|
-
ivec2 textureIndex = calculateTextureIndex(flatIndex, linePositionsTextureSize);
|
|
78
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, arrow.linePositionsTextureSize);
|
|
1727
79
|
return vec3(texelFetch(linePositionsTexture, textureIndex, 0).xy, 0);
|
|
1728
80
|
}
|
|
1729
81
|
|
|
@@ -1732,7 +84,7 @@ vec3 fetchLinePosition(int point) {
|
|
|
1732
84
|
*/
|
|
1733
85
|
float fetchLineDistance(int point) {
|
|
1734
86
|
int flatIndex = instanceLineDistancesTextureOffset + point;
|
|
1735
|
-
ivec2 textureIndex = calculateTextureIndex(flatIndex, lineDistancesTextureSize);
|
|
87
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, arrow.lineDistancesTextureSize);
|
|
1736
88
|
return texelFetch(lineDistancesTexture, textureIndex, 0).x;
|
|
1737
89
|
}
|
|
1738
90
|
|
|
@@ -1801,9 +153,9 @@ float project_size_at_latitude_low_zoom(float lat) {
|
|
|
1801
153
|
* (see: https://github.com/visgl/deck.gl/blob/401d624c0529faaa62125714c376b3ba3b8f379f/dev-docs/RFCs/v6.1/improved-lnglat-projection-rfc.md?plain=1#L29)
|
|
1802
154
|
*/
|
|
1803
155
|
float project_size_all_zoom_levels(float meters, float lat) {
|
|
1804
|
-
// We use
|
|
1805
|
-
if (
|
|
1806
|
-
return meters *
|
|
156
|
+
// We use project.scale = 4096 (2^12) which corresponds to zoom = 12
|
|
157
|
+
if (project.scale < 4096.0) {
|
|
158
|
+
return meters * project.commonUnitsPerMeter.z * project_size_at_latitude_low_zoom(lat);
|
|
1807
159
|
}
|
|
1808
160
|
return project_size(meters);
|
|
1809
161
|
}
|
|
@@ -1817,7 +169,7 @@ void main(void ) {
|
|
|
1817
169
|
// instanceArrowDistance: a float in interval [0,1] describing the initial position of the arrow along the full path between two substations (0: begin, 1.0 end)
|
|
1818
170
|
float distanceAlong =
|
|
1819
171
|
instanceLineDistance * instanceArrowDistance +
|
|
1820
|
-
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * timestamp * instanceSpeedFactor;
|
|
172
|
+
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * arrow.timestamp * instanceSpeedFactor;
|
|
1821
173
|
float arrowDistance = mod(distanceAlong, instanceLineDistance);
|
|
1822
174
|
if (arrowDistance < 0.0) {
|
|
1823
175
|
arrowDistance += instanceLineDistance;
|
|
@@ -1839,7 +191,7 @@ void main(void ) {
|
|
|
1839
191
|
vec3 linePosition2 = fetchLinePosition(linePoint);
|
|
1840
192
|
|
|
1841
193
|
// clamp to arrow size limits
|
|
1842
|
-
float sizePixels = clamp(project_size_to_pixel(instanceSize), sizeMinPixels, sizeMaxPixels);
|
|
194
|
+
float sizePixels = clamp(project_size_to_pixel(instanceSize), arrow.sizeMinPixels, arrow.sizeMaxPixels);
|
|
1843
195
|
|
|
1844
196
|
// project the 2 line points position to common space
|
|
1845
197
|
vec3 position64Low = vec3(0, 0, 0);
|
|
@@ -1852,8 +204,8 @@ void main(void ) {
|
|
|
1852
204
|
vec3 arrowPositionWorldSpace = mix(linePosition1, linePosition2, interpolationValue);
|
|
1853
205
|
float offsetCommonSpace = clamp(
|
|
1854
206
|
project_size_all_zoom_levels(instanceDistanceBetweenLines, arrowPositionWorldSpace.y),
|
|
1855
|
-
project_pixel_size(minParallelOffset),
|
|
1856
|
-
project_pixel_size(maxParallelOffset)
|
|
207
|
+
project_pixel_size(arrow.minParallelOffset),
|
|
208
|
+
project_pixel_size(arrow.maxParallelOffset)
|
|
1857
209
|
);
|
|
1858
210
|
|
|
1859
211
|
// calculate translation for the parallels lines, use the angle calculated from origin/destination
|
|
@@ -1894,12 +246,35 @@ void main(void ) {
|
|
|
1894
246
|
gl_Position = vertexPosition;
|
|
1895
247
|
|
|
1896
248
|
// arrow fill color for fragment shader
|
|
1897
|
-
vFillColor = vec4(instanceColor.rgb, opacity);
|
|
249
|
+
vFillColor = vec4(instanceColor.rgb, layer.opacity);
|
|
1898
250
|
shouldDiscard = 0.0;
|
|
1899
251
|
}
|
|
1900
252
|
}
|
|
1901
253
|
`;
|
|
1902
|
-
const
|
|
254
|
+
const arrowUniformBlock = `uniform arrowUniforms {
|
|
255
|
+
float sizeMinPixels;
|
|
256
|
+
float sizeMaxPixels;
|
|
257
|
+
float timestamp;
|
|
258
|
+
float maxParallelOffset;
|
|
259
|
+
float minParallelOffset;
|
|
260
|
+
highp ivec2 linePositionsTextureSize;
|
|
261
|
+
highp ivec2 lineDistancesTextureSize;
|
|
262
|
+
} arrow;
|
|
263
|
+
`;
|
|
264
|
+
const arrowUniforms = {
|
|
265
|
+
name: "arrow",
|
|
266
|
+
vs: arrowUniformBlock,
|
|
267
|
+
fs: arrowUniformBlock,
|
|
268
|
+
uniformTypes: {
|
|
269
|
+
sizeMinPixels: "f32",
|
|
270
|
+
sizeMaxPixels: "f32",
|
|
271
|
+
timestamp: "f32",
|
|
272
|
+
maxParallelOffset: "f32",
|
|
273
|
+
minParallelOffset: "f32",
|
|
274
|
+
linePositionsTextureSize: "vec2<i32>",
|
|
275
|
+
lineDistancesTextureSize: "vec2<i32>"
|
|
276
|
+
}
|
|
277
|
+
};
|
|
1903
278
|
const DEFAULT_COLOR = [0, 0, 0, 255];
|
|
1904
279
|
const MAX_LINE_POINT_COUNT = 2 ** 15;
|
|
1905
280
|
var ArrowDirection = /* @__PURE__ */ ((ArrowDirection2) => {
|
|
@@ -1931,29 +306,31 @@ const defaultProps$3 = {
|
|
|
1931
306
|
minParallelOffset: { type: "number", value: 3 }
|
|
1932
307
|
// opacity prop is handled at the layer level for visually proportional perception https://deck.gl/docs/api-reference/core/layer#opacity
|
|
1933
308
|
};
|
|
1934
|
-
|
|
309
|
+
class ArrowLayer extends core.Layer {
|
|
310
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
311
|
+
static layerName = "ArrowLayer";
|
|
312
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
313
|
+
static defaultProps = defaultProps$3;
|
|
1935
314
|
getShaders() {
|
|
1936
|
-
return super.getShaders({ vs, fs, modules: [core.project32, core.picking] });
|
|
315
|
+
return super.getShaders({ vs, fs, modules: [core.project32, core.picking, arrowUniforms] });
|
|
1937
316
|
}
|
|
1938
317
|
getArrowLineAttributes(arrow) {
|
|
1939
|
-
var _a;
|
|
1940
318
|
const line = this.props.getLine(arrow);
|
|
1941
319
|
if (!line) {
|
|
1942
320
|
throw new Error("Invalid line");
|
|
1943
321
|
}
|
|
1944
|
-
const attributes =
|
|
322
|
+
const attributes = this.state.lineAttributes?.get(line);
|
|
1945
323
|
if (!attributes) {
|
|
1946
324
|
throw new Error(`Line ${line.id} not found`);
|
|
1947
325
|
}
|
|
1948
326
|
return attributes;
|
|
1949
327
|
}
|
|
1950
328
|
initializeState({ device }) {
|
|
1951
|
-
var _a;
|
|
1952
329
|
const maxTextureSize = device.limits.maxTextureDimension2D;
|
|
1953
330
|
this.state = {
|
|
1954
331
|
maxTextureSize
|
|
1955
332
|
};
|
|
1956
|
-
|
|
333
|
+
this.getAttributeManager()?.addInstanced({
|
|
1957
334
|
instanceSize: {
|
|
1958
335
|
size: 1,
|
|
1959
336
|
type: "float32",
|
|
@@ -2076,13 +453,13 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2076
453
|
width,
|
|
2077
454
|
height,
|
|
2078
455
|
format,
|
|
2079
|
-
type: constants
|
|
456
|
+
type: constants.GL.FLOAT,
|
|
2080
457
|
data: new Float32Array(data),
|
|
2081
458
|
parameters: {
|
|
2082
|
-
[constants
|
|
2083
|
-
[constants
|
|
2084
|
-
[constants
|
|
2085
|
-
[constants
|
|
459
|
+
[constants.GL.TEXTURE_MAG_FILTER]: constants.GL.NEAREST,
|
|
460
|
+
[constants.GL.TEXTURE_MIN_FILTER]: constants.GL.NEAREST,
|
|
461
|
+
[constants.GL.TEXTURE_WRAP_S]: constants.GL.CLAMP_TO_EDGE,
|
|
462
|
+
[constants.GL.TEXTURE_WRAP_T]: constants.GL.CLAMP_TO_EDGE
|
|
2086
463
|
},
|
|
2087
464
|
mipmaps: false
|
|
2088
465
|
});
|
|
@@ -2109,8 +486,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2109
486
|
let linePointCount = 0;
|
|
2110
487
|
if (positions.length > 0) {
|
|
2111
488
|
positions.forEach((position) => {
|
|
2112
|
-
linePositionsTextureData.push(position[0]);
|
|
2113
|
-
linePositionsTextureData.push(position[1]);
|
|
489
|
+
linePositionsTextureData.push(position[0], position[1]);
|
|
2114
490
|
linePointCount++;
|
|
2115
491
|
});
|
|
2116
492
|
lineDistancesTextureData.push(...line.cumulativeDistances ?? []);
|
|
@@ -2135,7 +511,6 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2135
511
|
};
|
|
2136
512
|
}
|
|
2137
513
|
updateGeometry({ props, changeFlags }) {
|
|
2138
|
-
var _a;
|
|
2139
514
|
const geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getLinePositions);
|
|
2140
515
|
if (geometryChanged) {
|
|
2141
516
|
const { device } = this.context;
|
|
@@ -2160,12 +535,11 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2160
535
|
lineAttributes
|
|
2161
536
|
});
|
|
2162
537
|
if (!changeFlags.dataChanged) {
|
|
2163
|
-
|
|
538
|
+
this.getAttributeManager()?.invalidateAll();
|
|
2164
539
|
}
|
|
2165
540
|
}
|
|
2166
541
|
}
|
|
2167
542
|
updateModel({ changeFlags }) {
|
|
2168
|
-
var _a;
|
|
2169
543
|
if (changeFlags.somethingChanged) {
|
|
2170
544
|
const { device } = this.context;
|
|
2171
545
|
const { model } = this.state;
|
|
@@ -2175,7 +549,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2175
549
|
this.setState({
|
|
2176
550
|
model: this._getModel(device)
|
|
2177
551
|
});
|
|
2178
|
-
|
|
552
|
+
this.getAttributeManager()?.invalidateAll();
|
|
2179
553
|
}
|
|
2180
554
|
}
|
|
2181
555
|
updateState(updateParams) {
|
|
@@ -2203,9 +577,9 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2203
577
|
this.startAnimation();
|
|
2204
578
|
}
|
|
2205
579
|
startAnimation() {
|
|
2206
|
-
|
|
580
|
+
globalThis.requestAnimationFrame((timestamp) => this.animate(timestamp));
|
|
2207
581
|
}
|
|
2208
|
-
draw({
|
|
582
|
+
draw({ renderPass }) {
|
|
2209
583
|
const { sizeMinPixels, sizeMaxPixels } = this.props;
|
|
2210
584
|
const {
|
|
2211
585
|
model,
|
|
@@ -2220,20 +594,16 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2220
594
|
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2221
595
|
lineDistancesTexture
|
|
2222
596
|
});
|
|
2223
|
-
|
|
2224
|
-
...uniforms,
|
|
597
|
+
const arrow = {
|
|
2225
598
|
sizeMinPixels,
|
|
2226
599
|
sizeMaxPixels,
|
|
2227
|
-
|
|
2228
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2229
|
-
linePositionsTextureSize: [linePositionsTexture.width, linePositionsTexture.height],
|
|
2230
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2231
|
-
lineDistancesTextureSize: [lineDistancesTexture.width, lineDistancesTexture.height],
|
|
2232
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2233
|
-
timestamp,
|
|
600
|
+
timestamp: timestamp || 0,
|
|
2234
601
|
maxParallelOffset: this.props.maxParallelOffset,
|
|
2235
|
-
minParallelOffset: this.props.minParallelOffset
|
|
2236
|
-
|
|
602
|
+
minParallelOffset: this.props.minParallelOffset,
|
|
603
|
+
linePositionsTextureSize: [linePositionsTexture.width, linePositionsTexture.height],
|
|
604
|
+
lineDistancesTextureSize: [lineDistancesTexture.width, lineDistancesTexture.height]
|
|
605
|
+
};
|
|
606
|
+
model.shaderInputs.setProps({ arrow });
|
|
2237
607
|
model.draw(renderPass);
|
|
2238
608
|
}
|
|
2239
609
|
_getModel(device) {
|
|
@@ -2257,10 +627,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2257
627
|
})
|
|
2258
628
|
);
|
|
2259
629
|
}
|
|
2260
|
-
}
|
|
2261
|
-
_ArrowLayer.layerName = "ArrowLayer";
|
|
2262
|
-
_ArrowLayer.defaultProps = defaultProps$3;
|
|
2263
|
-
let ArrowLayer = _ArrowLayer;
|
|
630
|
+
}
|
|
2264
631
|
const substationPositionByIdIndexer = (map, substation) => {
|
|
2265
632
|
map.set(substation.id, substation.coordinate);
|
|
2266
633
|
return map;
|
|
@@ -2270,14 +637,17 @@ const linePositionByIdIndexer = (map, line) => {
|
|
|
2270
637
|
return map;
|
|
2271
638
|
};
|
|
2272
639
|
class GeoData {
|
|
640
|
+
substationPositionsById = /* @__PURE__ */ new Map();
|
|
641
|
+
linePositionsById = /* @__PURE__ */ new Map();
|
|
2273
642
|
constructor(substationPositionsById, linePositionsById) {
|
|
2274
|
-
this.substationPositionsById = /* @__PURE__ */ new Map();
|
|
2275
|
-
this.linePositionsById = /* @__PURE__ */ new Map();
|
|
2276
643
|
this.substationPositionsById = substationPositionsById;
|
|
2277
644
|
this.linePositionsById = linePositionsById;
|
|
2278
645
|
}
|
|
2279
646
|
setSubstationPositions(positions) {
|
|
2280
|
-
this.substationPositionsById = positions.reduce(
|
|
647
|
+
this.substationPositionsById = positions.reduce(
|
|
648
|
+
(map, substation) => substationPositionByIdIndexer(map, substation),
|
|
649
|
+
/* @__PURE__ */ new Map()
|
|
650
|
+
);
|
|
2281
651
|
}
|
|
2282
652
|
updateSubstationPositions(substationIdsToUpdate, fetchedPositions) {
|
|
2283
653
|
fetchedPositions.forEach((pos) => this.substationPositionsById.set(pos.id, pos.coordinate));
|
|
@@ -2292,7 +662,7 @@ class GeoData {
|
|
|
2292
662
|
return [position.lon, position.lat];
|
|
2293
663
|
}
|
|
2294
664
|
setLinePositions(positions) {
|
|
2295
|
-
this.linePositionsById = positions.reduce(linePositionByIdIndexer, /* @__PURE__ */ new Map());
|
|
665
|
+
this.linePositionsById = positions.reduce((map, line) => linePositionByIdIndexer(map, line), /* @__PURE__ */ new Map());
|
|
2296
666
|
}
|
|
2297
667
|
updateLinePositions(lineIdsToUpdate, fetchedPositions) {
|
|
2298
668
|
fetchedPositions.forEach((pos) => {
|
|
@@ -2376,10 +746,13 @@ class GeoData {
|
|
|
2376
746
|
if (arrowPosition > 1 || arrowPosition < 0) {
|
|
2377
747
|
throw new Error("Proportional position value incorrect: " + arrowPosition);
|
|
2378
748
|
}
|
|
2379
|
-
if (cumulativeDistances === null || cumulativeDistances.length < 2 || cumulativeDistances
|
|
749
|
+
if (cumulativeDistances === null || cumulativeDistances.length < 2 || cumulativeDistances.at(-1) === 0) {
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
const lineDistance = cumulativeDistances.at(-1);
|
|
753
|
+
if (lineDistance === void 0) {
|
|
2380
754
|
return null;
|
|
2381
755
|
}
|
|
2382
|
-
const lineDistance = cumulativeDistances[cumulativeDistances.length - 1];
|
|
2383
756
|
let wantedDistance = lineDistance * arrowPosition;
|
|
2384
757
|
if (cumulativeDistances.length === 2) {
|
|
2385
758
|
wantedDistance = wantedDistance - 2 * distanceBetweenLines * arrowPosition * proximityFactor;
|
|
@@ -2403,17 +776,17 @@ class GeoData {
|
|
|
2403
776
|
const angle = this.getMapAngle(goodSegment.segment[0], goodSegment.segment[1]);
|
|
2404
777
|
const neededOffset = this.getLabelOffset(angle, 20, arrowDirection);
|
|
2405
778
|
const position = {
|
|
2406
|
-
position:
|
|
779
|
+
position: geolib.computeDestinationPoint(goodSegment.segment[0], remainingDistance, angle),
|
|
2407
780
|
angle,
|
|
2408
781
|
offset: neededOffset
|
|
2409
782
|
};
|
|
2410
|
-
position.position =
|
|
783
|
+
position.position = geolib.computeDestinationPoint(
|
|
2411
784
|
position.position,
|
|
2412
785
|
distanceBetweenLines * lineParallelIndex,
|
|
2413
786
|
lineAngle + 90
|
|
2414
787
|
);
|
|
2415
788
|
if (cumulativeDistances.length === 2) {
|
|
2416
|
-
position.position =
|
|
789
|
+
position.position = geolib.computeDestinationPoint(
|
|
2417
790
|
position.position,
|
|
2418
791
|
-distanceBetweenLines * proximityFactor,
|
|
2419
792
|
lineAngle
|
|
@@ -2428,7 +801,7 @@ class GeoData {
|
|
|
2428
801
|
labelDistanceInSegment = remainingDistance;
|
|
2429
802
|
}
|
|
2430
803
|
const labelPercentage = labelDistanceInSegment / segmentDistance;
|
|
2431
|
-
position.position =
|
|
804
|
+
position.position = geolib.computeDestinationPoint(
|
|
2432
805
|
position.position,
|
|
2433
806
|
distanceBetweenLines * labelPercentage,
|
|
2434
807
|
proximityAngle
|
|
@@ -2447,7 +820,6 @@ class GeoData {
|
|
|
2447
820
|
direction = -1;
|
|
2448
821
|
break;
|
|
2449
822
|
case ArrowDirection.NONE:
|
|
2450
|
-
direction = 0;
|
|
2451
823
|
break;
|
|
2452
824
|
default:
|
|
2453
825
|
throw new Error("impossible");
|
|
@@ -2459,8 +831,8 @@ class GeoData {
|
|
|
2459
831
|
}
|
|
2460
832
|
//returns the angle between point1 and point2 in degrees [0-360)
|
|
2461
833
|
getMapAngle(point1, point2) {
|
|
2462
|
-
let angle =
|
|
2463
|
-
const angle2 =
|
|
834
|
+
let angle = geolib.getRhumbLineBearing(point1, point2);
|
|
835
|
+
const angle2 = geolib.getGreatCircleBearing(point1, point2);
|
|
2464
836
|
const coeff = 0.1;
|
|
2465
837
|
angle = coeff * angle + (1 - coeff) * angle2;
|
|
2466
838
|
return angle;
|
|
@@ -2489,6 +861,28 @@ const INVALID_FLOW_OPACITY = 0.2;
|
|
|
2489
861
|
const SUBSTATION_RADIUS = 500;
|
|
2490
862
|
const SUBSTATION_RADIUS_MAX_PIXEL = 5;
|
|
2491
863
|
const SUBSTATION_RADIUS_MIN_PIXEL = 1;
|
|
864
|
+
const forkLineUniformBlock = `uniform forkLineUniforms {
|
|
865
|
+
float distanceBetweenLines;
|
|
866
|
+
float maxParallelOffset;
|
|
867
|
+
float minParallelOffset;
|
|
868
|
+
float substationRadius;
|
|
869
|
+
float substationMaxPixel;
|
|
870
|
+
float minSubstationRadiusPixel;
|
|
871
|
+
} forkLine;
|
|
872
|
+
`;
|
|
873
|
+
const forkLineUniforms = {
|
|
874
|
+
name: "forkLine",
|
|
875
|
+
vs: forkLineUniformBlock,
|
|
876
|
+
fs: forkLineUniformBlock,
|
|
877
|
+
uniformTypes: {
|
|
878
|
+
distanceBetweenLines: "f32",
|
|
879
|
+
maxParallelOffset: "f32",
|
|
880
|
+
minParallelOffset: "f32",
|
|
881
|
+
substationRadius: "f32",
|
|
882
|
+
substationMaxPixel: "f32",
|
|
883
|
+
minSubstationRadiusPixel: "f32"
|
|
884
|
+
}
|
|
885
|
+
};
|
|
2492
886
|
const defaultProps$2 = {
|
|
2493
887
|
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2494
888
|
getLineAngle: { type: "accessor", value: 0 },
|
|
@@ -2499,7 +893,11 @@ const defaultProps$2 = {
|
|
|
2499
893
|
substationMaxPixel: { type: "number", value: 5 },
|
|
2500
894
|
minSubstationRadiusPixel: { type: "number", value: 1 }
|
|
2501
895
|
};
|
|
2502
|
-
|
|
896
|
+
class ForkLineLayer extends layers.LineLayer {
|
|
897
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
898
|
+
static layerName = "ForkLineLayer";
|
|
899
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
900
|
+
static defaultProps = defaultProps$2;
|
|
2503
901
|
getShaders() {
|
|
2504
902
|
const shaders = super.getShaders();
|
|
2505
903
|
shaders.inject = {
|
|
@@ -2508,39 +906,44 @@ in float instanceLineParallelIndex;
|
|
|
2508
906
|
in float instanceLineAngle;
|
|
2509
907
|
in float instanceOffsetStart;
|
|
2510
908
|
in float instanceProximityFactor;
|
|
2511
|
-
uniform float distanceBetweenLines;
|
|
2512
|
-
uniform float maxParallelOffset;
|
|
2513
|
-
uniform float minParallelOffset;
|
|
2514
|
-
uniform float substationRadius;
|
|
2515
|
-
uniform float substationMaxPixel;
|
|
2516
|
-
uniform float minSubstationRadiusPixel;
|
|
2517
909
|
`,
|
|
2518
910
|
"float segmentIndex = positions.x": `;
|
|
2519
|
-
target = source
|
|
2520
|
-
|
|
911
|
+
target = source;
|
|
912
|
+
target_commonspace = source_commonspace;
|
|
913
|
+
|
|
914
|
+
float offsetPixels = clamp(project_size_to_pixel(forkLine.distanceBetweenLines), forkLine.minParallelOffset, forkLine.maxParallelOffset);
|
|
2521
915
|
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2522
916
|
|
|
2523
|
-
float offsetSubstation = clamp(
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
917
|
+
float offsetSubstation = clamp(
|
|
918
|
+
project_size_to_pixel(forkLine.substationRadius * instanceOffsetStart),
|
|
919
|
+
forkLine.minSubstationRadiusPixel,
|
|
920
|
+
forkLine.substationMaxPixel * instanceOffsetStart
|
|
921
|
+
);
|
|
922
|
+
float offsetSubstationCommonSpace = project_pixel_size(offsetSubstation);
|
|
2527
923
|
|
|
2528
|
-
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle
|
|
924
|
+
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle), 0.0, 0.0) * instanceLineParallelIndex;
|
|
2529
925
|
|
|
2530
926
|
trans.x -= sin(instanceLineAngle) * instanceProximityFactor;
|
|
2531
927
|
trans.y -= cos(instanceLineAngle) * instanceProximityFactor;
|
|
2532
928
|
|
|
2533
|
-
|
|
2534
|
-
|
|
929
|
+
float transLen = max(1e-6, length(trans.xy));
|
|
930
|
+
vec4 transTargetCommon = trans * offsetCommonSpace;
|
|
931
|
+
vec4 transSourceCommon = trans * (offsetSubstationCommonSpace / transLen);
|
|
932
|
+
|
|
933
|
+
source_commonspace += transSourceCommon;
|
|
934
|
+
target_commonspace += transTargetCommon;
|
|
935
|
+
|
|
936
|
+
source += project_common_position_to_clipspace(transSourceCommon) - project.center;
|
|
937
|
+
target += project_common_position_to_clipspace(transTargetCommon) - project.center;
|
|
2535
938
|
|
|
2536
939
|
`
|
|
2537
940
|
};
|
|
941
|
+
shaders.modules.push(forkLineUniforms);
|
|
2538
942
|
return shaders;
|
|
2539
943
|
}
|
|
2540
944
|
initializeState() {
|
|
2541
|
-
var _a;
|
|
2542
945
|
super.initializeState();
|
|
2543
|
-
|
|
946
|
+
this.getAttributeManager()?.addInstanced({
|
|
2544
947
|
instanceLineParallelIndex: {
|
|
2545
948
|
size: 1,
|
|
2546
949
|
type: "float32",
|
|
@@ -2565,22 +968,35 @@ uniform float minSubstationRadiusPixel;
|
|
|
2565
968
|
}
|
|
2566
969
|
// TODO find the full type for record values
|
|
2567
970
|
draw({ uniforms }) {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
});
|
|
971
|
+
const model = this.state.model;
|
|
972
|
+
const forkLine = {
|
|
973
|
+
distanceBetweenLines: this.props.getDistanceBetweenLines,
|
|
974
|
+
maxParallelOffset: this.props.getMaxParallelOffset,
|
|
975
|
+
minParallelOffset: this.props.getMinParallelOffset,
|
|
976
|
+
substationRadius: this.props.getSubstationRadius,
|
|
977
|
+
substationMaxPixel: this.props.getSubstationMaxPixel,
|
|
978
|
+
minSubstationRadiusPixel: this.props.getMinSubstationRadiusPixel
|
|
979
|
+
};
|
|
980
|
+
model.shaderInputs.setProps({ forkLine });
|
|
981
|
+
super.draw({ uniforms });
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
const parallelPathUniformBlock = `uniform parallelPathUniforms {
|
|
985
|
+
float distanceBetweenLines;
|
|
986
|
+
float maxParallelOffset;
|
|
987
|
+
float minParallelOffset;
|
|
988
|
+
} parallelPath;
|
|
989
|
+
`;
|
|
990
|
+
const parallelPathUniforms = {
|
|
991
|
+
name: "parallelPath",
|
|
992
|
+
vs: parallelPathUniformBlock,
|
|
993
|
+
fs: parallelPathUniformBlock,
|
|
994
|
+
uniformTypes: {
|
|
995
|
+
distanceBetweenLines: "f32",
|
|
996
|
+
maxParallelOffset: "f32",
|
|
997
|
+
minParallelOffset: "f32"
|
|
2579
998
|
}
|
|
2580
999
|
};
|
|
2581
|
-
_ForkLineLayer.layerName = "ForkLineLayer";
|
|
2582
|
-
_ForkLineLayer.defaultProps = defaultProps$2;
|
|
2583
|
-
let ForkLineLayer = _ForkLineLayer;
|
|
2584
1000
|
const defaultProps$1 = {
|
|
2585
1001
|
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2586
1002
|
getLineAngle: { type: "accessor", value: 0 },
|
|
@@ -2588,11 +1004,16 @@ const defaultProps$1 = {
|
|
|
2588
1004
|
maxParallelOffset: { type: "number", value: 100 },
|
|
2589
1005
|
minParallelOffset: { type: "number", value: 3 }
|
|
2590
1006
|
};
|
|
2591
|
-
|
|
1007
|
+
class ParallelPathLayer extends layers.PathLayer {
|
|
1008
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1009
|
+
static layerName = "ParallelPathLayer";
|
|
1010
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1011
|
+
static defaultProps = defaultProps$1;
|
|
2592
1012
|
getShaders() {
|
|
2593
1013
|
const shaders = super.getShaders();
|
|
2594
|
-
shaders.inject =
|
|
2595
|
-
|
|
1014
|
+
shaders.inject = {
|
|
1015
|
+
...shaders.inject,
|
|
1016
|
+
"vs:#decl": `//Note: with the following attribute, we have reached the limit (16 on most platforms) of the number of attributes.
|
|
2596
1017
|
// with webgl2, this might be raised in the future to 32 on most platforms...
|
|
2597
1018
|
// The PathLayer that this class extends already uses 13 attributes (and 15 with the dash extension).
|
|
2598
1019
|
// we have packed all our attributes together in a single attribute to
|
|
@@ -2615,11 +1036,8 @@ const _ParallelPathLayer = class _ParallelPathLayer extends layers.PathLayer {
|
|
|
2615
1036
|
// only its buffer, so it hurts performance a bit in this case.
|
|
2616
1037
|
// But this is a rare case for us (changing parameters) so it doesn't matter much.
|
|
2617
1038
|
in vec4 instanceExtraAttributes;
|
|
2618
|
-
uniform float distanceBetweenLines;
|
|
2619
|
-
uniform float maxParallelOffset;
|
|
2620
|
-
uniform float minParallelOffset;
|
|
2621
1039
|
`,
|
|
2622
|
-
"vs:#main-end":
|
|
1040
|
+
"vs:#main-end": `
|
|
2623
1041
|
bool isSegmentEnd = isEnd > EPSILON;
|
|
2624
1042
|
bool isFirstSegment = (instanceTypes == 1.0 || instanceTypes == 3.0);
|
|
2625
1043
|
bool isLastSegment = (instanceTypes == 2.0 || instanceTypes == 3.0);
|
|
@@ -2633,7 +1051,7 @@ else if ( isSegmentEnd && isLastSegment){
|
|
|
2633
1051
|
}
|
|
2634
1052
|
float instanceLineParallelIndex = (mod(instanceExtraAttributes[3], 64.0) - 31.0) / 2.0;
|
|
2635
1053
|
|
|
2636
|
-
float offsetPixels = clamp(project_size_to_pixel(distanceBetweenLines), minParallelOffset, maxParallelOffset);
|
|
1054
|
+
float offsetPixels = clamp(project_size_to_pixel(parallelPath.distanceBetweenLines), parallelPath.minParallelOffset, parallelPath.maxParallelOffset);
|
|
2637
1055
|
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2638
1056
|
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle), 0, 0.) * instanceLineParallelIndex;
|
|
2639
1057
|
|
|
@@ -2650,15 +1068,16 @@ else if (!isSegmentEnd && isFirstSegment)
|
|
|
2650
1068
|
}
|
|
2651
1069
|
|
|
2652
1070
|
trans = trans * offsetCommonSpace;
|
|
2653
|
-
|
|
1071
|
+
geometry.position += trans;
|
|
1072
|
+
gl_Position += project_common_position_to_clipspace(trans) - project.center;
|
|
2654
1073
|
`
|
|
2655
|
-
}
|
|
1074
|
+
};
|
|
1075
|
+
shaders.modules.push(parallelPathUniforms);
|
|
2656
1076
|
return shaders;
|
|
2657
1077
|
}
|
|
2658
1078
|
initializeState() {
|
|
2659
|
-
var _a;
|
|
2660
1079
|
super.initializeState();
|
|
2661
|
-
|
|
1080
|
+
this.getAttributeManager()?.addInstanced({
|
|
2662
1081
|
// too much instances variables need to compact some...
|
|
2663
1082
|
instanceExtraAttributes: {
|
|
2664
1083
|
size: 4,
|
|
@@ -2668,19 +1087,16 @@ gl_Position += project_common_position_to_clipspace(trans) - project_uCenter;
|
|
|
2668
1087
|
});
|
|
2669
1088
|
}
|
|
2670
1089
|
draw({ uniforms }) {
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
});
|
|
1090
|
+
const model = this.state.model;
|
|
1091
|
+
const parallelPath = {
|
|
1092
|
+
distanceBetweenLines: this.props.distanceBetweenLines,
|
|
1093
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
1094
|
+
minParallelOffset: this.props.minParallelOffset
|
|
1095
|
+
};
|
|
1096
|
+
model.shaderInputs.setProps({ parallelPath });
|
|
1097
|
+
super.draw({ uniforms });
|
|
2679
1098
|
}
|
|
2680
|
-
}
|
|
2681
|
-
_ParallelPathLayer.layerName = "ParallelPathLayer";
|
|
2682
|
-
_ParallelPathLayer.defaultProps = defaultProps$1;
|
|
2683
|
-
let ParallelPathLayer = _ParallelPathLayer;
|
|
1099
|
+
}
|
|
2684
1100
|
const DISTANCE_BETWEEN_ARROWS = 1e4;
|
|
2685
1101
|
const START_ARROW_POSITION = 0.1;
|
|
2686
1102
|
const END_ARROW_POSITION = 0.9;
|
|
@@ -2725,9 +1141,8 @@ function getLineLoadingZoneOfSide(limit, intensity, lineFlowAlertThreshold) {
|
|
|
2725
1141
|
}
|
|
2726
1142
|
}
|
|
2727
1143
|
function getLineLoadingZone(line, lineFlowAlertThreshold) {
|
|
2728
|
-
|
|
2729
|
-
const
|
|
2730
|
-
const zone2 = getLineLoadingZoneOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2, lineFlowAlertThreshold);
|
|
1144
|
+
const zone1 = getLineLoadingZoneOfSide(line.currentLimits1?.permanentLimit, line.i1, lineFlowAlertThreshold);
|
|
1145
|
+
const zone2 = getLineLoadingZoneOfSide(line.currentLimits2?.permanentLimit, line.i2, lineFlowAlertThreshold);
|
|
2731
1146
|
return Math.max(zone1, zone2);
|
|
2732
1147
|
}
|
|
2733
1148
|
function getLineLoadingZoneColor(zone) {
|
|
@@ -2740,7 +1155,7 @@ function getLineLoadingZoneColor(zone) {
|
|
|
2740
1155
|
} else if (zone === 3) {
|
|
2741
1156
|
return [255, 0, 0];
|
|
2742
1157
|
} else {
|
|
2743
|
-
throw new Error(
|
|
1158
|
+
throw new Error(`Unsupported line loading zone: ${zone}`);
|
|
2744
1159
|
}
|
|
2745
1160
|
}
|
|
2746
1161
|
function getLineColor(line, nominalVoltageColor, props, lineConnection) {
|
|
@@ -2757,9 +1172,12 @@ function getLineColor(line, nominalVoltageColor, props, lineConnection) {
|
|
|
2757
1172
|
return nominalVoltageColor;
|
|
2758
1173
|
}
|
|
2759
1174
|
}
|
|
1175
|
+
function getIconFromLineStatus(lineStatus) {
|
|
1176
|
+
return STATUS_ICONS[lineStatus] ?? "";
|
|
1177
|
+
}
|
|
2760
1178
|
function getLineIcon(lineStatus) {
|
|
2761
1179
|
return {
|
|
2762
|
-
url: lineStatus
|
|
1180
|
+
url: getIconFromLineStatus(lineStatus),
|
|
2763
1181
|
height: 24,
|
|
2764
1182
|
width: 24,
|
|
2765
1183
|
mask: true
|
|
@@ -2768,22 +1186,19 @@ function getLineIcon(lineStatus) {
|
|
|
2768
1186
|
function getArrowSpeedOfSide(limit, intensity) {
|
|
2769
1187
|
if (limit === void 0 || intensity === void 0 || intensity === 0) {
|
|
2770
1188
|
return 0;
|
|
1189
|
+
} else if (intensity > 0 && intensity < limit / 3) {
|
|
1190
|
+
return 1;
|
|
1191
|
+
} else if (intensity >= limit / 3 && intensity < limit * 2 / 3) {
|
|
1192
|
+
return 2;
|
|
1193
|
+
} else if (intensity >= limit * 2 / 3 && intensity < limit) {
|
|
1194
|
+
return 3;
|
|
2771
1195
|
} else {
|
|
2772
|
-
|
|
2773
|
-
return 1;
|
|
2774
|
-
} else if (intensity >= limit / 3 && intensity < limit * 2 / 3) {
|
|
2775
|
-
return 2;
|
|
2776
|
-
} else if (intensity >= limit * 2 / 3 && intensity < limit) {
|
|
2777
|
-
return 3;
|
|
2778
|
-
} else {
|
|
2779
|
-
return 4;
|
|
2780
|
-
}
|
|
1196
|
+
return 4;
|
|
2781
1197
|
}
|
|
2782
1198
|
}
|
|
2783
1199
|
function getArrowSpeed(line) {
|
|
2784
|
-
|
|
2785
|
-
const
|
|
2786
|
-
const speed2 = getArrowSpeedOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2);
|
|
1200
|
+
const speed1 = getArrowSpeedOfSide(line.currentLimits1?.permanentLimit, line.i1);
|
|
1201
|
+
const speed2 = getArrowSpeedOfSide(line.currentLimits2?.permanentLimit, line.i2);
|
|
2787
1202
|
return Math.max(speed1, speed2);
|
|
2788
1203
|
}
|
|
2789
1204
|
function getArrowSpeedFactor(speed) {
|
|
@@ -2802,7 +1217,53 @@ function getArrowSpeedFactor(speed) {
|
|
|
2802
1217
|
throw new Error("Unknown arrow speed: " + speed);
|
|
2803
1218
|
}
|
|
2804
1219
|
}
|
|
2805
|
-
const
|
|
1220
|
+
const STATUS_ICONS = {
|
|
1221
|
+
[
|
|
1222
|
+
"PLANNED_OUTAGE"
|
|
1223
|
+
/* PLANNED_OUTAGE */
|
|
1224
|
+
]: PadlockIcon,
|
|
1225
|
+
[
|
|
1226
|
+
"FORCED_OUTAGE"
|
|
1227
|
+
/* FORCED_OUTAGE */
|
|
1228
|
+
]: BoltIcon,
|
|
1229
|
+
[
|
|
1230
|
+
"IN_OPERATION"
|
|
1231
|
+
/* IN_OPERATION */
|
|
1232
|
+
]: ""
|
|
1233
|
+
};
|
|
1234
|
+
class LineLayer extends core.CompositeLayer {
|
|
1235
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1236
|
+
static layerName = "LineLayer";
|
|
1237
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1238
|
+
static defaultProps = {
|
|
1239
|
+
network: void 0,
|
|
1240
|
+
geoData: void 0,
|
|
1241
|
+
getNominalVoltageColor: {
|
|
1242
|
+
type: "accessor",
|
|
1243
|
+
value: () => [255, 255, 255]
|
|
1244
|
+
/*getNominalVoltageColor*/
|
|
1245
|
+
},
|
|
1246
|
+
disconnectedLineColor: { type: "color", value: [255, 255, 255] },
|
|
1247
|
+
filteredNominalVoltages: void 0,
|
|
1248
|
+
lineFlowMode: "feeders",
|
|
1249
|
+
lineFlowColorMode: "nominalVoltage",
|
|
1250
|
+
lineFlowAlertThreshold: 100,
|
|
1251
|
+
showLineFlow: true,
|
|
1252
|
+
lineFullPath: true,
|
|
1253
|
+
lineParallelPath: true,
|
|
1254
|
+
labelSize: 12,
|
|
1255
|
+
iconSize: 48,
|
|
1256
|
+
distanceBetweenLines: 1e3,
|
|
1257
|
+
maxParallelOffset: 100,
|
|
1258
|
+
minParallelOffset: 3,
|
|
1259
|
+
substationRadius: { type: "number", value: SUBSTATION_RADIUS },
|
|
1260
|
+
substationMaxPixel: { type: "number", value: SUBSTATION_RADIUS_MAX_PIXEL },
|
|
1261
|
+
minSubstationRadiusPixel: {
|
|
1262
|
+
type: "number",
|
|
1263
|
+
value: SUBSTATION_RADIUS_MIN_PIXEL
|
|
1264
|
+
},
|
|
1265
|
+
labelColor: [255, 255, 255]
|
|
1266
|
+
};
|
|
2806
1267
|
initializeState(context) {
|
|
2807
1268
|
super.initializeState(context);
|
|
2808
1269
|
this.state = {
|
|
@@ -2814,15 +1275,15 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2814
1275
|
getVoltageLevelIndex(voltageLevelId) {
|
|
2815
1276
|
const { network } = this.props;
|
|
2816
1277
|
const vl = network.getVoltageLevel(voltageLevelId);
|
|
2817
|
-
const substation = network.getSubstation(vl
|
|
1278
|
+
const substation = network.getSubstation(vl?.substationId);
|
|
2818
1279
|
return [
|
|
2819
1280
|
...new Set(
|
|
2820
|
-
substation
|
|
1281
|
+
substation?.voltageLevels.map((vl2) => vl2.nominalV)
|
|
2821
1282
|
// only one voltage level
|
|
2822
1283
|
)
|
|
2823
1284
|
].sort((a, b) => {
|
|
2824
1285
|
return a - b;
|
|
2825
|
-
}).indexOf(vl
|
|
1286
|
+
}).indexOf(vl?.nominalV) + 1;
|
|
2826
1287
|
}
|
|
2827
1288
|
//TODO this is a huge function, refactor
|
|
2828
1289
|
updateState({ props, oldProps, changeFlags }) {
|
|
@@ -2833,34 +1294,33 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2833
1294
|
compositeData = [];
|
|
2834
1295
|
linesConnection = /* @__PURE__ */ new Map();
|
|
2835
1296
|
linesStatus = /* @__PURE__ */ new Map();
|
|
2836
|
-
if (props.network
|
|
1297
|
+
if (props.network?.substations && props.data.length !== 0 && props.geoData != null) {
|
|
2837
1298
|
const lineNominalVoltageIndexer = (map, line) => {
|
|
2838
1299
|
const network = props.network;
|
|
2839
1300
|
const vl1 = network.getVoltageLevel(line.voltageLevelId1);
|
|
2840
1301
|
const vl2 = network.getVoltageLevel(line.voltageLevelId2);
|
|
2841
1302
|
const vl = vl1 || vl2;
|
|
2842
|
-
let list = map.get(vl
|
|
1303
|
+
let list = map.get(vl?.nominalV);
|
|
2843
1304
|
if (!list) {
|
|
2844
1305
|
list = [];
|
|
2845
|
-
map.set(vl
|
|
1306
|
+
map.set(vl?.nominalV, list);
|
|
2846
1307
|
}
|
|
2847
|
-
if (
|
|
1308
|
+
if (vl1?.substationId !== vl2?.substationId) {
|
|
2848
1309
|
list.push(line);
|
|
2849
1310
|
}
|
|
2850
1311
|
return map;
|
|
2851
1312
|
};
|
|
2852
1313
|
const linesByNominalVoltage = props.data.reduce(
|
|
2853
|
-
lineNominalVoltageIndexer,
|
|
1314
|
+
(map, line) => lineNominalVoltageIndexer(map, line),
|
|
2854
1315
|
/* @__PURE__ */ new Map()
|
|
2855
1316
|
);
|
|
2856
1317
|
compositeData = Array.from(linesByNominalVoltage.entries()).map((e) => {
|
|
2857
1318
|
return { nominalV: e[0], lines: e[1] };
|
|
2858
1319
|
}).sort((a, b) => b.nominalV - a.nominalV);
|
|
2859
1320
|
compositeData.forEach((compositeData2) => {
|
|
2860
|
-
var _a;
|
|
2861
1321
|
const mapOriginDestination = /* @__PURE__ */ new Map();
|
|
2862
1322
|
compositeData2.mapOriginDestination = mapOriginDestination;
|
|
2863
|
-
|
|
1323
|
+
compositeData2.lines?.forEach((line) => {
|
|
2864
1324
|
linesConnection.set(line.id, {
|
|
2865
1325
|
terminal1Connected: line.terminal1Connected,
|
|
2866
1326
|
terminal2Connected: line.terminal2Connected
|
|
@@ -2899,9 +1359,8 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2899
1359
|
}
|
|
2900
1360
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || oldProps.geoData !== props.geoData)) {
|
|
2901
1361
|
compositeData.forEach((compositeData2) => {
|
|
2902
|
-
var _a;
|
|
2903
1362
|
const lineMap = /* @__PURE__ */ new Map();
|
|
2904
|
-
|
|
1363
|
+
compositeData2.lines?.forEach((line) => {
|
|
2905
1364
|
const positions = props.geoData.getLinePositions(props.network, line, props.lineFullPath);
|
|
2906
1365
|
const cumulativeDistances = props.geoData.getLineDistances(positions);
|
|
2907
1366
|
lineMap.set(line.id, {
|
|
@@ -2919,16 +1378,14 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2919
1378
|
}
|
|
2920
1379
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2921
1380
|
compositeData.forEach((compositeData2) => {
|
|
2922
|
-
var _a;
|
|
2923
1381
|
compositeData2.activePower = [];
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
const lineData = (_a2 = compositeData2.lineMap) == null ? void 0 : _a2.get(line.id);
|
|
1382
|
+
compositeData2.lines?.forEach((line) => {
|
|
1383
|
+
const lineData = compositeData2.lineMap?.get(line.id);
|
|
2927
1384
|
const arrowDirection = getArrowDirection(line.p1);
|
|
2928
1385
|
const coordinates1 = props.geoData.labelDisplayPosition(
|
|
2929
1386
|
// @ts-expect-error TODO: manage undefined case
|
|
2930
|
-
lineData
|
|
2931
|
-
lineData
|
|
1387
|
+
lineData?.positions,
|
|
1388
|
+
lineData?.cumulativeDistances,
|
|
2932
1389
|
START_ARROW_POSITION,
|
|
2933
1390
|
arrowDirection,
|
|
2934
1391
|
line.parallelIndex,
|
|
@@ -2941,8 +1398,8 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2941
1398
|
);
|
|
2942
1399
|
const coordinates2 = props.geoData.labelDisplayPosition(
|
|
2943
1400
|
// @ts-expect-error TODO: manage undefined case
|
|
2944
|
-
lineData
|
|
2945
|
-
lineData
|
|
1401
|
+
lineData?.positions,
|
|
1402
|
+
lineData?.cumulativeDistances,
|
|
2946
1403
|
END_ARROW_POSITION,
|
|
2947
1404
|
arrowDirection,
|
|
2948
1405
|
line.parallelIndex,
|
|
@@ -2954,35 +1411,35 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2954
1411
|
line.proximityFactorEnd
|
|
2955
1412
|
);
|
|
2956
1413
|
if (coordinates1 !== null && coordinates2 !== null) {
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
1414
|
+
compositeData2.activePower?.push(
|
|
1415
|
+
{
|
|
1416
|
+
line,
|
|
1417
|
+
p: line.p1,
|
|
1418
|
+
printPosition: [coordinates1.position.longitude, coordinates1.position.latitude],
|
|
1419
|
+
offset: coordinates1.offset
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
line,
|
|
1423
|
+
p: line.p2,
|
|
1424
|
+
printPosition: [coordinates2.position.longitude, coordinates2.position.latitude],
|
|
1425
|
+
offset: coordinates2.offset
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
2969
1428
|
}
|
|
2970
1429
|
});
|
|
2971
1430
|
});
|
|
2972
1431
|
}
|
|
2973
1432
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (props.updatedLines !== oldProps.updatedLines || oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2974
1433
|
compositeData.forEach((compositeData2) => {
|
|
2975
|
-
var _a;
|
|
2976
1434
|
compositeData2.operatingStatus = [];
|
|
2977
|
-
|
|
2978
|
-
var _a2, _b;
|
|
1435
|
+
compositeData2.lines?.forEach((line) => {
|
|
2979
1436
|
const lineStatus = linesStatus.get(line.id);
|
|
2980
|
-
if (lineStatus
|
|
2981
|
-
const lineData =
|
|
1437
|
+
if (lineStatus?.operatingStatus !== void 0 && lineStatus.operatingStatus !== "IN_OPERATION") {
|
|
1438
|
+
const lineData = compositeData2.lineMap?.get(line.id);
|
|
2982
1439
|
const coordinatesIcon = props.geoData.labelDisplayPosition(
|
|
2983
1440
|
// @ts-expect-error TODO: manage undefined case
|
|
2984
|
-
lineData
|
|
2985
|
-
lineData
|
|
1441
|
+
lineData?.positions,
|
|
1442
|
+
lineData?.cumulativeDistances,
|
|
2986
1443
|
0.5,
|
|
2987
1444
|
ArrowDirection.NONE,
|
|
2988
1445
|
line.parallelIndex,
|
|
@@ -2994,7 +1451,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
2994
1451
|
line.proximityFactorEnd
|
|
2995
1452
|
);
|
|
2996
1453
|
if (coordinatesIcon !== null) {
|
|
2997
|
-
|
|
1454
|
+
compositeData2.operatingStatus?.push({
|
|
2998
1455
|
status: lineStatus.operatingStatus,
|
|
2999
1456
|
printPosition: [coordinatesIcon.position.longitude, coordinatesIcon.position.latitude],
|
|
3000
1457
|
offset: coordinatesIcon.offset
|
|
@@ -3008,12 +1465,11 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3008
1465
|
//because for LineFlowMode.STATIC_ARROWS and LineFlowMode.ANIMATED_ARROWS it's the same
|
|
3009
1466
|
props.lineFlowMode !== oldProps.lineFlowMode && (props.lineFlowMode === "feeders" || oldProps.lineFlowMode === "feeders"))) {
|
|
3010
1467
|
compositeData.forEach((compositeData2) => {
|
|
3011
|
-
var _a;
|
|
3012
1468
|
const lineMap = compositeData2.lineMap;
|
|
3013
|
-
compositeData2.arrows =
|
|
3014
|
-
const lineData = lineMap
|
|
3015
|
-
line.cumulativeDistances = lineData
|
|
3016
|
-
line.positions = lineData
|
|
1469
|
+
compositeData2.arrows = compositeData2.lines?.flatMap((line) => {
|
|
1470
|
+
const lineData = lineMap?.get(line.id);
|
|
1471
|
+
line.cumulativeDistances = lineData?.cumulativeDistances;
|
|
1472
|
+
line.positions = lineData?.positions;
|
|
3017
1473
|
if (props.lineFlowMode === "feeders") {
|
|
3018
1474
|
return [
|
|
3019
1475
|
{
|
|
@@ -3027,7 +1483,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3027
1483
|
];
|
|
3028
1484
|
}
|
|
3029
1485
|
const directLinePositions = props.geoData.getLinePositions(props.network, line, false);
|
|
3030
|
-
const directLineDistance =
|
|
1486
|
+
const directLineDistance = geolib.getDistance(
|
|
3031
1487
|
{
|
|
3032
1488
|
latitude: directLinePositions[0][1],
|
|
3033
1489
|
longitude: directLinePositions[0][0]
|
|
@@ -3059,7 +1515,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3059
1515
|
recomputeParallelLinesIndex(compositeData, props) {
|
|
3060
1516
|
compositeData.forEach((compositeData2) => {
|
|
3061
1517
|
const mapOriginDestination = compositeData2.mapOriginDestination;
|
|
3062
|
-
mapOriginDestination
|
|
1518
|
+
mapOriginDestination?.forEach((samePathLine, key) => {
|
|
3063
1519
|
let truncatedSize = samePathLine.size;
|
|
3064
1520
|
if (truncatedSize > 32) {
|
|
3065
1521
|
console.warn(
|
|
@@ -3081,24 +1537,23 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3081
1537
|
const mapMinProximityFactor = /* @__PURE__ */ new Map();
|
|
3082
1538
|
compositeData.forEach((compositeData2) => {
|
|
3083
1539
|
compositeData2.lines.forEach((line) => {
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
1540
|
+
const positions = compositeData2.lineMap?.get(line.id)?.positions;
|
|
1541
|
+
if (!positions || positions.length < 2) {
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
const first = positions[0];
|
|
1545
|
+
const last = positions.at(-1);
|
|
1546
|
+
const second = positions[1];
|
|
1547
|
+
const secondToLast = positions.at(-2);
|
|
1548
|
+
line.origin = first;
|
|
1549
|
+
line.end = last;
|
|
3088
1550
|
line.substationIndexStart = this.getVoltageLevelIndex(line.voltageLevelId1);
|
|
3089
1551
|
line.substationIndexEnd = this.getVoltageLevelIndex(line.voltageLevelId2);
|
|
3090
|
-
line.angle = this.computeAngle(props,
|
|
3091
|
-
line.angleStart = this.computeAngle(props,
|
|
3092
|
-
line.angleEnd = this.computeAngle(
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
positions[positions.length - 1]
|
|
3096
|
-
);
|
|
3097
|
-
line.proximityFactorStart = this.getProximityFactor(positions[0], positions[1]);
|
|
3098
|
-
line.proximityFactorEnd = this.getProximityFactor(
|
|
3099
|
-
positions[positions.length - 2],
|
|
3100
|
-
positions[positions.length - 1]
|
|
3101
|
-
);
|
|
1552
|
+
line.angle = this.computeAngle(props, first, last);
|
|
1553
|
+
line.angleStart = this.computeAngle(props, first, second);
|
|
1554
|
+
line.angleEnd = this.computeAngle(props, secondToLast, last);
|
|
1555
|
+
line.proximityFactorStart = this.getProximityFactor(first, second);
|
|
1556
|
+
line.proximityFactorEnd = this.getProximityFactor(secondToLast, last);
|
|
3102
1557
|
const key = this.genLineKey(line);
|
|
3103
1558
|
const val = mapMinProximityFactor.get(key);
|
|
3104
1559
|
if (val == null) {
|
|
@@ -3123,13 +1578,24 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3123
1578
|
);
|
|
3124
1579
|
}
|
|
3125
1580
|
getProximityFactor(firstPosition, secondPosition) {
|
|
3126
|
-
let
|
|
1581
|
+
let dist;
|
|
1582
|
+
if (this.props.coordinateSystem === core.COORDINATE_SYSTEM.CARTESIAN) {
|
|
1583
|
+
dist = Math.hypot(secondPosition[0] - firstPosition[0], secondPosition[1] - firstPosition[1]);
|
|
1584
|
+
} else {
|
|
1585
|
+
dist = geolib.getDistance(firstPosition, secondPosition);
|
|
1586
|
+
}
|
|
1587
|
+
let factor = dist / (3 * this.props.distanceBetweenLines);
|
|
3127
1588
|
if (factor > 1) {
|
|
3128
1589
|
factor = 1;
|
|
3129
1590
|
}
|
|
3130
1591
|
return factor;
|
|
3131
1592
|
}
|
|
3132
1593
|
computeAngle(props, position1, position2) {
|
|
1594
|
+
if (props.coordinateSystem === core.COORDINATE_SYSTEM.CARTESIAN) {
|
|
1595
|
+
const [x1, y1] = position1;
|
|
1596
|
+
const [x2, y2] = position2;
|
|
1597
|
+
return 3 * Math.PI / 2 - Math.atan2(y2 - y1, x2 - x1);
|
|
1598
|
+
}
|
|
3133
1599
|
let angle = props.geoData.getMapAngle(position1, position2);
|
|
3134
1600
|
angle = angle * Math.PI / 180 + Math.PI;
|
|
3135
1601
|
if (angle < 0) {
|
|
@@ -3318,7 +1784,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3318
1784
|
// @ts-expect-error TODO: manage undefined case
|
|
3319
1785
|
getProximityFactor: (line) => line.proximityFactorEnd,
|
|
3320
1786
|
// @ts-expect-error TODO: manage undefined case
|
|
3321
|
-
getLineParallelIndex: (line) => -line.parallelIndex,
|
|
1787
|
+
getLineParallelIndex: (line) => -1 * line.parallelIndex,
|
|
3322
1788
|
// @ts-expect-error TODO: manage undefined case
|
|
3323
1789
|
getLineAngle: (line) => line.angleEnd + Math.PI,
|
|
3324
1790
|
getDistanceBetweenLines: this.props.distanceBetweenLines,
|
|
@@ -3348,7 +1814,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3348
1814
|
this.getSubLayerProps({
|
|
3349
1815
|
id: "ActivePower" + compositeData.nominalV,
|
|
3350
1816
|
data: compositeData.activePower,
|
|
3351
|
-
getText: (activePower) => activePower.p
|
|
1817
|
+
getText: (activePower) => activePower.p === void 0 ? "" : Math.round(activePower.p).toString(),
|
|
3352
1818
|
// The position passed to this layer causes a bug when zooming and maxParallelOffset is reached:
|
|
3353
1819
|
// the label is not correctly positioned on the lines, they are slightly off.
|
|
3354
1820
|
// In the custom layers, we clamp the distanceBetweenLines. This is not done in the deck.gl TextLayer
|
|
@@ -3396,52 +1862,21 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3396
1862
|
});
|
|
3397
1863
|
return layers$1;
|
|
3398
1864
|
}
|
|
3399
|
-
}
|
|
3400
|
-
_LineLayer.layerName = "LineLayer";
|
|
3401
|
-
_LineLayer.defaultProps = {
|
|
3402
|
-
network: void 0,
|
|
3403
|
-
geoData: void 0,
|
|
3404
|
-
getNominalVoltageColor: {
|
|
3405
|
-
type: "accessor",
|
|
3406
|
-
value: () => [255, 255, 255]
|
|
3407
|
-
/*getNominalVoltageColor*/
|
|
3408
|
-
},
|
|
3409
|
-
disconnectedLineColor: { type: "color", value: [255, 255, 255] },
|
|
3410
|
-
filteredNominalVoltages: void 0,
|
|
3411
|
-
lineFlowMode: "feeders",
|
|
3412
|
-
lineFlowColorMode: "nominalVoltage",
|
|
3413
|
-
lineFlowAlertThreshold: 100,
|
|
3414
|
-
showLineFlow: true,
|
|
3415
|
-
lineFullPath: true,
|
|
3416
|
-
lineParallelPath: true,
|
|
3417
|
-
labelSize: 12,
|
|
3418
|
-
iconSize: 48,
|
|
3419
|
-
distanceBetweenLines: 1e3,
|
|
3420
|
-
maxParallelOffset: 100,
|
|
3421
|
-
minParallelOffset: 3,
|
|
3422
|
-
substationRadius: { type: "number", value: SUBSTATION_RADIUS },
|
|
3423
|
-
substationMaxPixel: { type: "number", value: SUBSTATION_RADIUS_MAX_PIXEL },
|
|
3424
|
-
minSubstationRadiusPixel: {
|
|
3425
|
-
type: "number",
|
|
3426
|
-
value: SUBSTATION_RADIUS_MIN_PIXEL
|
|
3427
|
-
},
|
|
3428
|
-
labelColor: [255, 255, 255]
|
|
3429
|
-
};
|
|
3430
|
-
let LineLayer = _LineLayer;
|
|
1865
|
+
}
|
|
3431
1866
|
const elementIdIndexer = (map, element) => map.set(element.id, element);
|
|
3432
1867
|
class MapEquipments {
|
|
1868
|
+
substations = [];
|
|
1869
|
+
substationsById = /* @__PURE__ */ new Map();
|
|
1870
|
+
lines = [];
|
|
1871
|
+
linesById = /* @__PURE__ */ new Map();
|
|
1872
|
+
tieLines = [];
|
|
1873
|
+
tieLinesById = /* @__PURE__ */ new Map();
|
|
1874
|
+
hvdcLines = [];
|
|
1875
|
+
hvdcLinesById = /* @__PURE__ */ new Map();
|
|
1876
|
+
voltageLevels = [];
|
|
1877
|
+
voltageLevelsById = /* @__PURE__ */ new Map();
|
|
1878
|
+
nominalVoltages = [];
|
|
3433
1879
|
constructor() {
|
|
3434
|
-
this.substations = [];
|
|
3435
|
-
this.substationsById = /* @__PURE__ */ new Map();
|
|
3436
|
-
this.lines = [];
|
|
3437
|
-
this.linesById = /* @__PURE__ */ new Map();
|
|
3438
|
-
this.tieLines = [];
|
|
3439
|
-
this.tieLinesById = /* @__PURE__ */ new Map();
|
|
3440
|
-
this.hvdcLines = [];
|
|
3441
|
-
this.hvdcLinesById = /* @__PURE__ */ new Map();
|
|
3442
|
-
this.voltageLevels = [];
|
|
3443
|
-
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3444
|
-
this.nominalVoltages = [];
|
|
3445
1880
|
}
|
|
3446
1881
|
newMapEquipmentForUpdate() {
|
|
3447
1882
|
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
@@ -3451,13 +1886,13 @@ class MapEquipments {
|
|
|
3451
1886
|
}
|
|
3452
1887
|
completeSubstationsInfos(equipmentsToIndex) {
|
|
3453
1888
|
const nominalVoltagesSet = new Set(this.nominalVoltages);
|
|
3454
|
-
if (
|
|
1889
|
+
if (equipmentsToIndex?.length === 0) {
|
|
3455
1890
|
this.substationsById = /* @__PURE__ */ new Map();
|
|
3456
1891
|
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3457
1892
|
}
|
|
3458
|
-
const substations =
|
|
1893
|
+
const substations = equipmentsToIndex?.length > 0 ? equipmentsToIndex : this.substations;
|
|
3459
1894
|
substations.forEach((substation) => {
|
|
3460
|
-
substation.voltageLevels
|
|
1895
|
+
substation.voltageLevels.sort(
|
|
3461
1896
|
(voltageLevel1, voltageLevel2) => voltageLevel1.nominalV - voltageLevel2.nominalV
|
|
3462
1897
|
);
|
|
3463
1898
|
this.substationsById.set(substation.id, substation);
|
|
@@ -3513,23 +1948,21 @@ class MapEquipments {
|
|
|
3513
1948
|
this.completeSubstationsInfos(fullReload ? [] : substations);
|
|
3514
1949
|
}
|
|
3515
1950
|
completeLinesInfos(equipmentsToIndex) {
|
|
3516
|
-
if (
|
|
1951
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3517
1952
|
equipmentsToIndex.forEach((line) => {
|
|
3518
|
-
|
|
3519
|
-
(_a = this.linesById) == null ? void 0 : _a.set(line.id, line);
|
|
1953
|
+
this.linesById?.set(line.id, line);
|
|
3520
1954
|
});
|
|
3521
1955
|
} else {
|
|
3522
|
-
this.linesById = this.lines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1956
|
+
this.linesById = this.lines.reduce((map, line) => elementIdIndexer(map, line), /* @__PURE__ */ new Map());
|
|
3523
1957
|
}
|
|
3524
1958
|
}
|
|
3525
1959
|
completeTieLinesInfos(equipmentsToIndex) {
|
|
3526
|
-
if (
|
|
1960
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3527
1961
|
equipmentsToIndex.forEach((tieLine) => {
|
|
3528
|
-
|
|
3529
|
-
(_a = this.tieLinesById) == null ? void 0 : _a.set(tieLine.id, tieLine);
|
|
1962
|
+
this.tieLinesById?.set(tieLine.id, tieLine);
|
|
3530
1963
|
});
|
|
3531
1964
|
} else {
|
|
3532
|
-
this.tieLinesById = this.tieLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1965
|
+
this.tieLinesById = this.tieLines.reduce((map, tieLine) => elementIdIndexer(map, tieLine), /* @__PURE__ */ new Map());
|
|
3533
1966
|
}
|
|
3534
1967
|
}
|
|
3535
1968
|
updateLines(lines, fullReload) {
|
|
@@ -3554,13 +1987,12 @@ class MapEquipments {
|
|
|
3554
1987
|
this.completeHvdcLinesInfos(fullReload ? [] : hvdcLines);
|
|
3555
1988
|
}
|
|
3556
1989
|
completeHvdcLinesInfos(equipmentsToIndex) {
|
|
3557
|
-
if (
|
|
1990
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3558
1991
|
equipmentsToIndex.forEach((hvdcLine) => {
|
|
3559
|
-
|
|
3560
|
-
(_a = this.hvdcLinesById) == null ? void 0 : _a.set(hvdcLine.id, hvdcLine);
|
|
1992
|
+
this.hvdcLinesById?.set(hvdcLine.id, hvdcLine);
|
|
3561
1993
|
});
|
|
3562
1994
|
} else {
|
|
3563
|
-
this.hvdcLinesById = this.hvdcLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1995
|
+
this.hvdcLinesById = this.hvdcLines.reduce((map, hvdcLine) => elementIdIndexer(map, hvdcLine), /* @__PURE__ */ new Map());
|
|
3564
1996
|
}
|
|
3565
1997
|
}
|
|
3566
1998
|
removeBranchesOfVoltageLevel(branchesList, voltageLevelId) {
|
|
@@ -3571,7 +2003,6 @@ class MapEquipments {
|
|
|
3571
2003
|
return remainingLines;
|
|
3572
2004
|
}
|
|
3573
2005
|
removeEquipment(equipmentType, equipmentId) {
|
|
3574
|
-
var _a, _b;
|
|
3575
2006
|
switch (equipmentType) {
|
|
3576
2007
|
case EQUIPMENT_TYPES.LINE: {
|
|
3577
2008
|
this.lines = this.lines.filter((l) => l.id !== equipmentId);
|
|
@@ -3579,9 +2010,9 @@ class MapEquipments {
|
|
|
3579
2010
|
break;
|
|
3580
2011
|
}
|
|
3581
2012
|
case EQUIPMENT_TYPES.VOLTAGE_LEVEL: {
|
|
3582
|
-
const substationId =
|
|
3583
|
-
let voltageLevelsOfSubstation =
|
|
3584
|
-
voltageLevelsOfSubstation = voltageLevelsOfSubstation
|
|
2013
|
+
const substationId = this.voltageLevelsById.get(equipmentId)?.substationId;
|
|
2014
|
+
let voltageLevelsOfSubstation = this.substationsById.get(substationId)?.voltageLevels;
|
|
2015
|
+
voltageLevelsOfSubstation = voltageLevelsOfSubstation?.filter((l) => l.id !== equipmentId);
|
|
3585
2016
|
const substation = this.substationsById.get(substationId);
|
|
3586
2017
|
if (substation !== void 0) {
|
|
3587
2018
|
substation.voltageLevels = voltageLevelsOfSubstation;
|
|
@@ -3593,7 +2024,7 @@ class MapEquipments {
|
|
|
3593
2024
|
case EQUIPMENT_TYPES.SUBSTATION: {
|
|
3594
2025
|
this.substations = this.substations.filter((l) => l.id !== equipmentId);
|
|
3595
2026
|
const substation = this.substationsById.get(equipmentId);
|
|
3596
|
-
substation
|
|
2027
|
+
substation?.voltageLevels.forEach((vl) => this.removeEquipment(EQUIPMENT_TYPES.VOLTAGE_LEVEL, vl.id));
|
|
3597
2028
|
this.completeSubstationsInfos([substation]);
|
|
3598
2029
|
break;
|
|
3599
2030
|
}
|
|
@@ -3636,22 +2067,26 @@ class MapEquipments {
|
|
|
3636
2067
|
const defaultProps = {
|
|
3637
2068
|
getRadiusMaxPixels: { type: "accessor", value: 1 }
|
|
3638
2069
|
};
|
|
3639
|
-
|
|
2070
|
+
class ScatterplotLayerExt extends layers.ScatterplotLayer {
|
|
2071
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2072
|
+
static layerName = "ScatterplotLayerExt";
|
|
2073
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2074
|
+
static defaultProps = defaultProps;
|
|
3640
2075
|
getShaders() {
|
|
3641
2076
|
const shaders = super.getShaders();
|
|
3642
|
-
return
|
|
3643
|
-
|
|
2077
|
+
return {
|
|
2078
|
+
...shaders,
|
|
2079
|
+
vs: shaders.vs.replace(", scatterplot.radiusMaxPixels", ", instanceRadiusMaxPixels"),
|
|
3644
2080
|
// hack to replace the uniform variable to corresponding attribute
|
|
3645
2081
|
inject: {
|
|
3646
2082
|
"vs:#decl": `in float instanceRadiusMaxPixels;
|
|
3647
2083
|
`
|
|
3648
2084
|
}
|
|
3649
|
-
}
|
|
2085
|
+
};
|
|
3650
2086
|
}
|
|
3651
2087
|
initializeState() {
|
|
3652
|
-
var _a;
|
|
3653
2088
|
super.initializeState();
|
|
3654
|
-
|
|
2089
|
+
this.getAttributeManager()?.addInstanced({
|
|
3655
2090
|
instanceRadiusMaxPixels: {
|
|
3656
2091
|
size: 1,
|
|
3657
2092
|
transition: true,
|
|
@@ -3661,10 +2096,7 @@ const _ScatterplotLayerExt = class _ScatterplotLayerExt extends layers.Scatterpl
|
|
|
3661
2096
|
}
|
|
3662
2097
|
});
|
|
3663
2098
|
}
|
|
3664
|
-
}
|
|
3665
|
-
_ScatterplotLayerExt.layerName = "ScatterplotLayerExt";
|
|
3666
|
-
_ScatterplotLayerExt.defaultProps = defaultProps;
|
|
3667
|
-
let ScatterplotLayerExt = _ScatterplotLayerExt;
|
|
2099
|
+
}
|
|
3668
2100
|
function voltageLevelNominalVoltageIndexer(map, voltageLevel) {
|
|
3669
2101
|
let list = map.get(voltageLevel.nominalV);
|
|
3670
2102
|
if (!list) {
|
|
@@ -3674,7 +2106,19 @@ function voltageLevelNominalVoltageIndexer(map, voltageLevel) {
|
|
|
3674
2106
|
list.push(voltageLevel);
|
|
3675
2107
|
return map;
|
|
3676
2108
|
}
|
|
3677
|
-
|
|
2109
|
+
class SubstationLayer extends core.CompositeLayer {
|
|
2110
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2111
|
+
static layerName = "SubstationLayer";
|
|
2112
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2113
|
+
static defaultProps = {
|
|
2114
|
+
network: void 0,
|
|
2115
|
+
geoData: void 0,
|
|
2116
|
+
getNominalVoltageColor: { type: "accessor", value: () => [255, 255, 255] },
|
|
2117
|
+
filteredNominalVoltages: null,
|
|
2118
|
+
labelsVisible: false,
|
|
2119
|
+
labelColor: { type: "color", value: [255, 255, 255] },
|
|
2120
|
+
labelSize: 12
|
|
2121
|
+
};
|
|
3678
2122
|
initializeState(context) {
|
|
3679
2123
|
super.initializeState(context);
|
|
3680
2124
|
this.state = {
|
|
@@ -3689,7 +2133,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
3689
2133
|
if (props.network != null && props.geoData != null) {
|
|
3690
2134
|
props.data.forEach((substation) => {
|
|
3691
2135
|
const voltageLevelsByNominalVoltage = substation.voltageLevels.reduce(
|
|
3692
|
-
voltageLevelNominalVoltageIndexer,
|
|
2136
|
+
(map, voltageLevel) => voltageLevelNominalVoltageIndexer(map, voltageLevel),
|
|
3693
2137
|
/* @__PURE__ */ new Map()
|
|
3694
2138
|
);
|
|
3695
2139
|
const nominalVoltages = [
|
|
@@ -3717,10 +2161,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
3717
2161
|
let substationsLabels = props.data;
|
|
3718
2162
|
if (props.network != null && props.geoData != null && props.filteredNominalVoltages != null) {
|
|
3719
2163
|
substationsLabels = substationsLabels.filter(
|
|
3720
|
-
(substation) => substation.voltageLevels.
|
|
3721
|
-
var _a;
|
|
3722
|
-
return (_a = props.filteredNominalVoltages) == null ? void 0 : _a.includes(v.nominalV);
|
|
3723
|
-
}) !== void 0
|
|
2164
|
+
(substation) => substation.voltageLevels.some((v) => props.filteredNominalVoltages?.includes(v.nominalV))
|
|
3724
2165
|
);
|
|
3725
2166
|
}
|
|
3726
2167
|
this.setState({ substationsLabels });
|
|
@@ -3769,18 +2210,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
3769
2210
|
layers$1.push(substationLabelsLayer);
|
|
3770
2211
|
return layers$1;
|
|
3771
2212
|
}
|
|
3772
|
-
}
|
|
3773
|
-
_SubstationLayer.layerName = "SubstationLayer";
|
|
3774
|
-
_SubstationLayer.defaultProps = {
|
|
3775
|
-
network: void 0,
|
|
3776
|
-
geoData: void 0,
|
|
3777
|
-
getNominalVoltageColor: { type: "accessor", value: () => [255, 255, 255] },
|
|
3778
|
-
filteredNominalVoltages: null,
|
|
3779
|
-
labelsVisible: false,
|
|
3780
|
-
labelColor: { type: "color", value: [255, 255, 255] },
|
|
3781
|
-
labelSize: 12
|
|
3782
|
-
};
|
|
3783
|
-
let SubstationLayer = _SubstationLayer;
|
|
2213
|
+
}
|
|
3784
2214
|
var Country = /* @__PURE__ */ ((Country2) => {
|
|
3785
2215
|
Country2["AF"] = "AFGHANISTAN";
|
|
3786
2216
|
Country2["AX"] = "ÅLAND ISLANDS";
|