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