@powsybl/network-map-layers 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +647 -0
- package/dist/index.d.ts +647 -0
- package/dist/powsybl-network-map-layers.cjs +4034 -0
- package/dist/powsybl-network-map-layers.js +4034 -0
- package/package.json +57 -0
|
@@ -0,0 +1,4034 @@
|
|
|
1
|
+
import { Layer, project32, picking, CompositeLayer } from "@deck.gl/core";
|
|
2
|
+
import GL from "@luma.gl/constants";
|
|
3
|
+
import { hasFeatures, FEATURES, isWebGL2, Texture2D, Model, Geometry } from "@luma.gl/core";
|
|
4
|
+
import { PathStyleExtension } from "@deck.gl/extensions";
|
|
5
|
+
import { LineLayer as LineLayer$1, PathLayer, TextLayer, IconLayer, ScatterplotLayer } from "@deck.gl/layers";
|
|
6
|
+
var EQUIPMENT_TYPES = /* @__PURE__ */ ((EQUIPMENT_TYPES2) => {
|
|
7
|
+
EQUIPMENT_TYPES2["SUBSTATION"] = "SUBSTATION";
|
|
8
|
+
EQUIPMENT_TYPES2["VOLTAGE_LEVEL"] = "VOLTAGE_LEVEL";
|
|
9
|
+
EQUIPMENT_TYPES2["LINE"] = "LINE";
|
|
10
|
+
EQUIPMENT_TYPES2["TWO_WINDINGS_TRANSFORMER"] = "TWO_WINDINGS_TRANSFORMER";
|
|
11
|
+
EQUIPMENT_TYPES2["THREE_WINDINGS_TRANSFORMER"] = "THREE_WINDINGS_TRANSFORMER";
|
|
12
|
+
EQUIPMENT_TYPES2["HVDC_LINE"] = "HVDC_LINE";
|
|
13
|
+
EQUIPMENT_TYPES2["GENERATOR"] = "GENERATOR";
|
|
14
|
+
EQUIPMENT_TYPES2["BATTERY"] = "BATTERY";
|
|
15
|
+
EQUIPMENT_TYPES2["LOAD"] = "LOAD";
|
|
16
|
+
EQUIPMENT_TYPES2["SHUNT_COMPENSATOR"] = "SHUNT_COMPENSATOR";
|
|
17
|
+
EQUIPMENT_TYPES2["TIE_LINE"] = "TIE_LINE";
|
|
18
|
+
EQUIPMENT_TYPES2["DANGLING_LINE"] = "DANGLING_LINE";
|
|
19
|
+
EQUIPMENT_TYPES2["STATIC_VAR_COMPENSATOR"] = "STATIC_VAR_COMPENSATOR";
|
|
20
|
+
EQUIPMENT_TYPES2["HVDC_CONVERTER_STATION"] = "HVDC_CONVERTER_STATION";
|
|
21
|
+
EQUIPMENT_TYPES2["VSC_CONVERTER_STATION"] = "VSC_CONVERTER_STATION";
|
|
22
|
+
EQUIPMENT_TYPES2["LCC_CONVERTER_STATION"] = "LCC_CONVERTER_STATION";
|
|
23
|
+
EQUIPMENT_TYPES2["SWITCH"] = "SWITCH";
|
|
24
|
+
return EQUIPMENT_TYPES2;
|
|
25
|
+
})(EQUIPMENT_TYPES || {});
|
|
26
|
+
const factors = {
|
|
27
|
+
kilometers: 1,
|
|
28
|
+
miles: 1e3 / 1609.344,
|
|
29
|
+
nauticalmiles: 1e3 / 1852,
|
|
30
|
+
meters: 1e3,
|
|
31
|
+
metres: 1e3,
|
|
32
|
+
yards: 1e3 / 0.9144,
|
|
33
|
+
feet: 1e3 / 0.3048,
|
|
34
|
+
inches: 1e3 / 0.0254
|
|
35
|
+
};
|
|
36
|
+
const RE = 6378.137;
|
|
37
|
+
const FE = 1 / 298.257223563;
|
|
38
|
+
const E2 = FE * (2 - FE);
|
|
39
|
+
const RAD = Math.PI / 180;
|
|
40
|
+
class CheapRuler {
|
|
41
|
+
/**
|
|
42
|
+
* Creates a ruler object from tile coordinates (y and z).
|
|
43
|
+
*
|
|
44
|
+
* @param {number} y
|
|
45
|
+
* @param {number} z
|
|
46
|
+
* @param {keyof typeof factors} [units='kilometers']
|
|
47
|
+
* @returns {CheapRuler}
|
|
48
|
+
* @example
|
|
49
|
+
* const ruler = cheapRuler.fromTile(1567, 12);
|
|
50
|
+
* //=ruler
|
|
51
|
+
*/
|
|
52
|
+
static fromTile(y, z, units) {
|
|
53
|
+
const n = Math.PI * (1 - 2 * (y + 0.5) / Math.pow(2, z));
|
|
54
|
+
const lat = Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) / RAD;
|
|
55
|
+
return new CheapRuler(lat, units);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Multipliers for converting between units.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // convert 50 meters to yards
|
|
62
|
+
* 50 * CheapRuler.units.yards / CheapRuler.units.meters;
|
|
63
|
+
*/
|
|
64
|
+
static get units() {
|
|
65
|
+
return factors;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
|
|
69
|
+
*
|
|
70
|
+
* @param {number} lat latitude
|
|
71
|
+
* @param {keyof typeof factors} [units='kilometers']
|
|
72
|
+
* @example
|
|
73
|
+
* const ruler = cheapRuler(35.05, 'miles');
|
|
74
|
+
* //=ruler
|
|
75
|
+
*/
|
|
76
|
+
constructor(lat, units) {
|
|
77
|
+
if (lat === void 0) throw new Error("No latitude given.");
|
|
78
|
+
if (units && !factors[units]) throw new Error(`Unknown unit ${units}. Use one of: ${Object.keys(factors).join(", ")}`);
|
|
79
|
+
const m = RAD * RE * (units ? factors[units] : 1);
|
|
80
|
+
const coslat = Math.cos(lat * RAD);
|
|
81
|
+
const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
|
|
82
|
+
const w = Math.sqrt(w2);
|
|
83
|
+
this.kx = m * w * coslat;
|
|
84
|
+
this.ky = m * w * w2 * (1 - E2);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Given two points of the form [longitude, latitude], returns the distance.
|
|
88
|
+
*
|
|
89
|
+
* @param {[number, number]} a point [longitude, latitude]
|
|
90
|
+
* @param {[number, number]} b point [longitude, latitude]
|
|
91
|
+
* @returns {number} distance
|
|
92
|
+
* @example
|
|
93
|
+
* const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
|
|
94
|
+
* //=distance
|
|
95
|
+
*/
|
|
96
|
+
distance(a, b) {
|
|
97
|
+
const dx = wrap(a[0] - b[0]) * this.kx;
|
|
98
|
+
const dy = (a[1] - b[1]) * this.ky;
|
|
99
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the bearing between two points in angles.
|
|
103
|
+
*
|
|
104
|
+
* @param {[number, number]} a point [longitude, latitude]
|
|
105
|
+
* @param {[number, number]} b point [longitude, latitude]
|
|
106
|
+
* @returns {number} bearing
|
|
107
|
+
* @example
|
|
108
|
+
* const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
|
|
109
|
+
* //=bearing
|
|
110
|
+
*/
|
|
111
|
+
bearing(a, b) {
|
|
112
|
+
const dx = wrap(b[0] - a[0]) * this.kx;
|
|
113
|
+
const dy = (b[1] - a[1]) * this.ky;
|
|
114
|
+
return Math.atan2(dx, dy) / RAD;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns a new point given distance and bearing from the starting point.
|
|
118
|
+
*
|
|
119
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
120
|
+
* @param {number} dist distance
|
|
121
|
+
* @param {number} bearing
|
|
122
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
123
|
+
* @example
|
|
124
|
+
* const point = ruler.destination([30.5, 50.5], 0.1, 90);
|
|
125
|
+
* //=point
|
|
126
|
+
*/
|
|
127
|
+
destination(p, dist, bearing) {
|
|
128
|
+
const a = bearing * RAD;
|
|
129
|
+
return this.offset(
|
|
130
|
+
p,
|
|
131
|
+
Math.sin(a) * dist,
|
|
132
|
+
Math.cos(a) * dist
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a new point given easting and northing offsets (in ruler units) from the starting point.
|
|
137
|
+
*
|
|
138
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
139
|
+
* @param {number} dx easting
|
|
140
|
+
* @param {number} dy northing
|
|
141
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
142
|
+
* @example
|
|
143
|
+
* const point = ruler.offset([30.5, 50.5], 10, 10);
|
|
144
|
+
* //=point
|
|
145
|
+
*/
|
|
146
|
+
offset(p, dx, dy) {
|
|
147
|
+
return [
|
|
148
|
+
p[0] + dx / this.kx,
|
|
149
|
+
p[1] + dy / this.ky
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Given a line (an array of points), returns the total line distance.
|
|
154
|
+
*
|
|
155
|
+
* @param {[number, number][]} points [longitude, latitude]
|
|
156
|
+
* @returns {number} total line distance
|
|
157
|
+
* @example
|
|
158
|
+
* const length = ruler.lineDistance([
|
|
159
|
+
* [-67.031, 50.458], [-67.031, 50.534],
|
|
160
|
+
* [-66.929, 50.534], [-66.929, 50.458]
|
|
161
|
+
* ]);
|
|
162
|
+
* //=length
|
|
163
|
+
*/
|
|
164
|
+
lineDistance(points) {
|
|
165
|
+
let total = 0;
|
|
166
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
167
|
+
total += this.distance(points[i], points[i + 1]);
|
|
168
|
+
}
|
|
169
|
+
return total;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Given a polygon (an array of rings, where each ring is an array of points), returns the area.
|
|
173
|
+
*
|
|
174
|
+
* @param {[number, number][][]} polygon
|
|
175
|
+
* @returns {number} area value in the specified units (square kilometers by default)
|
|
176
|
+
* @example
|
|
177
|
+
* const area = ruler.area([[
|
|
178
|
+
* [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
|
|
179
|
+
* [-66.929, 50.458], [-67.031, 50.458]
|
|
180
|
+
* ]]);
|
|
181
|
+
* //=area
|
|
182
|
+
*/
|
|
183
|
+
area(polygon) {
|
|
184
|
+
let sum = 0;
|
|
185
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
186
|
+
const ring = polygon[i];
|
|
187
|
+
for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
|
|
188
|
+
sum += wrap(ring[j][0] - ring[k][0]) * (ring[j][1] + ring[k][1]) * (i ? -1 : 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return Math.abs(sum) / 2 * this.kx * this.ky;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns the point at a specified distance along the line.
|
|
195
|
+
*
|
|
196
|
+
* @param {[number, number][]} line
|
|
197
|
+
* @param {number} dist distance
|
|
198
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
199
|
+
* @example
|
|
200
|
+
* const point = ruler.along(line, 2.5);
|
|
201
|
+
* //=point
|
|
202
|
+
*/
|
|
203
|
+
along(line, dist) {
|
|
204
|
+
let sum = 0;
|
|
205
|
+
if (dist <= 0) return line[0];
|
|
206
|
+
for (let i = 0; i < line.length - 1; i++) {
|
|
207
|
+
const p0 = line[i];
|
|
208
|
+
const p1 = line[i + 1];
|
|
209
|
+
const d = this.distance(p0, p1);
|
|
210
|
+
sum += d;
|
|
211
|
+
if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
|
|
212
|
+
}
|
|
213
|
+
return line[line.length - 1];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns the distance from a point `p` to a line segment `a` to `b`.
|
|
217
|
+
*
|
|
218
|
+
* @pointToSegmentDistance
|
|
219
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
220
|
+
* @param {[number, number]} a segment point 1 [longitude, latitude]
|
|
221
|
+
* @param {[number, number]} b segment point 2 [longitude, latitude]
|
|
222
|
+
* @returns {number} distance
|
|
223
|
+
* @example
|
|
224
|
+
* const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
|
|
225
|
+
* //=distance
|
|
226
|
+
*/
|
|
227
|
+
pointToSegmentDistance(p, a, b) {
|
|
228
|
+
let [x, y] = a;
|
|
229
|
+
let dx = wrap(b[0] - x) * this.kx;
|
|
230
|
+
let dy = (b[1] - y) * this.ky;
|
|
231
|
+
if (dx !== 0 || dy !== 0) {
|
|
232
|
+
const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
233
|
+
if (t > 1) {
|
|
234
|
+
x = b[0];
|
|
235
|
+
y = b[1];
|
|
236
|
+
} else if (t > 0) {
|
|
237
|
+
x += dx / this.kx * t;
|
|
238
|
+
y += dy / this.ky * t;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
dx = wrap(p[0] - x) * this.kx;
|
|
242
|
+
dy = (p[1] - y) * this.ky;
|
|
243
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Returns an object of the form {point, index, t}, where point is closest point on the line
|
|
247
|
+
* from the given point, index is the start index of the segment with the closest point,
|
|
248
|
+
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
|
|
249
|
+
*
|
|
250
|
+
* @param {[number, number][]} line
|
|
251
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
252
|
+
* @returns {{point: [number, number], index: number, t: number}} {point, index, t}
|
|
253
|
+
* @example
|
|
254
|
+
* const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
|
|
255
|
+
* //=point
|
|
256
|
+
*/
|
|
257
|
+
pointOnLine(line, p) {
|
|
258
|
+
let minDist = Infinity;
|
|
259
|
+
let minX = line[0][0];
|
|
260
|
+
let minY = line[0][1];
|
|
261
|
+
let minI = 0;
|
|
262
|
+
let minT = 0;
|
|
263
|
+
for (let i = 0; i < line.length - 1; i++) {
|
|
264
|
+
let x = line[i][0];
|
|
265
|
+
let y = line[i][1];
|
|
266
|
+
let dx = wrap(line[i + 1][0] - x) * this.kx;
|
|
267
|
+
let dy = (line[i + 1][1] - y) * this.ky;
|
|
268
|
+
let t = 0;
|
|
269
|
+
if (dx !== 0 || dy !== 0) {
|
|
270
|
+
t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
271
|
+
if (t > 1) {
|
|
272
|
+
x = line[i + 1][0];
|
|
273
|
+
y = line[i + 1][1];
|
|
274
|
+
} else if (t > 0) {
|
|
275
|
+
x += dx / this.kx * t;
|
|
276
|
+
y += dy / this.ky * t;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
dx = wrap(p[0] - x) * this.kx;
|
|
280
|
+
dy = (p[1] - y) * this.ky;
|
|
281
|
+
const sqDist = dx * dx + dy * dy;
|
|
282
|
+
if (sqDist < minDist) {
|
|
283
|
+
minDist = sqDist;
|
|
284
|
+
minX = x;
|
|
285
|
+
minY = y;
|
|
286
|
+
minI = i;
|
|
287
|
+
minT = t;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
point: [minX, minY],
|
|
292
|
+
index: minI,
|
|
293
|
+
t: Math.max(0, Math.min(1, minT))
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Returns a part of the given line between the start and the stop points (or their closest points on the line).
|
|
298
|
+
*
|
|
299
|
+
* @param {[number, number]} start point [longitude, latitude]
|
|
300
|
+
* @param {[number, number]} stop point [longitude, latitude]
|
|
301
|
+
* @param {[number, number][]} line
|
|
302
|
+
* @returns {[number, number][]} line part of a line
|
|
303
|
+
* @example
|
|
304
|
+
* const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
|
|
305
|
+
* //=line2
|
|
306
|
+
*/
|
|
307
|
+
lineSlice(start, stop, line) {
|
|
308
|
+
let p1 = this.pointOnLine(line, start);
|
|
309
|
+
let p2 = this.pointOnLine(line, stop);
|
|
310
|
+
if (p1.index > p2.index || p1.index === p2.index && p1.t > p2.t) {
|
|
311
|
+
const tmp = p1;
|
|
312
|
+
p1 = p2;
|
|
313
|
+
p2 = tmp;
|
|
314
|
+
}
|
|
315
|
+
const slice = [p1.point];
|
|
316
|
+
const l = p1.index + 1;
|
|
317
|
+
const r = p2.index;
|
|
318
|
+
if (!equals(line[l], slice[0]) && l <= r)
|
|
319
|
+
slice.push(line[l]);
|
|
320
|
+
for (let i = l + 1; i <= r; i++) {
|
|
321
|
+
slice.push(line[i]);
|
|
322
|
+
}
|
|
323
|
+
if (!equals(line[r], p2.point))
|
|
324
|
+
slice.push(p2.point);
|
|
325
|
+
return slice;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
|
|
329
|
+
*
|
|
330
|
+
* @param {number} start start distance
|
|
331
|
+
* @param {number} stop stop distance
|
|
332
|
+
* @param {[number, number][]} line
|
|
333
|
+
* @returns {[number, number][]} part of a line
|
|
334
|
+
* @example
|
|
335
|
+
* const line2 = ruler.lineSliceAlong(10, 20, line1);
|
|
336
|
+
* //=line2
|
|
337
|
+
*/
|
|
338
|
+
lineSliceAlong(start, stop, line) {
|
|
339
|
+
let sum = 0;
|
|
340
|
+
const slice = [];
|
|
341
|
+
for (let i = 0; i < line.length - 1; i++) {
|
|
342
|
+
const p0 = line[i];
|
|
343
|
+
const p1 = line[i + 1];
|
|
344
|
+
const d = this.distance(p0, p1);
|
|
345
|
+
sum += d;
|
|
346
|
+
if (sum > start && slice.length === 0) {
|
|
347
|
+
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
|
|
348
|
+
}
|
|
349
|
+
if (sum >= stop) {
|
|
350
|
+
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
|
|
351
|
+
return slice;
|
|
352
|
+
}
|
|
353
|
+
if (sum > start) slice.push(p1);
|
|
354
|
+
}
|
|
355
|
+
return slice;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
|
|
359
|
+
*
|
|
360
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
361
|
+
* @param {number} buffer
|
|
362
|
+
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
363
|
+
* @example
|
|
364
|
+
* const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
|
|
365
|
+
* //=bbox
|
|
366
|
+
*/
|
|
367
|
+
bufferPoint(p, buffer) {
|
|
368
|
+
const v = buffer / this.ky;
|
|
369
|
+
const h = buffer / this.kx;
|
|
370
|
+
return [
|
|
371
|
+
p[0] - h,
|
|
372
|
+
p[1] - v,
|
|
373
|
+
p[0] + h,
|
|
374
|
+
p[1] + v
|
|
375
|
+
];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Given a bounding box, returns the box buffered by a given distance.
|
|
379
|
+
*
|
|
380
|
+
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
381
|
+
* @param {number} buffer
|
|
382
|
+
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
383
|
+
* @example
|
|
384
|
+
* const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
|
|
385
|
+
* //=bbox
|
|
386
|
+
*/
|
|
387
|
+
bufferBBox(bbox, buffer) {
|
|
388
|
+
const v = buffer / this.ky;
|
|
389
|
+
const h = buffer / this.kx;
|
|
390
|
+
return [
|
|
391
|
+
bbox[0] - h,
|
|
392
|
+
bbox[1] - v,
|
|
393
|
+
bbox[2] + h,
|
|
394
|
+
bbox[3] + v
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Returns true if the given point is inside in the given bounding box, otherwise false.
|
|
399
|
+
*
|
|
400
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
401
|
+
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
402
|
+
* @returns {boolean}
|
|
403
|
+
* @example
|
|
404
|
+
* const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
|
|
405
|
+
* //=inside
|
|
406
|
+
*/
|
|
407
|
+
insideBBox(p, bbox) {
|
|
408
|
+
return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function equals(a, b) {
|
|
412
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
413
|
+
}
|
|
414
|
+
function interpolate(a, b, t) {
|
|
415
|
+
const dx = wrap(b[0] - a[0]);
|
|
416
|
+
const dy = b[1] - a[1];
|
|
417
|
+
return [
|
|
418
|
+
a[0] + dx * t,
|
|
419
|
+
a[1] + dy * t
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
function wrap(deg) {
|
|
423
|
+
while (deg < -180) deg += 360;
|
|
424
|
+
while (deg > 180) deg -= 360;
|
|
425
|
+
return deg;
|
|
426
|
+
}
|
|
427
|
+
var es = {};
|
|
428
|
+
var computeDestinationPoint$1 = {};
|
|
429
|
+
var getLatitude$1 = {};
|
|
430
|
+
var constants = {};
|
|
431
|
+
Object.defineProperty(constants, "__esModule", { value: true });
|
|
432
|
+
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;
|
|
433
|
+
var sexagesimalPattern = /^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}(\.([0-9]{1,}))?)["″]\s*)?([NEOSW]?)$/;
|
|
434
|
+
constants.sexagesimalPattern = sexagesimalPattern;
|
|
435
|
+
var earthRadius = 6378137;
|
|
436
|
+
constants.earthRadius = earthRadius;
|
|
437
|
+
var MINLAT = -90;
|
|
438
|
+
constants.MINLAT = MINLAT;
|
|
439
|
+
var MAXLAT = 90;
|
|
440
|
+
constants.MAXLAT = MAXLAT;
|
|
441
|
+
var MINLON = -180;
|
|
442
|
+
constants.MINLON = MINLON;
|
|
443
|
+
var MAXLON = 180;
|
|
444
|
+
constants.MAXLON = MAXLON;
|
|
445
|
+
var longitudeKeys = ["lng", "lon", "longitude", 0];
|
|
446
|
+
constants.longitudeKeys = longitudeKeys;
|
|
447
|
+
var latitudeKeys = ["lat", "latitude", 1];
|
|
448
|
+
constants.latitudeKeys = latitudeKeys;
|
|
449
|
+
var altitudeKeys = ["alt", "altitude", "elevation", "elev", 2];
|
|
450
|
+
constants.altitudeKeys = altitudeKeys;
|
|
451
|
+
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 };
|
|
452
|
+
constants.distanceConversion = distanceConversion;
|
|
453
|
+
var timeConversion = { m: 60, h: 3600, d: 86400 };
|
|
454
|
+
constants.timeConversion = timeConversion;
|
|
455
|
+
var areaConversion = { m2: 1, km2: 1e-6, ha: 1e-4, a: 0.01, ft2: 10.763911, yd2: 1.19599, in2: 1550.0031 };
|
|
456
|
+
constants.areaConversion = areaConversion;
|
|
457
|
+
areaConversion.sqm = areaConversion.m2;
|
|
458
|
+
areaConversion.sqkm = areaConversion.km2;
|
|
459
|
+
areaConversion.sqft = areaConversion.ft2;
|
|
460
|
+
areaConversion.sqyd = areaConversion.yd2;
|
|
461
|
+
areaConversion.sqin = areaConversion.in2;
|
|
462
|
+
var getCoordinateKey$1 = {};
|
|
463
|
+
Object.defineProperty(getCoordinateKey$1, "__esModule", { value: true });
|
|
464
|
+
getCoordinateKey$1.default = void 0;
|
|
465
|
+
var getCoordinateKey = function getCoordinateKey2(point, keysToLookup) {
|
|
466
|
+
return keysToLookup.reduce(function(foundKey, key) {
|
|
467
|
+
if (typeof point === "undefined" || point === null) {
|
|
468
|
+
throw new Error("'".concat(point, "' is no valid coordinate."));
|
|
469
|
+
}
|
|
470
|
+
if (Object.prototype.hasOwnProperty.call(point, key) && typeof key !== "undefined" && typeof foundKey === "undefined") {
|
|
471
|
+
foundKey = key;
|
|
472
|
+
return key;
|
|
473
|
+
}
|
|
474
|
+
return foundKey;
|
|
475
|
+
}, void 0);
|
|
476
|
+
};
|
|
477
|
+
var _default$D = getCoordinateKey;
|
|
478
|
+
getCoordinateKey$1.default = _default$D;
|
|
479
|
+
var toDecimal$1 = {};
|
|
480
|
+
var isDecimal$1 = {};
|
|
481
|
+
Object.defineProperty(isDecimal$1, "__esModule", { value: true });
|
|
482
|
+
isDecimal$1.default = void 0;
|
|
483
|
+
var isDecimal = function isDecimal2(value) {
|
|
484
|
+
var checkedValue = value.toString().trim();
|
|
485
|
+
if (isNaN(parseFloat(checkedValue))) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
return parseFloat(checkedValue) === Number(checkedValue);
|
|
489
|
+
};
|
|
490
|
+
var _default$C = isDecimal;
|
|
491
|
+
isDecimal$1.default = _default$C;
|
|
492
|
+
var isSexagesimal$1 = {};
|
|
493
|
+
Object.defineProperty(isSexagesimal$1, "__esModule", { value: true });
|
|
494
|
+
isSexagesimal$1.default = void 0;
|
|
495
|
+
var _constants$e = constants;
|
|
496
|
+
var isSexagesimal = function isSexagesimal2(value) {
|
|
497
|
+
return _constants$e.sexagesimalPattern.test(value.toString().trim());
|
|
498
|
+
};
|
|
499
|
+
var _default$B = isSexagesimal;
|
|
500
|
+
isSexagesimal$1.default = _default$B;
|
|
501
|
+
var sexagesimalToDecimal$1 = {};
|
|
502
|
+
Object.defineProperty(sexagesimalToDecimal$1, "__esModule", { value: true });
|
|
503
|
+
sexagesimalToDecimal$1.default = void 0;
|
|
504
|
+
var _constants$d = constants;
|
|
505
|
+
var sexagesimalToDecimal = function sexagesimalToDecimal2(sexagesimal) {
|
|
506
|
+
var data = new RegExp(_constants$d.sexagesimalPattern).exec(sexagesimal.toString().trim());
|
|
507
|
+
if (typeof data === "undefined" || data === null) {
|
|
508
|
+
throw new Error("Given value is not in sexagesimal format");
|
|
509
|
+
}
|
|
510
|
+
var min = Number(data[2]) / 60 || 0;
|
|
511
|
+
var sec = Number(data[4]) / 3600 || 0;
|
|
512
|
+
var decimal = parseFloat(data[1]) + min + sec;
|
|
513
|
+
return ["S", "W"].includes(data[7]) ? -decimal : decimal;
|
|
514
|
+
};
|
|
515
|
+
var _default$A = sexagesimalToDecimal;
|
|
516
|
+
sexagesimalToDecimal$1.default = _default$A;
|
|
517
|
+
var isValidCoordinate$1 = {};
|
|
518
|
+
var getCoordinateKeys$1 = {};
|
|
519
|
+
Object.defineProperty(getCoordinateKeys$1, "__esModule", { value: true });
|
|
520
|
+
getCoordinateKeys$1.default = void 0;
|
|
521
|
+
var _constants$c = constants;
|
|
522
|
+
var _getCoordinateKey$2 = _interopRequireDefault$q(getCoordinateKey$1);
|
|
523
|
+
function _interopRequireDefault$q(obj) {
|
|
524
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
525
|
+
}
|
|
526
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
527
|
+
var keys = Object.keys(object);
|
|
528
|
+
if (Object.getOwnPropertySymbols) {
|
|
529
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
530
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
531
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
532
|
+
});
|
|
533
|
+
keys.push.apply(keys, symbols);
|
|
534
|
+
}
|
|
535
|
+
return keys;
|
|
536
|
+
}
|
|
537
|
+
function _objectSpread$1(target) {
|
|
538
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
539
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
540
|
+
if (i % 2) {
|
|
541
|
+
ownKeys$1(Object(source), true).forEach(function(key) {
|
|
542
|
+
_defineProperty$1(target, key, source[key]);
|
|
543
|
+
});
|
|
544
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
545
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
546
|
+
} else {
|
|
547
|
+
ownKeys$1(Object(source)).forEach(function(key) {
|
|
548
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return target;
|
|
553
|
+
}
|
|
554
|
+
function _defineProperty$1(obj, key, value) {
|
|
555
|
+
if (key in obj) {
|
|
556
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
557
|
+
} else {
|
|
558
|
+
obj[key] = value;
|
|
559
|
+
}
|
|
560
|
+
return obj;
|
|
561
|
+
}
|
|
562
|
+
var getCoordinateKeys = function getCoordinateKeys2(point) {
|
|
563
|
+
var keysToLookup = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { longitude: _constants$c.longitudeKeys, latitude: _constants$c.latitudeKeys, altitude: _constants$c.altitudeKeys };
|
|
564
|
+
var longitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.longitude);
|
|
565
|
+
var latitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.latitude);
|
|
566
|
+
var altitude = (0, _getCoordinateKey$2.default)(point, keysToLookup.altitude);
|
|
567
|
+
return _objectSpread$1({ latitude, longitude }, altitude ? { altitude } : {});
|
|
568
|
+
};
|
|
569
|
+
var _default$z = getCoordinateKeys;
|
|
570
|
+
getCoordinateKeys$1.default = _default$z;
|
|
571
|
+
var isValidLatitude$1 = {};
|
|
572
|
+
Object.defineProperty(isValidLatitude$1, "__esModule", { value: true });
|
|
573
|
+
isValidLatitude$1.default = void 0;
|
|
574
|
+
var _isDecimal$2 = _interopRequireDefault$p(isDecimal$1);
|
|
575
|
+
var _isSexagesimal$2 = _interopRequireDefault$p(isSexagesimal$1);
|
|
576
|
+
var _sexagesimalToDecimal$2 = _interopRequireDefault$p(sexagesimalToDecimal$1);
|
|
577
|
+
var _constants$b = constants;
|
|
578
|
+
function _interopRequireDefault$p(obj) {
|
|
579
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
580
|
+
}
|
|
581
|
+
var isValidLatitude = function isValidLatitude2(value) {
|
|
582
|
+
if ((0, _isDecimal$2.default)(value)) {
|
|
583
|
+
if (parseFloat(value) > _constants$b.MAXLAT || value < _constants$b.MINLAT) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
if ((0, _isSexagesimal$2.default)(value)) {
|
|
589
|
+
return isValidLatitude2((0, _sexagesimalToDecimal$2.default)(value));
|
|
590
|
+
}
|
|
591
|
+
return false;
|
|
592
|
+
};
|
|
593
|
+
var _default$y = isValidLatitude;
|
|
594
|
+
isValidLatitude$1.default = _default$y;
|
|
595
|
+
var isValidLongitude$1 = {};
|
|
596
|
+
Object.defineProperty(isValidLongitude$1, "__esModule", { value: true });
|
|
597
|
+
isValidLongitude$1.default = void 0;
|
|
598
|
+
var _isDecimal$1 = _interopRequireDefault$o(isDecimal$1);
|
|
599
|
+
var _isSexagesimal$1 = _interopRequireDefault$o(isSexagesimal$1);
|
|
600
|
+
var _sexagesimalToDecimal$1 = _interopRequireDefault$o(sexagesimalToDecimal$1);
|
|
601
|
+
var _constants$a = constants;
|
|
602
|
+
function _interopRequireDefault$o(obj) {
|
|
603
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
604
|
+
}
|
|
605
|
+
var isValidLongitude = function isValidLongitude2(value) {
|
|
606
|
+
if ((0, _isDecimal$1.default)(value)) {
|
|
607
|
+
if (parseFloat(value) > _constants$a.MAXLON || value < _constants$a.MINLON) {
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
if ((0, _isSexagesimal$1.default)(value)) {
|
|
613
|
+
return isValidLongitude2((0, _sexagesimalToDecimal$1.default)(value));
|
|
614
|
+
}
|
|
615
|
+
return false;
|
|
616
|
+
};
|
|
617
|
+
var _default$x = isValidLongitude;
|
|
618
|
+
isValidLongitude$1.default = _default$x;
|
|
619
|
+
Object.defineProperty(isValidCoordinate$1, "__esModule", { value: true });
|
|
620
|
+
isValidCoordinate$1.default = void 0;
|
|
621
|
+
var _getCoordinateKeys2 = _interopRequireDefault$n(getCoordinateKeys$1);
|
|
622
|
+
var _isValidLatitude = _interopRequireDefault$n(isValidLatitude$1);
|
|
623
|
+
var _isValidLongitude = _interopRequireDefault$n(isValidLongitude$1);
|
|
624
|
+
function _interopRequireDefault$n(obj) {
|
|
625
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
626
|
+
}
|
|
627
|
+
var isValidCoordinate = function isValidCoordinate2(point) {
|
|
628
|
+
var _getCoordinateKeys3 = (0, _getCoordinateKeys2.default)(point), latitude = _getCoordinateKeys3.latitude, longitude = _getCoordinateKeys3.longitude;
|
|
629
|
+
if (Array.isArray(point) && point.length >= 2) {
|
|
630
|
+
return (0, _isValidLongitude.default)(point[0]) && (0, _isValidLatitude.default)(point[1]);
|
|
631
|
+
}
|
|
632
|
+
if (typeof latitude === "undefined" || typeof longitude === "undefined") {
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
var lon = point[longitude];
|
|
636
|
+
var lat = point[latitude];
|
|
637
|
+
if (typeof lat === "undefined" || typeof lon === "undefined") {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
if ((0, _isValidLatitude.default)(lat) === false || (0, _isValidLongitude.default)(lon) === false) {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
return true;
|
|
644
|
+
};
|
|
645
|
+
var _default$w = isValidCoordinate;
|
|
646
|
+
isValidCoordinate$1.default = _default$w;
|
|
647
|
+
Object.defineProperty(toDecimal$1, "__esModule", { value: true });
|
|
648
|
+
toDecimal$1.default = void 0;
|
|
649
|
+
var _isDecimal = _interopRequireDefault$m(isDecimal$1);
|
|
650
|
+
var _isSexagesimal = _interopRequireDefault$m(isSexagesimal$1);
|
|
651
|
+
var _sexagesimalToDecimal = _interopRequireDefault$m(sexagesimalToDecimal$1);
|
|
652
|
+
var _isValidCoordinate = _interopRequireDefault$m(isValidCoordinate$1);
|
|
653
|
+
var _getCoordinateKeys = _interopRequireDefault$m(getCoordinateKeys$1);
|
|
654
|
+
function _interopRequireDefault$m(obj) {
|
|
655
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
656
|
+
}
|
|
657
|
+
function ownKeys(object, enumerableOnly) {
|
|
658
|
+
var keys = Object.keys(object);
|
|
659
|
+
if (Object.getOwnPropertySymbols) {
|
|
660
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
661
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
662
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
663
|
+
});
|
|
664
|
+
keys.push.apply(keys, symbols);
|
|
665
|
+
}
|
|
666
|
+
return keys;
|
|
667
|
+
}
|
|
668
|
+
function _objectSpread(target) {
|
|
669
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
670
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
671
|
+
if (i % 2) {
|
|
672
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
673
|
+
_defineProperty(target, key, source[key]);
|
|
674
|
+
});
|
|
675
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
676
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
677
|
+
} else {
|
|
678
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
679
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return target;
|
|
684
|
+
}
|
|
685
|
+
function _defineProperty(obj, key, value) {
|
|
686
|
+
if (key in obj) {
|
|
687
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
688
|
+
} else {
|
|
689
|
+
obj[key] = value;
|
|
690
|
+
}
|
|
691
|
+
return obj;
|
|
692
|
+
}
|
|
693
|
+
var toDecimal = function toDecimal2(value) {
|
|
694
|
+
if ((0, _isDecimal.default)(value)) {
|
|
695
|
+
return Number(value);
|
|
696
|
+
}
|
|
697
|
+
if ((0, _isSexagesimal.default)(value)) {
|
|
698
|
+
return (0, _sexagesimalToDecimal.default)(value);
|
|
699
|
+
}
|
|
700
|
+
if ((0, _isValidCoordinate.default)(value)) {
|
|
701
|
+
var keys = (0, _getCoordinateKeys.default)(value);
|
|
702
|
+
if (Array.isArray(value)) {
|
|
703
|
+
return value.map(function(v, index) {
|
|
704
|
+
return [0, 1].includes(index) ? toDecimal2(v) : v;
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
return _objectSpread(_objectSpread(_objectSpread({}, value), keys.latitude && _defineProperty({}, keys.latitude, toDecimal2(value[keys.latitude]))), keys.longitude && _defineProperty({}, keys.longitude, toDecimal2(value[keys.longitude])));
|
|
708
|
+
}
|
|
709
|
+
if (Array.isArray(value)) {
|
|
710
|
+
return value.map(function(point) {
|
|
711
|
+
return (0, _isValidCoordinate.default)(point) ? toDecimal2(point) : point;
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
return value;
|
|
715
|
+
};
|
|
716
|
+
var _default$v = toDecimal;
|
|
717
|
+
toDecimal$1.default = _default$v;
|
|
718
|
+
Object.defineProperty(getLatitude$1, "__esModule", { value: true });
|
|
719
|
+
getLatitude$1.default = void 0;
|
|
720
|
+
var _constants$9 = constants;
|
|
721
|
+
var _getCoordinateKey$1 = _interopRequireDefault$l(getCoordinateKey$1);
|
|
722
|
+
var _toDecimal$1 = _interopRequireDefault$l(toDecimal$1);
|
|
723
|
+
function _interopRequireDefault$l(obj) {
|
|
724
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
725
|
+
}
|
|
726
|
+
var getLatitude = function getLatitude2(point, raw) {
|
|
727
|
+
var latKey = (0, _getCoordinateKey$1.default)(point, _constants$9.latitudeKeys);
|
|
728
|
+
if (typeof latKey === "undefined" || latKey === null) {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
var value = point[latKey];
|
|
732
|
+
return raw === true ? value : (0, _toDecimal$1.default)(value);
|
|
733
|
+
};
|
|
734
|
+
var _default$u = getLatitude;
|
|
735
|
+
getLatitude$1.default = _default$u;
|
|
736
|
+
var getLongitude$1 = {};
|
|
737
|
+
Object.defineProperty(getLongitude$1, "__esModule", { value: true });
|
|
738
|
+
getLongitude$1.default = void 0;
|
|
739
|
+
var _constants$8 = constants;
|
|
740
|
+
var _getCoordinateKey = _interopRequireDefault$k(getCoordinateKey$1);
|
|
741
|
+
var _toDecimal = _interopRequireDefault$k(toDecimal$1);
|
|
742
|
+
function _interopRequireDefault$k(obj) {
|
|
743
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
744
|
+
}
|
|
745
|
+
var getLongitude = function getLongitude2(point, raw) {
|
|
746
|
+
var latKey = (0, _getCoordinateKey.default)(point, _constants$8.longitudeKeys);
|
|
747
|
+
if (typeof latKey === "undefined" || latKey === null) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
var value = point[latKey];
|
|
751
|
+
return raw === true ? value : (0, _toDecimal.default)(value);
|
|
752
|
+
};
|
|
753
|
+
var _default$t = getLongitude;
|
|
754
|
+
getLongitude$1.default = _default$t;
|
|
755
|
+
var toRad$1 = {};
|
|
756
|
+
Object.defineProperty(toRad$1, "__esModule", { value: true });
|
|
757
|
+
toRad$1.default = void 0;
|
|
758
|
+
var toRad = function toRad2(value) {
|
|
759
|
+
return value * Math.PI / 180;
|
|
760
|
+
};
|
|
761
|
+
var _default$s = toRad;
|
|
762
|
+
toRad$1.default = _default$s;
|
|
763
|
+
var toDeg$1 = {};
|
|
764
|
+
Object.defineProperty(toDeg$1, "__esModule", { value: true });
|
|
765
|
+
toDeg$1.default = void 0;
|
|
766
|
+
var toDeg = function toDeg2(value) {
|
|
767
|
+
return value * 180 / Math.PI;
|
|
768
|
+
};
|
|
769
|
+
var _default$r = toDeg;
|
|
770
|
+
toDeg$1.default = _default$r;
|
|
771
|
+
Object.defineProperty(computeDestinationPoint$1, "__esModule", { value: true });
|
|
772
|
+
computeDestinationPoint$1.default = void 0;
|
|
773
|
+
var _getLatitude$9 = _interopRequireDefault$j(getLatitude$1);
|
|
774
|
+
var _getLongitude$9 = _interopRequireDefault$j(getLongitude$1);
|
|
775
|
+
var _toRad$7 = _interopRequireDefault$j(toRad$1);
|
|
776
|
+
var _toDeg$4 = _interopRequireDefault$j(toDeg$1);
|
|
777
|
+
var _constants$7 = constants;
|
|
778
|
+
function _interopRequireDefault$j(obj) {
|
|
779
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
780
|
+
}
|
|
781
|
+
var computeDestinationPoint = function computeDestinationPoint2(start, distance, bearing) {
|
|
782
|
+
var radius = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 6371e3;
|
|
783
|
+
var lat = (0, _getLatitude$9.default)(start);
|
|
784
|
+
var lng = (0, _getLongitude$9.default)(start);
|
|
785
|
+
var delta = distance / radius;
|
|
786
|
+
var theta = (0, _toRad$7.default)(bearing);
|
|
787
|
+
var phi1 = (0, _toRad$7.default)(lat);
|
|
788
|
+
var lambda1 = (0, _toRad$7.default)(lng);
|
|
789
|
+
var phi2 = Math.asin(Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta));
|
|
790
|
+
var lambda2 = lambda1 + Math.atan2(Math.sin(theta) * Math.sin(delta) * Math.cos(phi1), Math.cos(delta) - Math.sin(phi1) * Math.sin(phi2));
|
|
791
|
+
var longitude = (0, _toDeg$4.default)(lambda2);
|
|
792
|
+
if (longitude < _constants$7.MINLON || longitude > _constants$7.MAXLON) {
|
|
793
|
+
lambda2 = (lambda2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
|
|
794
|
+
longitude = (0, _toDeg$4.default)(lambda2);
|
|
795
|
+
}
|
|
796
|
+
return { latitude: (0, _toDeg$4.default)(phi2), longitude };
|
|
797
|
+
};
|
|
798
|
+
var _default$q = computeDestinationPoint;
|
|
799
|
+
computeDestinationPoint$1.default = _default$q;
|
|
800
|
+
var convertArea$1 = {};
|
|
801
|
+
Object.defineProperty(convertArea$1, "__esModule", { value: true });
|
|
802
|
+
convertArea$1.default = void 0;
|
|
803
|
+
var _constants$6 = constants;
|
|
804
|
+
var convertArea = function convertArea2(squareMeters) {
|
|
805
|
+
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
806
|
+
var factor = _constants$6.areaConversion[targetUnit];
|
|
807
|
+
if (factor) {
|
|
808
|
+
return squareMeters * factor;
|
|
809
|
+
}
|
|
810
|
+
throw new Error("Invalid unit used for area conversion.");
|
|
811
|
+
};
|
|
812
|
+
var _default$p = convertArea;
|
|
813
|
+
convertArea$1.default = _default$p;
|
|
814
|
+
var convertDistance$1 = {};
|
|
815
|
+
Object.defineProperty(convertDistance$1, "__esModule", { value: true });
|
|
816
|
+
convertDistance$1.default = void 0;
|
|
817
|
+
var _constants$5 = constants;
|
|
818
|
+
var convertDistance = function convertDistance2(meters) {
|
|
819
|
+
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
820
|
+
var factor = _constants$5.distanceConversion[targetUnit];
|
|
821
|
+
if (factor) {
|
|
822
|
+
return meters * factor;
|
|
823
|
+
}
|
|
824
|
+
throw new Error("Invalid unit used for distance conversion.");
|
|
825
|
+
};
|
|
826
|
+
var _default$o = convertDistance;
|
|
827
|
+
convertDistance$1.default = _default$o;
|
|
828
|
+
var convertSpeed$1 = {};
|
|
829
|
+
Object.defineProperty(convertSpeed$1, "__esModule", { value: true });
|
|
830
|
+
convertSpeed$1.default = void 0;
|
|
831
|
+
var _constants$4 = constants;
|
|
832
|
+
var convertSpeed = function convertSpeed2(metersPerSecond) {
|
|
833
|
+
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "kmh";
|
|
834
|
+
switch (targetUnit) {
|
|
835
|
+
case "kmh":
|
|
836
|
+
return metersPerSecond * _constants$4.timeConversion.h * _constants$4.distanceConversion.km;
|
|
837
|
+
case "mph":
|
|
838
|
+
return metersPerSecond * _constants$4.timeConversion.h * _constants$4.distanceConversion.mi;
|
|
839
|
+
default:
|
|
840
|
+
return metersPerSecond;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
var _default$n = convertSpeed;
|
|
844
|
+
convertSpeed$1.default = _default$n;
|
|
845
|
+
var decimalToSexagesimal = {};
|
|
846
|
+
Object.defineProperty(decimalToSexagesimal, "__esModule", { value: true });
|
|
847
|
+
decimalToSexagesimal.default = void 0;
|
|
848
|
+
function _slicedToArray$1(arr, i) {
|
|
849
|
+
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
850
|
+
}
|
|
851
|
+
function _nonIterableRest$1() {
|
|
852
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
853
|
+
}
|
|
854
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
855
|
+
if (!o) return;
|
|
856
|
+
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
857
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
858
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
859
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
860
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
861
|
+
}
|
|
862
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
863
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
864
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
865
|
+
arr2[i] = arr[i];
|
|
866
|
+
}
|
|
867
|
+
return arr2;
|
|
868
|
+
}
|
|
869
|
+
function _iterableToArrayLimit$1(arr, i) {
|
|
870
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
871
|
+
var _arr = [];
|
|
872
|
+
var _n = true;
|
|
873
|
+
var _d = false;
|
|
874
|
+
var _e = void 0;
|
|
875
|
+
try {
|
|
876
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
877
|
+
_arr.push(_s.value);
|
|
878
|
+
if (i && _arr.length === i) break;
|
|
879
|
+
}
|
|
880
|
+
} catch (err) {
|
|
881
|
+
_d = true;
|
|
882
|
+
_e = err;
|
|
883
|
+
} finally {
|
|
884
|
+
try {
|
|
885
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
886
|
+
} finally {
|
|
887
|
+
if (_d) throw _e;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return _arr;
|
|
891
|
+
}
|
|
892
|
+
function _arrayWithHoles$1(arr) {
|
|
893
|
+
if (Array.isArray(arr)) return arr;
|
|
894
|
+
}
|
|
895
|
+
var imprecise = function imprecise2(number) {
|
|
896
|
+
var decimals = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
897
|
+
var factor = Math.pow(10, decimals);
|
|
898
|
+
return Math.round(number * factor) / factor;
|
|
899
|
+
};
|
|
900
|
+
var decimal2sexagesimalNext = function decimal2sexagesimalNext2(decimal) {
|
|
901
|
+
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];
|
|
902
|
+
var deg = Math.abs(Number(pre));
|
|
903
|
+
var min0 = Number("0." + (post || 0)) * 60;
|
|
904
|
+
var sec0 = min0.toString().split(".");
|
|
905
|
+
var min = Math.floor(min0);
|
|
906
|
+
var sec = imprecise(Number("0." + (sec0[1] || 0)) * 60).toString();
|
|
907
|
+
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$;
|
|
908
|
+
return deg + "° " + min.toString().padStart(2, "0") + "' " + secPreDec.padStart(2, "0") + "." + secDec.padEnd(1, "0") + '"';
|
|
909
|
+
};
|
|
910
|
+
var _default$m = decimal2sexagesimalNext;
|
|
911
|
+
decimalToSexagesimal.default = _default$m;
|
|
912
|
+
var findNearest$1 = {};
|
|
913
|
+
var orderByDistance$1 = {};
|
|
914
|
+
var getDistance$2 = {};
|
|
915
|
+
var robustAcos$1 = {};
|
|
916
|
+
Object.defineProperty(robustAcos$1, "__esModule", { value: true });
|
|
917
|
+
robustAcos$1.default = void 0;
|
|
918
|
+
var robustAcos = function robustAcos2(value) {
|
|
919
|
+
if (value > 1) {
|
|
920
|
+
return 1;
|
|
921
|
+
}
|
|
922
|
+
if (value < -1) {
|
|
923
|
+
return -1;
|
|
924
|
+
}
|
|
925
|
+
return value;
|
|
926
|
+
};
|
|
927
|
+
var _default$l = robustAcos;
|
|
928
|
+
robustAcos$1.default = _default$l;
|
|
929
|
+
Object.defineProperty(getDistance$2, "__esModule", { value: true });
|
|
930
|
+
getDistance$2.default = void 0;
|
|
931
|
+
var _getLatitude$8 = _interopRequireDefault$i(getLatitude$1);
|
|
932
|
+
var _getLongitude$8 = _interopRequireDefault$i(getLongitude$1);
|
|
933
|
+
var _toRad$6 = _interopRequireDefault$i(toRad$1);
|
|
934
|
+
var _robustAcos$1 = _interopRequireDefault$i(robustAcos$1);
|
|
935
|
+
var _constants$3 = constants;
|
|
936
|
+
function _interopRequireDefault$i(obj) {
|
|
937
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
938
|
+
}
|
|
939
|
+
var getDistance$1 = function getDistance(from, to) {
|
|
940
|
+
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
941
|
+
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
942
|
+
var fromLat = (0, _getLatitude$8.default)(from);
|
|
943
|
+
var fromLon = (0, _getLongitude$8.default)(from);
|
|
944
|
+
var toLat = (0, _getLatitude$8.default)(to);
|
|
945
|
+
var toLon = (0, _getLongitude$8.default)(to);
|
|
946
|
+
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;
|
|
947
|
+
return Math.round(distance / accuracy) * accuracy;
|
|
948
|
+
};
|
|
949
|
+
var _default$k = getDistance$1;
|
|
950
|
+
getDistance$2.default = _default$k;
|
|
951
|
+
Object.defineProperty(orderByDistance$1, "__esModule", { value: true });
|
|
952
|
+
orderByDistance$1.default = void 0;
|
|
953
|
+
var _getDistance$5 = _interopRequireDefault$h(getDistance$2);
|
|
954
|
+
function _interopRequireDefault$h(obj) {
|
|
955
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
956
|
+
}
|
|
957
|
+
var orderByDistance = function orderByDistance2(point, coords) {
|
|
958
|
+
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance$5.default;
|
|
959
|
+
distanceFn = typeof distanceFn === "function" ? distanceFn : _getDistance$5.default;
|
|
960
|
+
return coords.slice().sort(function(a, b) {
|
|
961
|
+
return distanceFn(point, a) - distanceFn(point, b);
|
|
962
|
+
});
|
|
963
|
+
};
|
|
964
|
+
var _default$j = orderByDistance;
|
|
965
|
+
orderByDistance$1.default = _default$j;
|
|
966
|
+
Object.defineProperty(findNearest$1, "__esModule", { value: true });
|
|
967
|
+
findNearest$1.default = void 0;
|
|
968
|
+
var _orderByDistance = _interopRequireDefault$g(orderByDistance$1);
|
|
969
|
+
function _interopRequireDefault$g(obj) {
|
|
970
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
971
|
+
}
|
|
972
|
+
var findNearest = function findNearest2(point, coords) {
|
|
973
|
+
return (0, _orderByDistance.default)(point, coords)[0];
|
|
974
|
+
};
|
|
975
|
+
var _default$i = findNearest;
|
|
976
|
+
findNearest$1.default = _default$i;
|
|
977
|
+
var getAreaOfPolygon$1 = {};
|
|
978
|
+
Object.defineProperty(getAreaOfPolygon$1, "__esModule", { value: true });
|
|
979
|
+
getAreaOfPolygon$1.default = void 0;
|
|
980
|
+
var _toRad$5 = _interopRequireDefault$f(toRad$1);
|
|
981
|
+
var _getLatitude$7 = _interopRequireDefault$f(getLatitude$1);
|
|
982
|
+
var _getLongitude$7 = _interopRequireDefault$f(getLongitude$1);
|
|
983
|
+
var _constants$2 = constants;
|
|
984
|
+
function _interopRequireDefault$f(obj) {
|
|
985
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
986
|
+
}
|
|
987
|
+
var getAreaOfPolygon = function getAreaOfPolygon2(points) {
|
|
988
|
+
var area = 0;
|
|
989
|
+
if (points.length > 2) {
|
|
990
|
+
var lowerIndex;
|
|
991
|
+
var middleIndex;
|
|
992
|
+
var upperIndex;
|
|
993
|
+
for (var i = 0; i < points.length; i++) {
|
|
994
|
+
if (i === points.length - 2) {
|
|
995
|
+
lowerIndex = points.length - 2;
|
|
996
|
+
middleIndex = points.length - 1;
|
|
997
|
+
upperIndex = 0;
|
|
998
|
+
} else if (i === points.length - 1) {
|
|
999
|
+
lowerIndex = points.length - 1;
|
|
1000
|
+
middleIndex = 0;
|
|
1001
|
+
upperIndex = 1;
|
|
1002
|
+
} else {
|
|
1003
|
+
lowerIndex = i;
|
|
1004
|
+
middleIndex = i + 1;
|
|
1005
|
+
upperIndex = i + 2;
|
|
1006
|
+
}
|
|
1007
|
+
var p1lon = (0, _getLongitude$7.default)(points[lowerIndex]);
|
|
1008
|
+
var p2lat = (0, _getLatitude$7.default)(points[middleIndex]);
|
|
1009
|
+
var p3lon = (0, _getLongitude$7.default)(points[upperIndex]);
|
|
1010
|
+
area += ((0, _toRad$5.default)(p3lon) - (0, _toRad$5.default)(p1lon)) * Math.sin((0, _toRad$5.default)(p2lat));
|
|
1011
|
+
}
|
|
1012
|
+
area = area * _constants$2.earthRadius * _constants$2.earthRadius / 2;
|
|
1013
|
+
}
|
|
1014
|
+
return Math.abs(area);
|
|
1015
|
+
};
|
|
1016
|
+
var _default$h = getAreaOfPolygon;
|
|
1017
|
+
getAreaOfPolygon$1.default = _default$h;
|
|
1018
|
+
var getBounds$1 = {};
|
|
1019
|
+
Object.defineProperty(getBounds$1, "__esModule", { value: true });
|
|
1020
|
+
getBounds$1.default = void 0;
|
|
1021
|
+
var _getLatitude$6 = _interopRequireDefault$e(getLatitude$1);
|
|
1022
|
+
var _getLongitude$6 = _interopRequireDefault$e(getLongitude$1);
|
|
1023
|
+
function _interopRequireDefault$e(obj) {
|
|
1024
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1025
|
+
}
|
|
1026
|
+
var getBounds = function getBounds2(points) {
|
|
1027
|
+
if (Array.isArray(points) === false || points.length === 0) {
|
|
1028
|
+
throw new Error("No points were given.");
|
|
1029
|
+
}
|
|
1030
|
+
return points.reduce(function(stats, point) {
|
|
1031
|
+
var latitude = (0, _getLatitude$6.default)(point);
|
|
1032
|
+
var longitude = (0, _getLongitude$6.default)(point);
|
|
1033
|
+
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) };
|
|
1034
|
+
}, { maxLat: -Infinity, minLat: Infinity, maxLng: -Infinity, minLng: Infinity });
|
|
1035
|
+
};
|
|
1036
|
+
var _default$g = getBounds;
|
|
1037
|
+
getBounds$1.default = _default$g;
|
|
1038
|
+
var getBoundsOfDistance$1 = {};
|
|
1039
|
+
Object.defineProperty(getBoundsOfDistance$1, "__esModule", { value: true });
|
|
1040
|
+
getBoundsOfDistance$1.default = void 0;
|
|
1041
|
+
var _getLatitude$5 = _interopRequireDefault$d(getLatitude$1);
|
|
1042
|
+
var _getLongitude$5 = _interopRequireDefault$d(getLongitude$1);
|
|
1043
|
+
var _toRad$4 = _interopRequireDefault$d(toRad$1);
|
|
1044
|
+
var _toDeg$3 = _interopRequireDefault$d(toDeg$1);
|
|
1045
|
+
var _constants$1 = constants;
|
|
1046
|
+
function _interopRequireDefault$d(obj) {
|
|
1047
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1048
|
+
}
|
|
1049
|
+
var getBoundsOfDistance = function getBoundsOfDistance2(point, distance) {
|
|
1050
|
+
var latitude = (0, _getLatitude$5.default)(point);
|
|
1051
|
+
var longitude = (0, _getLongitude$5.default)(point);
|
|
1052
|
+
var radLat = (0, _toRad$4.default)(latitude);
|
|
1053
|
+
var radLon = (0, _toRad$4.default)(longitude);
|
|
1054
|
+
var radDist = distance / _constants$1.earthRadius;
|
|
1055
|
+
var minLat = radLat - radDist;
|
|
1056
|
+
var maxLat = radLat + radDist;
|
|
1057
|
+
var MAX_LAT_RAD = (0, _toRad$4.default)(_constants$1.MAXLAT);
|
|
1058
|
+
var MIN_LAT_RAD = (0, _toRad$4.default)(_constants$1.MINLAT);
|
|
1059
|
+
var MAX_LON_RAD = (0, _toRad$4.default)(_constants$1.MAXLON);
|
|
1060
|
+
var MIN_LON_RAD = (0, _toRad$4.default)(_constants$1.MINLON);
|
|
1061
|
+
var minLon;
|
|
1062
|
+
var maxLon;
|
|
1063
|
+
if (minLat > MIN_LAT_RAD && maxLat < MAX_LAT_RAD) {
|
|
1064
|
+
var deltaLon = Math.asin(Math.sin(radDist) / Math.cos(radLat));
|
|
1065
|
+
minLon = radLon - deltaLon;
|
|
1066
|
+
if (minLon < MIN_LON_RAD) {
|
|
1067
|
+
minLon += Math.PI * 2;
|
|
1068
|
+
}
|
|
1069
|
+
maxLon = radLon + deltaLon;
|
|
1070
|
+
if (maxLon > MAX_LON_RAD) {
|
|
1071
|
+
maxLon -= Math.PI * 2;
|
|
1072
|
+
}
|
|
1073
|
+
} else {
|
|
1074
|
+
minLat = Math.max(minLat, MIN_LAT_RAD);
|
|
1075
|
+
maxLat = Math.min(maxLat, MAX_LAT_RAD);
|
|
1076
|
+
minLon = MIN_LON_RAD;
|
|
1077
|
+
maxLon = MAX_LON_RAD;
|
|
1078
|
+
}
|
|
1079
|
+
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) }];
|
|
1080
|
+
};
|
|
1081
|
+
var _default$f = getBoundsOfDistance;
|
|
1082
|
+
getBoundsOfDistance$1.default = _default$f;
|
|
1083
|
+
var getCenter$1 = {};
|
|
1084
|
+
Object.defineProperty(getCenter$1, "__esModule", { value: true });
|
|
1085
|
+
getCenter$1.default = void 0;
|
|
1086
|
+
var _getLatitude$4 = _interopRequireDefault$c(getLatitude$1);
|
|
1087
|
+
var _getLongitude$4 = _interopRequireDefault$c(getLongitude$1);
|
|
1088
|
+
var _toRad$3 = _interopRequireDefault$c(toRad$1);
|
|
1089
|
+
var _toDeg$2 = _interopRequireDefault$c(toDeg$1);
|
|
1090
|
+
function _interopRequireDefault$c(obj) {
|
|
1091
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1092
|
+
}
|
|
1093
|
+
var getCenter = function getCenter2(points) {
|
|
1094
|
+
if (Array.isArray(points) === false || points.length === 0) {
|
|
1095
|
+
return false;
|
|
1096
|
+
}
|
|
1097
|
+
var numberOfPoints = points.length;
|
|
1098
|
+
var sum = points.reduce(function(acc, point) {
|
|
1099
|
+
var pointLat = (0, _toRad$3.default)((0, _getLatitude$4.default)(point));
|
|
1100
|
+
var pointLon = (0, _toRad$3.default)((0, _getLongitude$4.default)(point));
|
|
1101
|
+
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) };
|
|
1102
|
+
}, { X: 0, Y: 0, Z: 0 });
|
|
1103
|
+
var X = sum.X / numberOfPoints;
|
|
1104
|
+
var Y = sum.Y / numberOfPoints;
|
|
1105
|
+
var Z = sum.Z / numberOfPoints;
|
|
1106
|
+
return { longitude: (0, _toDeg$2.default)(Math.atan2(Y, X)), latitude: (0, _toDeg$2.default)(Math.atan2(Z, Math.sqrt(X * X + Y * Y))) };
|
|
1107
|
+
};
|
|
1108
|
+
var _default$e = getCenter;
|
|
1109
|
+
getCenter$1.default = _default$e;
|
|
1110
|
+
var getCenterOfBounds$1 = {};
|
|
1111
|
+
Object.defineProperty(getCenterOfBounds$1, "__esModule", { value: true });
|
|
1112
|
+
getCenterOfBounds$1.default = void 0;
|
|
1113
|
+
var _getBounds = _interopRequireDefault$b(getBounds$1);
|
|
1114
|
+
function _interopRequireDefault$b(obj) {
|
|
1115
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1116
|
+
}
|
|
1117
|
+
var getCenterOfBounds = function getCenterOfBounds2(coords) {
|
|
1118
|
+
var bounds = (0, _getBounds.default)(coords);
|
|
1119
|
+
var latitude = bounds.minLat + (bounds.maxLat - bounds.minLat) / 2;
|
|
1120
|
+
var longitude = bounds.minLng + (bounds.maxLng - bounds.minLng) / 2;
|
|
1121
|
+
return { latitude: parseFloat(latitude.toFixed(6)), longitude: parseFloat(longitude.toFixed(6)) };
|
|
1122
|
+
};
|
|
1123
|
+
var _default$d = getCenterOfBounds;
|
|
1124
|
+
getCenterOfBounds$1.default = _default$d;
|
|
1125
|
+
var getCompassDirection$1 = {};
|
|
1126
|
+
var getRhumbLineBearing$1 = {};
|
|
1127
|
+
Object.defineProperty(getRhumbLineBearing$1, "__esModule", { value: true });
|
|
1128
|
+
getRhumbLineBearing$1.default = void 0;
|
|
1129
|
+
var _getLatitude$3 = _interopRequireDefault$a(getLatitude$1);
|
|
1130
|
+
var _getLongitude$3 = _interopRequireDefault$a(getLongitude$1);
|
|
1131
|
+
var _toRad$2 = _interopRequireDefault$a(toRad$1);
|
|
1132
|
+
var _toDeg$1 = _interopRequireDefault$a(toDeg$1);
|
|
1133
|
+
function _interopRequireDefault$a(obj) {
|
|
1134
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1135
|
+
}
|
|
1136
|
+
var getRhumbLineBearing = function getRhumbLineBearing2(origin, dest) {
|
|
1137
|
+
var diffLon = (0, _toRad$2.default)((0, _getLongitude$3.default)(dest)) - (0, _toRad$2.default)((0, _getLongitude$3.default)(origin));
|
|
1138
|
+
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));
|
|
1139
|
+
if (Math.abs(diffLon) > Math.PI) {
|
|
1140
|
+
if (diffLon > 0) {
|
|
1141
|
+
diffLon = (Math.PI * 2 - diffLon) * -1;
|
|
1142
|
+
} else {
|
|
1143
|
+
diffLon = Math.PI * 2 + diffLon;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return ((0, _toDeg$1.default)(Math.atan2(diffLon, diffPhi)) + 360) % 360;
|
|
1147
|
+
};
|
|
1148
|
+
var _default$c = getRhumbLineBearing;
|
|
1149
|
+
getRhumbLineBearing$1.default = _default$c;
|
|
1150
|
+
Object.defineProperty(getCompassDirection$1, "__esModule", { value: true });
|
|
1151
|
+
getCompassDirection$1.default = void 0;
|
|
1152
|
+
var _getRhumbLineBearing = _interopRequireDefault$9(getRhumbLineBearing$1);
|
|
1153
|
+
function _interopRequireDefault$9(obj) {
|
|
1154
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1155
|
+
}
|
|
1156
|
+
var getCompassDirection = function getCompassDirection2(origin, dest) {
|
|
1157
|
+
var bearingFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getRhumbLineBearing.default;
|
|
1158
|
+
var bearing = typeof bearingFn === "function" ? bearingFn(origin, dest) : (0, _getRhumbLineBearing.default)(origin, dest);
|
|
1159
|
+
if (isNaN(bearing)) {
|
|
1160
|
+
throw new Error("Could not calculate bearing for given points. Check your bearing function");
|
|
1161
|
+
}
|
|
1162
|
+
switch (Math.round(bearing / 22.5)) {
|
|
1163
|
+
case 1:
|
|
1164
|
+
return "NNE";
|
|
1165
|
+
case 2:
|
|
1166
|
+
return "NE";
|
|
1167
|
+
case 3:
|
|
1168
|
+
return "ENE";
|
|
1169
|
+
case 4:
|
|
1170
|
+
return "E";
|
|
1171
|
+
case 5:
|
|
1172
|
+
return "ESE";
|
|
1173
|
+
case 6:
|
|
1174
|
+
return "SE";
|
|
1175
|
+
case 7:
|
|
1176
|
+
return "SSE";
|
|
1177
|
+
case 8:
|
|
1178
|
+
return "S";
|
|
1179
|
+
case 9:
|
|
1180
|
+
return "SSW";
|
|
1181
|
+
case 10:
|
|
1182
|
+
return "SW";
|
|
1183
|
+
case 11:
|
|
1184
|
+
return "WSW";
|
|
1185
|
+
case 12:
|
|
1186
|
+
return "W";
|
|
1187
|
+
case 13:
|
|
1188
|
+
return "WNW";
|
|
1189
|
+
case 14:
|
|
1190
|
+
return "NW";
|
|
1191
|
+
case 15:
|
|
1192
|
+
return "NNW";
|
|
1193
|
+
default:
|
|
1194
|
+
return "N";
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
var _default$b = getCompassDirection;
|
|
1198
|
+
getCompassDirection$1.default = _default$b;
|
|
1199
|
+
var getDistanceFromLine$1 = {};
|
|
1200
|
+
Object.defineProperty(getDistanceFromLine$1, "__esModule", { value: true });
|
|
1201
|
+
getDistanceFromLine$1.default = void 0;
|
|
1202
|
+
var _getDistance$4 = _interopRequireDefault$8(getDistance$2);
|
|
1203
|
+
var _robustAcos = _interopRequireDefault$8(robustAcos$1);
|
|
1204
|
+
function _interopRequireDefault$8(obj) {
|
|
1205
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1206
|
+
}
|
|
1207
|
+
var getDistanceFromLine = function getDistanceFromLine2(point, lineStart, lineEnd) {
|
|
1208
|
+
var accuracy = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
|
|
1209
|
+
var d1 = (0, _getDistance$4.default)(lineStart, point, accuracy);
|
|
1210
|
+
var d2 = (0, _getDistance$4.default)(point, lineEnd, accuracy);
|
|
1211
|
+
var d3 = (0, _getDistance$4.default)(lineStart, lineEnd, accuracy);
|
|
1212
|
+
var alpha = Math.acos((0, _robustAcos.default)((d1 * d1 + d3 * d3 - d2 * d2) / (2 * d1 * d3)));
|
|
1213
|
+
var beta = Math.acos((0, _robustAcos.default)((d2 * d2 + d3 * d3 - d1 * d1) / (2 * d2 * d3)));
|
|
1214
|
+
if (alpha > Math.PI / 2) {
|
|
1215
|
+
return d1;
|
|
1216
|
+
}
|
|
1217
|
+
if (beta > Math.PI / 2) {
|
|
1218
|
+
return d2;
|
|
1219
|
+
}
|
|
1220
|
+
return Math.sin(alpha) * d1;
|
|
1221
|
+
};
|
|
1222
|
+
var _default$a = getDistanceFromLine;
|
|
1223
|
+
getDistanceFromLine$1.default = _default$a;
|
|
1224
|
+
var getGreatCircleBearing$1 = {};
|
|
1225
|
+
Object.defineProperty(getGreatCircleBearing$1, "__esModule", { value: true });
|
|
1226
|
+
getGreatCircleBearing$1.default = void 0;
|
|
1227
|
+
var _getLatitude$2 = _interopRequireDefault$7(getLatitude$1);
|
|
1228
|
+
var _getLongitude$2 = _interopRequireDefault$7(getLongitude$1);
|
|
1229
|
+
var _toRad$1 = _interopRequireDefault$7(toRad$1);
|
|
1230
|
+
var _toDeg = _interopRequireDefault$7(toDeg$1);
|
|
1231
|
+
function _interopRequireDefault$7(obj) {
|
|
1232
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1233
|
+
}
|
|
1234
|
+
var getGreatCircleBearing = function getGreatCircleBearing2(origin, dest) {
|
|
1235
|
+
var destLat = (0, _getLatitude$2.default)(dest);
|
|
1236
|
+
var detLon = (0, _getLongitude$2.default)(dest);
|
|
1237
|
+
var originLat = (0, _getLatitude$2.default)(origin);
|
|
1238
|
+
var originLon = (0, _getLongitude$2.default)(origin);
|
|
1239
|
+
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;
|
|
1240
|
+
return bearing;
|
|
1241
|
+
};
|
|
1242
|
+
var _default$9 = getGreatCircleBearing;
|
|
1243
|
+
getGreatCircleBearing$1.default = _default$9;
|
|
1244
|
+
var getPathLength$1 = {};
|
|
1245
|
+
Object.defineProperty(getPathLength$1, "__esModule", { value: true });
|
|
1246
|
+
getPathLength$1.default = void 0;
|
|
1247
|
+
var _getDistance$3 = _interopRequireDefault$6(getDistance$2);
|
|
1248
|
+
function _interopRequireDefault$6(obj) {
|
|
1249
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1250
|
+
}
|
|
1251
|
+
function _typeof(obj) {
|
|
1252
|
+
"@babel/helpers - typeof";
|
|
1253
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
1254
|
+
_typeof = function _typeof2(obj2) {
|
|
1255
|
+
return typeof obj2;
|
|
1256
|
+
};
|
|
1257
|
+
} else {
|
|
1258
|
+
_typeof = function _typeof2(obj2) {
|
|
1259
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
return _typeof(obj);
|
|
1263
|
+
}
|
|
1264
|
+
var getPathLength = function getPathLength2(points) {
|
|
1265
|
+
var distanceFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _getDistance$3.default;
|
|
1266
|
+
return points.reduce(function(acc, point) {
|
|
1267
|
+
if (_typeof(acc) === "object" && acc.last !== null) {
|
|
1268
|
+
acc.distance += distanceFn(point, acc.last);
|
|
1269
|
+
}
|
|
1270
|
+
acc.last = point;
|
|
1271
|
+
return acc;
|
|
1272
|
+
}, { last: null, distance: 0 }).distance;
|
|
1273
|
+
};
|
|
1274
|
+
var _default$8 = getPathLength;
|
|
1275
|
+
getPathLength$1.default = _default$8;
|
|
1276
|
+
var getPreciseDistance = {};
|
|
1277
|
+
Object.defineProperty(getPreciseDistance, "__esModule", { value: true });
|
|
1278
|
+
getPreciseDistance.default = void 0;
|
|
1279
|
+
var _getLatitude$1 = _interopRequireDefault$5(getLatitude$1);
|
|
1280
|
+
var _getLongitude$1 = _interopRequireDefault$5(getLongitude$1);
|
|
1281
|
+
var _toRad = _interopRequireDefault$5(toRad$1);
|
|
1282
|
+
var _constants = constants;
|
|
1283
|
+
function _interopRequireDefault$5(obj) {
|
|
1284
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1285
|
+
}
|
|
1286
|
+
var getDistance2 = function getDistance3(start, end) {
|
|
1287
|
+
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
1288
|
+
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
1289
|
+
var startLat = (0, _getLatitude$1.default)(start);
|
|
1290
|
+
var startLon = (0, _getLongitude$1.default)(start);
|
|
1291
|
+
var endLat = (0, _getLatitude$1.default)(end);
|
|
1292
|
+
var endLon = (0, _getLongitude$1.default)(end);
|
|
1293
|
+
var b = 6356752314245e-6;
|
|
1294
|
+
var ellipsoidParams = 1 / 298.257223563;
|
|
1295
|
+
var L = (0, _toRad.default)(endLon - startLon);
|
|
1296
|
+
var cosSigma;
|
|
1297
|
+
var sigma;
|
|
1298
|
+
var sinAlpha;
|
|
1299
|
+
var cosSqAlpha;
|
|
1300
|
+
var cos2SigmaM;
|
|
1301
|
+
var sinSigma;
|
|
1302
|
+
var U1 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(startLat))));
|
|
1303
|
+
var U2 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(endLat))));
|
|
1304
|
+
var sinU1 = Math.sin(U1);
|
|
1305
|
+
var cosU1 = Math.cos(U1);
|
|
1306
|
+
var sinU2 = Math.sin(U2);
|
|
1307
|
+
var cosU2 = Math.cos(U2);
|
|
1308
|
+
var lambda = L;
|
|
1309
|
+
var lambdaP;
|
|
1310
|
+
var iterLimit = 100;
|
|
1311
|
+
do {
|
|
1312
|
+
var sinLambda = Math.sin(lambda);
|
|
1313
|
+
var cosLambda = Math.cos(lambda);
|
|
1314
|
+
sinSigma = Math.sqrt(cosU2 * sinLambda * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
|
|
1315
|
+
if (sinSigma === 0) {
|
|
1316
|
+
return 0;
|
|
1317
|
+
}
|
|
1318
|
+
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
|
|
1319
|
+
sigma = Math.atan2(sinSigma, cosSigma);
|
|
1320
|
+
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
|
|
1321
|
+
cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
|
1322
|
+
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
|
|
1323
|
+
if (isNaN(cos2SigmaM)) {
|
|
1324
|
+
cos2SigmaM = 0;
|
|
1325
|
+
}
|
|
1326
|
+
var C = ellipsoidParams / 16 * cosSqAlpha * (4 + ellipsoidParams * (4 - 3 * cosSqAlpha));
|
|
1327
|
+
lambdaP = lambda;
|
|
1328
|
+
lambda = L + (1 - C) * ellipsoidParams * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
1329
|
+
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
|
|
1330
|
+
if (iterLimit === 0) {
|
|
1331
|
+
return NaN;
|
|
1332
|
+
}
|
|
1333
|
+
var uSq = cosSqAlpha * (_constants.earthRadius * _constants.earthRadius - b * b) / (b * b);
|
|
1334
|
+
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
|
1335
|
+
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
|
1336
|
+
var deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
|
1337
|
+
var distance = b * A * (sigma - deltaSigma);
|
|
1338
|
+
return Math.round(distance / accuracy) * accuracy;
|
|
1339
|
+
};
|
|
1340
|
+
var _default$7 = getDistance2;
|
|
1341
|
+
getPreciseDistance.default = _default$7;
|
|
1342
|
+
var getRoughCompassDirection$1 = {};
|
|
1343
|
+
Object.defineProperty(getRoughCompassDirection$1, "__esModule", { value: true });
|
|
1344
|
+
getRoughCompassDirection$1.default = void 0;
|
|
1345
|
+
var getRoughCompassDirection = function getRoughCompassDirection2(exact) {
|
|
1346
|
+
if (/^(NNE|NE|NNW|N)$/.test(exact)) {
|
|
1347
|
+
return "N";
|
|
1348
|
+
}
|
|
1349
|
+
if (/^(ENE|E|ESE|SE)$/.test(exact)) {
|
|
1350
|
+
return "E";
|
|
1351
|
+
}
|
|
1352
|
+
if (/^(SSE|S|SSW|SW)$/.test(exact)) {
|
|
1353
|
+
return "S";
|
|
1354
|
+
}
|
|
1355
|
+
if (/^(WSW|W|WNW|NW)$/.test(exact)) {
|
|
1356
|
+
return "W";
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
var _default$6 = getRoughCompassDirection;
|
|
1360
|
+
getRoughCompassDirection$1.default = _default$6;
|
|
1361
|
+
var getSpeed$1 = {};
|
|
1362
|
+
Object.defineProperty(getSpeed$1, "__esModule", { value: true });
|
|
1363
|
+
getSpeed$1.default = void 0;
|
|
1364
|
+
var _getDistance$2 = _interopRequireDefault$4(getDistance$2);
|
|
1365
|
+
function _interopRequireDefault$4(obj) {
|
|
1366
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1367
|
+
}
|
|
1368
|
+
var getSpeed = function getSpeed2(start, end) {
|
|
1369
|
+
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance$2.default;
|
|
1370
|
+
var distance = distanceFn(start, end);
|
|
1371
|
+
var time = Number(end.time) - Number(start.time);
|
|
1372
|
+
var metersPerSecond = distance / time * 1e3;
|
|
1373
|
+
return metersPerSecond;
|
|
1374
|
+
};
|
|
1375
|
+
var _default$5 = getSpeed;
|
|
1376
|
+
getSpeed$1.default = _default$5;
|
|
1377
|
+
var isPointInLine$1 = {};
|
|
1378
|
+
Object.defineProperty(isPointInLine$1, "__esModule", { value: true });
|
|
1379
|
+
isPointInLine$1.default = void 0;
|
|
1380
|
+
var _getDistance$1 = _interopRequireDefault$3(getDistance$2);
|
|
1381
|
+
function _interopRequireDefault$3(obj) {
|
|
1382
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1383
|
+
}
|
|
1384
|
+
var isPointInLine = function isPointInLine2(point, lineStart, lineEnd) {
|
|
1385
|
+
return (0, _getDistance$1.default)(lineStart, point) + (0, _getDistance$1.default)(point, lineEnd) === (0, _getDistance$1.default)(lineStart, lineEnd);
|
|
1386
|
+
};
|
|
1387
|
+
var _default$4 = isPointInLine;
|
|
1388
|
+
isPointInLine$1.default = _default$4;
|
|
1389
|
+
var isPointInPolygon$1 = {};
|
|
1390
|
+
Object.defineProperty(isPointInPolygon$1, "__esModule", { value: true });
|
|
1391
|
+
isPointInPolygon$1.default = void 0;
|
|
1392
|
+
var _getLatitude = _interopRequireDefault$2(getLatitude$1);
|
|
1393
|
+
var _getLongitude = _interopRequireDefault$2(getLongitude$1);
|
|
1394
|
+
function _interopRequireDefault$2(obj) {
|
|
1395
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1396
|
+
}
|
|
1397
|
+
var isPointInPolygon = function isPointInPolygon2(point, polygon) {
|
|
1398
|
+
var isInside = false;
|
|
1399
|
+
var totalPolys = polygon.length;
|
|
1400
|
+
for (var i = -1, j = totalPolys - 1; ++i < totalPolys; j = i) {
|
|
1401
|
+
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])) {
|
|
1402
|
+
isInside = !isInside;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return isInside;
|
|
1406
|
+
};
|
|
1407
|
+
var _default$3 = isPointInPolygon;
|
|
1408
|
+
isPointInPolygon$1.default = _default$3;
|
|
1409
|
+
var isPointNearLine$1 = {};
|
|
1410
|
+
Object.defineProperty(isPointNearLine$1, "__esModule", { value: true });
|
|
1411
|
+
isPointNearLine$1.default = void 0;
|
|
1412
|
+
var _getDistanceFromLine = _interopRequireDefault$1(getDistanceFromLine$1);
|
|
1413
|
+
function _interopRequireDefault$1(obj) {
|
|
1414
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1415
|
+
}
|
|
1416
|
+
var isPointNearLine = function isPointNearLine2(point, start, end, distance) {
|
|
1417
|
+
return (0, _getDistanceFromLine.default)(point, start, end) < distance;
|
|
1418
|
+
};
|
|
1419
|
+
var _default$2 = isPointNearLine;
|
|
1420
|
+
isPointNearLine$1.default = _default$2;
|
|
1421
|
+
var isPointWithinRadius$1 = {};
|
|
1422
|
+
Object.defineProperty(isPointWithinRadius$1, "__esModule", { value: true });
|
|
1423
|
+
isPointWithinRadius$1.default = void 0;
|
|
1424
|
+
var _getDistance = _interopRequireDefault(getDistance$2);
|
|
1425
|
+
function _interopRequireDefault(obj) {
|
|
1426
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1427
|
+
}
|
|
1428
|
+
var isPointWithinRadius = function isPointWithinRadius2(point, center, radius) {
|
|
1429
|
+
var accuracy = 0.01;
|
|
1430
|
+
return (0, _getDistance.default)(point, center, accuracy) < radius;
|
|
1431
|
+
};
|
|
1432
|
+
var _default$1 = isPointWithinRadius;
|
|
1433
|
+
isPointWithinRadius$1.default = _default$1;
|
|
1434
|
+
var wktToPolygon$1 = {};
|
|
1435
|
+
Object.defineProperty(wktToPolygon$1, "__esModule", { value: true });
|
|
1436
|
+
wktToPolygon$1.default = void 0;
|
|
1437
|
+
function _slicedToArray(arr, i) {
|
|
1438
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1439
|
+
}
|
|
1440
|
+
function _nonIterableRest() {
|
|
1441
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1442
|
+
}
|
|
1443
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1444
|
+
if (!o) return;
|
|
1445
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1446
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1447
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1448
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1449
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1450
|
+
}
|
|
1451
|
+
function _arrayLikeToArray(arr, len) {
|
|
1452
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1453
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1454
|
+
arr2[i] = arr[i];
|
|
1455
|
+
}
|
|
1456
|
+
return arr2;
|
|
1457
|
+
}
|
|
1458
|
+
function _iterableToArrayLimit(arr, i) {
|
|
1459
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
1460
|
+
var _arr = [];
|
|
1461
|
+
var _n = true;
|
|
1462
|
+
var _d = false;
|
|
1463
|
+
var _e = void 0;
|
|
1464
|
+
try {
|
|
1465
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1466
|
+
_arr.push(_s.value);
|
|
1467
|
+
if (i && _arr.length === i) break;
|
|
1468
|
+
}
|
|
1469
|
+
} catch (err) {
|
|
1470
|
+
_d = true;
|
|
1471
|
+
_e = err;
|
|
1472
|
+
} finally {
|
|
1473
|
+
try {
|
|
1474
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1475
|
+
} finally {
|
|
1476
|
+
if (_d) throw _e;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
return _arr;
|
|
1480
|
+
}
|
|
1481
|
+
function _arrayWithHoles(arr) {
|
|
1482
|
+
if (Array.isArray(arr)) return arr;
|
|
1483
|
+
}
|
|
1484
|
+
var wktToPolygon = function wktToPolygon2(wkt) {
|
|
1485
|
+
if (!wkt.startsWith("POLYGON")) {
|
|
1486
|
+
throw new Error("Invalid wkt.");
|
|
1487
|
+
}
|
|
1488
|
+
var coordsText = wkt.slice(wkt.indexOf("(") + 2, wkt.indexOf(")")).split(", ");
|
|
1489
|
+
var polygon = coordsText.map(function(coordText) {
|
|
1490
|
+
var _coordText$split = coordText.split(" "), _coordText$split2 = _slicedToArray(_coordText$split, 2), longitude = _coordText$split2[0], latitude = _coordText$split2[1];
|
|
1491
|
+
return { longitude: parseFloat(longitude), latitude: parseFloat(latitude) };
|
|
1492
|
+
});
|
|
1493
|
+
return polygon;
|
|
1494
|
+
};
|
|
1495
|
+
var _default = wktToPolygon;
|
|
1496
|
+
wktToPolygon$1.default = _default;
|
|
1497
|
+
(function(exports) {
|
|
1498
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1499
|
+
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 };
|
|
1500
|
+
Object.defineProperty(exports, "computeDestinationPoint", { enumerable: true, get: function get() {
|
|
1501
|
+
return _computeDestinationPoint.default;
|
|
1502
|
+
} });
|
|
1503
|
+
Object.defineProperty(exports, "convertArea", { enumerable: true, get: function get() {
|
|
1504
|
+
return _convertArea.default;
|
|
1505
|
+
} });
|
|
1506
|
+
Object.defineProperty(exports, "convertDistance", { enumerable: true, get: function get() {
|
|
1507
|
+
return _convertDistance.default;
|
|
1508
|
+
} });
|
|
1509
|
+
Object.defineProperty(exports, "convertSpeed", { enumerable: true, get: function get() {
|
|
1510
|
+
return _convertSpeed.default;
|
|
1511
|
+
} });
|
|
1512
|
+
Object.defineProperty(exports, "decimalToSexagesimal", { enumerable: true, get: function get() {
|
|
1513
|
+
return _decimalToSexagesimal.default;
|
|
1514
|
+
} });
|
|
1515
|
+
Object.defineProperty(exports, "findNearest", { enumerable: true, get: function get() {
|
|
1516
|
+
return _findNearest.default;
|
|
1517
|
+
} });
|
|
1518
|
+
Object.defineProperty(exports, "getAreaOfPolygon", { enumerable: true, get: function get() {
|
|
1519
|
+
return _getAreaOfPolygon.default;
|
|
1520
|
+
} });
|
|
1521
|
+
Object.defineProperty(exports, "getBounds", { enumerable: true, get: function get() {
|
|
1522
|
+
return _getBounds2.default;
|
|
1523
|
+
} });
|
|
1524
|
+
Object.defineProperty(exports, "getBoundsOfDistance", { enumerable: true, get: function get() {
|
|
1525
|
+
return _getBoundsOfDistance.default;
|
|
1526
|
+
} });
|
|
1527
|
+
Object.defineProperty(exports, "getCenter", { enumerable: true, get: function get() {
|
|
1528
|
+
return _getCenter.default;
|
|
1529
|
+
} });
|
|
1530
|
+
Object.defineProperty(exports, "getCenterOfBounds", { enumerable: true, get: function get() {
|
|
1531
|
+
return _getCenterOfBounds.default;
|
|
1532
|
+
} });
|
|
1533
|
+
Object.defineProperty(exports, "getCompassDirection", { enumerable: true, get: function get() {
|
|
1534
|
+
return _getCompassDirection.default;
|
|
1535
|
+
} });
|
|
1536
|
+
Object.defineProperty(exports, "getCoordinateKey", { enumerable: true, get: function get() {
|
|
1537
|
+
return _getCoordinateKey2.default;
|
|
1538
|
+
} });
|
|
1539
|
+
Object.defineProperty(exports, "getCoordinateKeys", { enumerable: true, get: function get() {
|
|
1540
|
+
return _getCoordinateKeys3.default;
|
|
1541
|
+
} });
|
|
1542
|
+
Object.defineProperty(exports, "getDistance", { enumerable: true, get: function get() {
|
|
1543
|
+
return _getDistance2.default;
|
|
1544
|
+
} });
|
|
1545
|
+
Object.defineProperty(exports, "getDistanceFromLine", { enumerable: true, get: function get() {
|
|
1546
|
+
return _getDistanceFromLine2.default;
|
|
1547
|
+
} });
|
|
1548
|
+
Object.defineProperty(exports, "getGreatCircleBearing", { enumerable: true, get: function get() {
|
|
1549
|
+
return _getGreatCircleBearing.default;
|
|
1550
|
+
} });
|
|
1551
|
+
Object.defineProperty(exports, "getLatitude", { enumerable: true, get: function get() {
|
|
1552
|
+
return _getLatitude2.default;
|
|
1553
|
+
} });
|
|
1554
|
+
Object.defineProperty(exports, "getLongitude", { enumerable: true, get: function get() {
|
|
1555
|
+
return _getLongitude2.default;
|
|
1556
|
+
} });
|
|
1557
|
+
Object.defineProperty(exports, "getPathLength", { enumerable: true, get: function get() {
|
|
1558
|
+
return _getPathLength.default;
|
|
1559
|
+
} });
|
|
1560
|
+
Object.defineProperty(exports, "getPreciseDistance", { enumerable: true, get: function get() {
|
|
1561
|
+
return _getPreciseDistance.default;
|
|
1562
|
+
} });
|
|
1563
|
+
Object.defineProperty(exports, "getRhumbLineBearing", { enumerable: true, get: function get() {
|
|
1564
|
+
return _getRhumbLineBearing2.default;
|
|
1565
|
+
} });
|
|
1566
|
+
Object.defineProperty(exports, "getRoughCompassDirection", { enumerable: true, get: function get() {
|
|
1567
|
+
return _getRoughCompassDirection.default;
|
|
1568
|
+
} });
|
|
1569
|
+
Object.defineProperty(exports, "getSpeed", { enumerable: true, get: function get() {
|
|
1570
|
+
return _getSpeed.default;
|
|
1571
|
+
} });
|
|
1572
|
+
Object.defineProperty(exports, "isDecimal", { enumerable: true, get: function get() {
|
|
1573
|
+
return _isDecimal2.default;
|
|
1574
|
+
} });
|
|
1575
|
+
Object.defineProperty(exports, "isPointInLine", { enumerable: true, get: function get() {
|
|
1576
|
+
return _isPointInLine.default;
|
|
1577
|
+
} });
|
|
1578
|
+
Object.defineProperty(exports, "isPointInPolygon", { enumerable: true, get: function get() {
|
|
1579
|
+
return _isPointInPolygon.default;
|
|
1580
|
+
} });
|
|
1581
|
+
Object.defineProperty(exports, "isPointNearLine", { enumerable: true, get: function get() {
|
|
1582
|
+
return _isPointNearLine.default;
|
|
1583
|
+
} });
|
|
1584
|
+
Object.defineProperty(exports, "isPointWithinRadius", { enumerable: true, get: function get() {
|
|
1585
|
+
return _isPointWithinRadius.default;
|
|
1586
|
+
} });
|
|
1587
|
+
Object.defineProperty(exports, "isSexagesimal", { enumerable: true, get: function get() {
|
|
1588
|
+
return _isSexagesimal2.default;
|
|
1589
|
+
} });
|
|
1590
|
+
Object.defineProperty(exports, "isValidCoordinate", { enumerable: true, get: function get() {
|
|
1591
|
+
return _isValidCoordinate2.default;
|
|
1592
|
+
} });
|
|
1593
|
+
Object.defineProperty(exports, "isValidLatitude", { enumerable: true, get: function get() {
|
|
1594
|
+
return _isValidLatitude2.default;
|
|
1595
|
+
} });
|
|
1596
|
+
Object.defineProperty(exports, "isValidLongitude", { enumerable: true, get: function get() {
|
|
1597
|
+
return _isValidLongitude2.default;
|
|
1598
|
+
} });
|
|
1599
|
+
Object.defineProperty(exports, "orderByDistance", { enumerable: true, get: function get() {
|
|
1600
|
+
return _orderByDistance2.default;
|
|
1601
|
+
} });
|
|
1602
|
+
Object.defineProperty(exports, "sexagesimalToDecimal", { enumerable: true, get: function get() {
|
|
1603
|
+
return _sexagesimalToDecimal2.default;
|
|
1604
|
+
} });
|
|
1605
|
+
Object.defineProperty(exports, "toDecimal", { enumerable: true, get: function get() {
|
|
1606
|
+
return _toDecimal2.default;
|
|
1607
|
+
} });
|
|
1608
|
+
Object.defineProperty(exports, "toRad", { enumerable: true, get: function get() {
|
|
1609
|
+
return _toRad2.default;
|
|
1610
|
+
} });
|
|
1611
|
+
Object.defineProperty(exports, "toDeg", { enumerable: true, get: function get() {
|
|
1612
|
+
return _toDeg2.default;
|
|
1613
|
+
} });
|
|
1614
|
+
Object.defineProperty(exports, "wktToPolygon", { enumerable: true, get: function get() {
|
|
1615
|
+
return _wktToPolygon.default;
|
|
1616
|
+
} });
|
|
1617
|
+
var _computeDestinationPoint = _interopRequireDefault2(computeDestinationPoint$1);
|
|
1618
|
+
var _convertArea = _interopRequireDefault2(convertArea$1);
|
|
1619
|
+
var _convertDistance = _interopRequireDefault2(convertDistance$1);
|
|
1620
|
+
var _convertSpeed = _interopRequireDefault2(convertSpeed$1);
|
|
1621
|
+
var _decimalToSexagesimal = _interopRequireDefault2(decimalToSexagesimal);
|
|
1622
|
+
var _findNearest = _interopRequireDefault2(findNearest$1);
|
|
1623
|
+
var _getAreaOfPolygon = _interopRequireDefault2(getAreaOfPolygon$1);
|
|
1624
|
+
var _getBounds2 = _interopRequireDefault2(getBounds$1);
|
|
1625
|
+
var _getBoundsOfDistance = _interopRequireDefault2(getBoundsOfDistance$1);
|
|
1626
|
+
var _getCenter = _interopRequireDefault2(getCenter$1);
|
|
1627
|
+
var _getCenterOfBounds = _interopRequireDefault2(getCenterOfBounds$1);
|
|
1628
|
+
var _getCompassDirection = _interopRequireDefault2(getCompassDirection$1);
|
|
1629
|
+
var _getCoordinateKey2 = _interopRequireDefault2(getCoordinateKey$1);
|
|
1630
|
+
var _getCoordinateKeys3 = _interopRequireDefault2(getCoordinateKeys$1);
|
|
1631
|
+
var _getDistance2 = _interopRequireDefault2(getDistance$2);
|
|
1632
|
+
var _getDistanceFromLine2 = _interopRequireDefault2(getDistanceFromLine$1);
|
|
1633
|
+
var _getGreatCircleBearing = _interopRequireDefault2(getGreatCircleBearing$1);
|
|
1634
|
+
var _getLatitude2 = _interopRequireDefault2(getLatitude$1);
|
|
1635
|
+
var _getLongitude2 = _interopRequireDefault2(getLongitude$1);
|
|
1636
|
+
var _getPathLength = _interopRequireDefault2(getPathLength$1);
|
|
1637
|
+
var _getPreciseDistance = _interopRequireDefault2(getPreciseDistance);
|
|
1638
|
+
var _getRhumbLineBearing2 = _interopRequireDefault2(getRhumbLineBearing$1);
|
|
1639
|
+
var _getRoughCompassDirection = _interopRequireDefault2(getRoughCompassDirection$1);
|
|
1640
|
+
var _getSpeed = _interopRequireDefault2(getSpeed$1);
|
|
1641
|
+
var _isDecimal2 = _interopRequireDefault2(isDecimal$1);
|
|
1642
|
+
var _isPointInLine = _interopRequireDefault2(isPointInLine$1);
|
|
1643
|
+
var _isPointInPolygon = _interopRequireDefault2(isPointInPolygon$1);
|
|
1644
|
+
var _isPointNearLine = _interopRequireDefault2(isPointNearLine$1);
|
|
1645
|
+
var _isPointWithinRadius = _interopRequireDefault2(isPointWithinRadius$1);
|
|
1646
|
+
var _isSexagesimal2 = _interopRequireDefault2(isSexagesimal$1);
|
|
1647
|
+
var _isValidCoordinate2 = _interopRequireDefault2(isValidCoordinate$1);
|
|
1648
|
+
var _isValidLatitude2 = _interopRequireDefault2(isValidLatitude$1);
|
|
1649
|
+
var _isValidLongitude2 = _interopRequireDefault2(isValidLongitude$1);
|
|
1650
|
+
var _orderByDistance2 = _interopRequireDefault2(orderByDistance$1);
|
|
1651
|
+
var _sexagesimalToDecimal2 = _interopRequireDefault2(sexagesimalToDecimal$1);
|
|
1652
|
+
var _toDecimal2 = _interopRequireDefault2(toDecimal$1);
|
|
1653
|
+
var _toRad2 = _interopRequireDefault2(toRad$1);
|
|
1654
|
+
var _toDeg2 = _interopRequireDefault2(toDeg$1);
|
|
1655
|
+
var _wktToPolygon = _interopRequireDefault2(wktToPolygon$1);
|
|
1656
|
+
var _constants2 = constants;
|
|
1657
|
+
Object.keys(_constants2).forEach(function(key) {
|
|
1658
|
+
if (key === "default" || key === "__esModule") return;
|
|
1659
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
1660
|
+
Object.defineProperty(exports, key, { enumerable: true, get: function get() {
|
|
1661
|
+
return _constants2[key];
|
|
1662
|
+
} });
|
|
1663
|
+
});
|
|
1664
|
+
function _interopRequireDefault2(obj) {
|
|
1665
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1666
|
+
}
|
|
1667
|
+
})(es);
|
|
1668
|
+
const vs = `/**
|
|
1669
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
1670
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
1671
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
1672
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
1673
|
+
*/
|
|
1674
|
+
|
|
1675
|
+
#define SHADER_NAME "arrow-layer-vertex-shader"
|
|
1676
|
+
|
|
1677
|
+
precision highp float;
|
|
1678
|
+
|
|
1679
|
+
attribute vec3 positions;
|
|
1680
|
+
|
|
1681
|
+
attribute float instanceSize;
|
|
1682
|
+
attribute float instanceArrowDistance;
|
|
1683
|
+
attribute vec4 instanceColor;
|
|
1684
|
+
attribute float instanceSpeedFactor;
|
|
1685
|
+
attribute float instanceLinePositionsTextureOffset;
|
|
1686
|
+
attribute float instanceLineDistancesTextureOffset;
|
|
1687
|
+
attribute float instanceLinePointCount;
|
|
1688
|
+
attribute float instanceLineDistance;
|
|
1689
|
+
attribute float instanceArrowDirection;
|
|
1690
|
+
attribute float instanceLineParallelIndex;
|
|
1691
|
+
attribute vec3 instanceLineAngles;
|
|
1692
|
+
attribute vec2 instanceProximityFactors;
|
|
1693
|
+
|
|
1694
|
+
uniform float sizeMinPixels;
|
|
1695
|
+
uniform float sizeMaxPixels;
|
|
1696
|
+
uniform float timestamp;
|
|
1697
|
+
uniform sampler2D linePositionsTexture;
|
|
1698
|
+
uniform sampler2D lineDistancesTexture;
|
|
1699
|
+
uniform ivec2 linePositionsTextureSize;
|
|
1700
|
+
uniform ivec2 lineDistancesTextureSize;
|
|
1701
|
+
uniform float webgl2;
|
|
1702
|
+
uniform float distanceBetweenLines;
|
|
1703
|
+
uniform float maxParallelOffset;
|
|
1704
|
+
uniform float minParallelOffset;
|
|
1705
|
+
uniform float opacity;
|
|
1706
|
+
|
|
1707
|
+
varying vec4 vFillColor;
|
|
1708
|
+
varying float shouldDiscard;
|
|
1709
|
+
|
|
1710
|
+
vec4 texelFetch(sampler2D sampler, ivec2 index, ivec2 size) {
|
|
1711
|
+
float x = (2.0 * float(index.x) + 1.0) / (2.0 * float(size.x));
|
|
1712
|
+
float y = (2.0 * float(index.y) + 1.0) / (2.0 * float(size.y));
|
|
1713
|
+
return texture2D(sampler, vec2(x, y));
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Calculate 2 dimensions texture index from flat index.
|
|
1718
|
+
*/
|
|
1719
|
+
ivec2 calculateTextureIndex(int flatIndex, ivec2 textureSize) {
|
|
1720
|
+
int x = flatIndex - flatIndex / textureSize.x * textureSize.x;
|
|
1721
|
+
int y = flatIndex / textureSize.y;
|
|
1722
|
+
return ivec2(x, y);
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Fetch WGS84 position from texture for a given point of the line.
|
|
1727
|
+
*/
|
|
1728
|
+
vec3 fetchLinePosition(int point) {
|
|
1729
|
+
int flatIndex = int(instanceLinePositionsTextureOffset) + point;
|
|
1730
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, linePositionsTextureSize);
|
|
1731
|
+
vec4 color = texelFetch(linePositionsTexture, textureIndex, linePositionsTextureSize);
|
|
1732
|
+
float x = color.r;
|
|
1733
|
+
float y = webgl2 > 0.5 ? color.g : color.a;
|
|
1734
|
+
return vec3(x, y, 0);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Fetch distance (in meters from the start of the line) from texture for a point of the line.
|
|
1739
|
+
*/
|
|
1740
|
+
float fetchLineDistance(int point) {
|
|
1741
|
+
int flatIndex = int(instanceLineDistancesTextureOffset) + point;
|
|
1742
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, lineDistancesTextureSize);
|
|
1743
|
+
return texelFetch(lineDistancesTexture, textureIndex, lineDistancesTextureSize).r;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* Find the first point of the line that is after a given distance from the start (first line point).
|
|
1748
|
+
* (implemented using a binary search)
|
|
1749
|
+
* The returned value is always between 1 and instanceLinePointCount - 1, even if the searched distance is out of bounds
|
|
1750
|
+
* Here are example returned values for a path having points at distance 0.0, 10.0, 20.0
|
|
1751
|
+
* -1 => 1
|
|
1752
|
+
* 0 => 1
|
|
1753
|
+
* 1 => 1
|
|
1754
|
+
* 9 => 1
|
|
1755
|
+
* 10 => 2
|
|
1756
|
+
* 11 => 2
|
|
1757
|
+
* 19 => 2
|
|
1758
|
+
* 20 => 2
|
|
1759
|
+
* 21 => 2
|
|
1760
|
+
*/
|
|
1761
|
+
int findFirstLinePointAfterDistance(float distance) {
|
|
1762
|
+
int firstPoint = 0;
|
|
1763
|
+
int lastPoint = int(instanceLinePointCount) - 1;
|
|
1764
|
+
|
|
1765
|
+
// variable length loops are not supported in WebGL v1, it needs to be a constant and cannot be like in WebGL v2 an
|
|
1766
|
+
// attribute, so we suppose here that we won't have more that 2^log2MaxPointCount points per line...
|
|
1767
|
+
//
|
|
1768
|
+
// WARNING!!!!
|
|
1769
|
+
// also, we need to avoid break/return in the for loop even if search complete because with a WebGL1 browser
|
|
1770
|
+
// it is not possible to call texture2D inside a non deterministic piece of code
|
|
1771
|
+
// https://shadertoyunofficial.wordpress.com/2017/11/19/avoiding-compiler-crash-or-endless-compilation
|
|
1772
|
+
const int log2MaxPointCount = 15;
|
|
1773
|
+
for (int i = 0; i < log2MaxPointCount; i++) {
|
|
1774
|
+
if (firstPoint + 1 != lastPoint) {
|
|
1775
|
+
int middlePoint = (firstPoint + lastPoint) / 2;
|
|
1776
|
+
float middlePointDistance = fetchLineDistance(middlePoint);
|
|
1777
|
+
if (middlePointDistance <= distance) {
|
|
1778
|
+
firstPoint = middlePoint;
|
|
1779
|
+
} else {
|
|
1780
|
+
lastPoint = middlePoint;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return lastPoint;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
mat3 calculateRotation(vec3 commonPosition1, vec3 commonPosition2) {
|
|
1788
|
+
float angle = atan(commonPosition1.x - commonPosition2.x, commonPosition1.y - commonPosition2.y);
|
|
1789
|
+
if (instanceArrowDirection < 2.0) {
|
|
1790
|
+
angle += radians(180.0);
|
|
1791
|
+
}
|
|
1792
|
+
return mat3(cos(angle), sin(angle), 0, -sin(angle), cos(angle), 0, 0, 0, 0);
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* Adjustment factor for low zoom levels
|
|
1797
|
+
* Code from deck.gl/modules/core/src/shaderlib/project/project.glsl.ts. We don't have access to this method from here.
|
|
1798
|
+
* Just to call it from project_size_all_zoom_levels().
|
|
1799
|
+
* Function renamed to project_size_at_latitude_low_zoom, to prevent conflicts with the original code.
|
|
1800
|
+
*/
|
|
1801
|
+
float project_size_at_latitude_low_zoom(float lat) {
|
|
1802
|
+
float y = clamp(lat, -89.9, 89.9);
|
|
1803
|
+
return 1.0 / cos(radians(y));
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* Forked version of project_size() from deck.gl deck.gl/modules/core/src/shaderlib/project/project.glsl.ts
|
|
1808
|
+
* Converts the size from the world space (meters) to the common space.
|
|
1809
|
+
* When the zoom level is lower than 12 (zoomed out), we use the arrow latitude to calculate the projection.
|
|
1810
|
+
* When the zoom level is higher than 12 (zoomed in), we fallback on the standard deck.gl project_size() which uses geometry.position.y.
|
|
1811
|
+
* I'm not sure why there is a change at zoomLevel = 12, but there seem to be some optimizations on the deck.gl side
|
|
1812
|
+
* (see: https://github.com/visgl/deck.gl/blob/401d624c0529faaa62125714c376b3ba3b8f379f/dev-docs/RFCs/v6.1/improved-lnglat-projection-rfc.md?plain=1#L29)
|
|
1813
|
+
*/
|
|
1814
|
+
float project_size_all_zoom_levels(float meters, float lat) {
|
|
1815
|
+
// We use project_uScale = 4096 (2^12) which corresponds to zoom = 12
|
|
1816
|
+
if (project_uScale < 4096.0) {
|
|
1817
|
+
return meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude_low_zoom(lat);
|
|
1818
|
+
}
|
|
1819
|
+
return project_size(meters);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
void main(void ) {
|
|
1823
|
+
if (instanceArrowDirection < 1.0) {
|
|
1824
|
+
vFillColor = vec4(0, 0, 0, 0);
|
|
1825
|
+
shouldDiscard = 1.0;
|
|
1826
|
+
} else {
|
|
1827
|
+
// arrow distance from the line start shifted with current timestamp
|
|
1828
|
+
// 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)
|
|
1829
|
+
float arrowDistance = mod(
|
|
1830
|
+
instanceLineDistance * instanceArrowDistance +
|
|
1831
|
+
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * timestamp * instanceSpeedFactor,
|
|
1832
|
+
instanceLineDistance
|
|
1833
|
+
);
|
|
1834
|
+
|
|
1835
|
+
// look for first line point that is after arrow distance
|
|
1836
|
+
int linePoint = findFirstLinePointAfterDistance(arrowDistance);
|
|
1837
|
+
|
|
1838
|
+
// Interpolate the 2 line points position
|
|
1839
|
+
float lineDistance1 = fetchLineDistance(linePoint - 1);
|
|
1840
|
+
float lineDistance2 = fetchLineDistance(linePoint);
|
|
1841
|
+
float interpolationValue = (arrowDistance - lineDistance1) / (lineDistance2 - lineDistance1);
|
|
1842
|
+
|
|
1843
|
+
// position for the line point just before the arrow
|
|
1844
|
+
vec3 linePosition1 = fetchLinePosition(linePoint - 1);
|
|
1845
|
+
|
|
1846
|
+
// position for the line point just after the arrow
|
|
1847
|
+
vec3 linePosition2 = fetchLinePosition(linePoint);
|
|
1848
|
+
|
|
1849
|
+
// clamp to arrow size limits
|
|
1850
|
+
float sizePixels = clamp(project_size_to_pixel(instanceSize), sizeMinPixels, sizeMaxPixels);
|
|
1851
|
+
|
|
1852
|
+
// project the 2 line points position to common space
|
|
1853
|
+
vec3 position64Low = vec3(0, 0, 0);
|
|
1854
|
+
vec3 commonPosition1 = project_position(linePosition1, position64Low);
|
|
1855
|
+
vec3 commonPosition2 = project_position(linePosition2, position64Low);
|
|
1856
|
+
|
|
1857
|
+
// We call our own project_size_all_zoom_levels() instead of project_size() from deck.gl as the latter causes a bug: the arrows
|
|
1858
|
+
// are not correctly positioned on the lines, they are slightly off.
|
|
1859
|
+
// This hack does not seem necessary for parallel-path or fork-line layers.
|
|
1860
|
+
vec3 arrowPositionWorldSpace = mix(linePosition1, linePosition2, interpolationValue);
|
|
1861
|
+
float offsetCommonSpace = clamp(
|
|
1862
|
+
project_size_all_zoom_levels(distanceBetweenLines, arrowPositionWorldSpace.y),
|
|
1863
|
+
project_pixel_size(minParallelOffset),
|
|
1864
|
+
project_pixel_size(maxParallelOffset)
|
|
1865
|
+
);
|
|
1866
|
+
|
|
1867
|
+
// calculate translation for the parallels lines, use the angle calculated from origin/destination
|
|
1868
|
+
// to maintain the same translation between segments
|
|
1869
|
+
float instanceLineAngle1 = instanceLineAngles[1];
|
|
1870
|
+
float instanceLineAngle2 = instanceLineAngles[1];
|
|
1871
|
+
if (linePoint == 1) {
|
|
1872
|
+
instanceLineAngle1 = instanceLineAngles[0];
|
|
1873
|
+
}
|
|
1874
|
+
if (linePoint == int(instanceLinePointCount) - 1) {
|
|
1875
|
+
instanceLineAngle2 = instanceLineAngles[2];
|
|
1876
|
+
}
|
|
1877
|
+
vec3 transOr = vec3(cos(instanceLineAngle1), -sin(instanceLineAngle1), 0.0) * instanceLineParallelIndex;
|
|
1878
|
+
if (linePoint == 1) {
|
|
1879
|
+
transOr.x -= sin(instanceLineAngle1) * instanceProximityFactors[0];
|
|
1880
|
+
transOr.y -= cos(instanceLineAngle1) * instanceProximityFactors[0];
|
|
1881
|
+
}
|
|
1882
|
+
commonPosition1 += transOr * offsetCommonSpace;
|
|
1883
|
+
vec3 transEx = vec3(cos(instanceLineAngle2), -sin(instanceLineAngle2), 0.0) * instanceLineParallelIndex;
|
|
1884
|
+
if (linePoint == int(instanceLinePointCount) - 1) {
|
|
1885
|
+
transEx.x += sin(instanceLineAngle2) * instanceProximityFactors[1];
|
|
1886
|
+
transEx.y += cos(instanceLineAngle2) * instanceProximityFactors[1];
|
|
1887
|
+
}
|
|
1888
|
+
commonPosition2 += transEx * offsetCommonSpace;
|
|
1889
|
+
|
|
1890
|
+
// calculate arrow position in the common space by interpolating the 2 line points position
|
|
1891
|
+
vec3 arrowPosition = mix(commonPosition1, commonPosition2, interpolationValue);
|
|
1892
|
+
|
|
1893
|
+
// calculate rotation angle for aligning the arrow with the line segment
|
|
1894
|
+
// it has to be done in the common space to get the right angle!!!
|
|
1895
|
+
mat3 rotation = calculateRotation(commonPosition1, commonPosition2);
|
|
1896
|
+
|
|
1897
|
+
// calculate vertex position in the clipspace
|
|
1898
|
+
vec3 offset = positions * project_pixel_size(sizePixels) * rotation;
|
|
1899
|
+
vec4 vertexPosition = project_common_position_to_clipspace(vec4(arrowPosition + offset, 1));
|
|
1900
|
+
|
|
1901
|
+
// vertex shader output
|
|
1902
|
+
gl_Position = vertexPosition;
|
|
1903
|
+
|
|
1904
|
+
// arrow fill color for fragment shader
|
|
1905
|
+
vFillColor = vec4(instanceColor.rgb, opacity);
|
|
1906
|
+
shouldDiscard = 0.0;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
`;
|
|
1910
|
+
const fs = '/**\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\n#define SHADER_NAME "arrow-layer-fragment-shader"\n\nprecision highp float;\n\nvarying vec4 vFillColor;\nvarying float shouldDiscard;\n\nvoid main(void ) {\n if (shouldDiscard > 0.0) {\n discard;\n }\n gl_FragColor = vFillColor;\n}\n';
|
|
1911
|
+
const DEFAULT_COLOR = [0, 0, 0, 255];
|
|
1912
|
+
const MAX_LINE_POINT_COUNT = 2 ** 15;
|
|
1913
|
+
var ArrowDirection = /* @__PURE__ */ ((ArrowDirection2) => {
|
|
1914
|
+
ArrowDirection2["NONE"] = "none";
|
|
1915
|
+
ArrowDirection2["FROM_SIDE_1_TO_SIDE_2"] = "fromSide1ToSide2";
|
|
1916
|
+
ArrowDirection2["FROM_SIDE_2_TO_SIDE_1"] = "fromSide2ToSide1";
|
|
1917
|
+
return ArrowDirection2;
|
|
1918
|
+
})(ArrowDirection || {});
|
|
1919
|
+
const defaultProps$3 = {
|
|
1920
|
+
sizeMinPixels: { type: "number", min: 0, value: 0 },
|
|
1921
|
+
// min size in pixels
|
|
1922
|
+
sizeMaxPixels: { type: "number", min: 0, value: Number.MAX_SAFE_INTEGER },
|
|
1923
|
+
// max size in pixels
|
|
1924
|
+
getDistance: { type: "accessor", value: (arrow) => arrow.distance },
|
|
1925
|
+
getLine: { type: "accessor", value: (arrow) => arrow.line },
|
|
1926
|
+
getLinePositions: { type: "accessor", value: (line) => line.positions ?? [] },
|
|
1927
|
+
getSize: { type: "accessor", value: 1 },
|
|
1928
|
+
getColor: { type: "accessor", value: DEFAULT_COLOR },
|
|
1929
|
+
getSpeedFactor: { type: "accessor", value: 1 },
|
|
1930
|
+
getDirection: {
|
|
1931
|
+
type: "accessor",
|
|
1932
|
+
value: "none"
|
|
1933
|
+
/* NONE */
|
|
1934
|
+
},
|
|
1935
|
+
animated: { type: "boolean", value: true },
|
|
1936
|
+
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
1937
|
+
getLineAngles: { type: "accessor", value: [0, 0, 0] },
|
|
1938
|
+
// @ts-expect-error TODO TS2322: distanceBetweenLines does not exist in type DefaultProps<ArrowLayerProps>. Did you mean to write getDistanceBetweenLines?
|
|
1939
|
+
distanceBetweenLines: { type: "number", value: 1e3 },
|
|
1940
|
+
maxParallelOffset: { type: "number", value: 100 },
|
|
1941
|
+
minParallelOffset: { type: "number", value: 3 },
|
|
1942
|
+
opacity: { type: "number", value: 1 }
|
|
1943
|
+
};
|
|
1944
|
+
const _ArrowLayer = class _ArrowLayer extends Layer {
|
|
1945
|
+
getShaders() {
|
|
1946
|
+
return super.getShaders({ vs, fs, modules: [project32, picking] });
|
|
1947
|
+
}
|
|
1948
|
+
getArrowLineAttributes(arrow) {
|
|
1949
|
+
var _a;
|
|
1950
|
+
const line = this.props.getLine(arrow);
|
|
1951
|
+
if (!line) {
|
|
1952
|
+
throw new Error("Invalid line");
|
|
1953
|
+
}
|
|
1954
|
+
const attributes = (_a = this.state.lineAttributes) == null ? void 0 : _a.get(line);
|
|
1955
|
+
if (!attributes) {
|
|
1956
|
+
throw new Error(`Line ${line.id} not found`);
|
|
1957
|
+
}
|
|
1958
|
+
return attributes;
|
|
1959
|
+
}
|
|
1960
|
+
initializeState() {
|
|
1961
|
+
var _a;
|
|
1962
|
+
const { gl } = this.context;
|
|
1963
|
+
if (!hasFeatures(gl, [FEATURES.TEXTURE_FLOAT])) {
|
|
1964
|
+
throw new Error("Arrow layer not supported on this browser");
|
|
1965
|
+
}
|
|
1966
|
+
const maxTextureSize = gl.getParameter(GL.MAX_TEXTURE_SIZE);
|
|
1967
|
+
this.state = {
|
|
1968
|
+
maxTextureSize,
|
|
1969
|
+
webgl2: isWebGL2(gl)
|
|
1970
|
+
};
|
|
1971
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.addInstanced({
|
|
1972
|
+
instanceSize: {
|
|
1973
|
+
size: 1,
|
|
1974
|
+
transition: true,
|
|
1975
|
+
accessor: "getSize",
|
|
1976
|
+
defaultValue: 1
|
|
1977
|
+
},
|
|
1978
|
+
instanceColor: {
|
|
1979
|
+
size: this.props.colorFormat.length,
|
|
1980
|
+
transition: true,
|
|
1981
|
+
normalized: true,
|
|
1982
|
+
type: GL.UNSIGNED_BYTE,
|
|
1983
|
+
accessor: "getColor",
|
|
1984
|
+
defaultValue: [0, 0, 0, 255]
|
|
1985
|
+
},
|
|
1986
|
+
instanceSpeedFactor: {
|
|
1987
|
+
size: 1,
|
|
1988
|
+
transition: true,
|
|
1989
|
+
accessor: "getSpeedFactor",
|
|
1990
|
+
defaultValue: 1
|
|
1991
|
+
},
|
|
1992
|
+
instanceArrowDistance: {
|
|
1993
|
+
size: 1,
|
|
1994
|
+
transition: true,
|
|
1995
|
+
accessor: "getDistance",
|
|
1996
|
+
type: GL.FLOAT,
|
|
1997
|
+
defaultValue: 0
|
|
1998
|
+
},
|
|
1999
|
+
instanceArrowDirection: {
|
|
2000
|
+
size: 1,
|
|
2001
|
+
transition: true,
|
|
2002
|
+
accessor: "getDirection",
|
|
2003
|
+
transform: (direction) => {
|
|
2004
|
+
switch (direction) {
|
|
2005
|
+
case "none":
|
|
2006
|
+
return 0;
|
|
2007
|
+
case "fromSide1ToSide2":
|
|
2008
|
+
return 1;
|
|
2009
|
+
case "fromSide2ToSide1":
|
|
2010
|
+
return 2;
|
|
2011
|
+
default:
|
|
2012
|
+
throw new Error("impossible");
|
|
2013
|
+
}
|
|
2014
|
+
},
|
|
2015
|
+
defaultValue: 0
|
|
2016
|
+
},
|
|
2017
|
+
instanceLineDistance: {
|
|
2018
|
+
size: 1,
|
|
2019
|
+
transition: true,
|
|
2020
|
+
type: GL.FLOAT,
|
|
2021
|
+
accessor: (arrow) => this.getArrowLineAttributes(arrow).distance
|
|
2022
|
+
},
|
|
2023
|
+
instanceLinePositionsTextureOffset: {
|
|
2024
|
+
size: 1,
|
|
2025
|
+
transition: true,
|
|
2026
|
+
type: GL.FLOAT,
|
|
2027
|
+
accessor: (arrow) => this.getArrowLineAttributes(arrow).positionsTextureOffset
|
|
2028
|
+
},
|
|
2029
|
+
instanceLineDistancesTextureOffset: {
|
|
2030
|
+
size: 1,
|
|
2031
|
+
transition: true,
|
|
2032
|
+
type: GL.FLOAT,
|
|
2033
|
+
accessor: (arrow) => this.getArrowLineAttributes(arrow).distancesTextureOffset
|
|
2034
|
+
},
|
|
2035
|
+
instanceLinePointCount: {
|
|
2036
|
+
size: 1,
|
|
2037
|
+
transition: true,
|
|
2038
|
+
type: GL.FLOAT,
|
|
2039
|
+
accessor: (arrow) => this.getArrowLineAttributes(arrow).pointCount
|
|
2040
|
+
},
|
|
2041
|
+
instanceLineParallelIndex: {
|
|
2042
|
+
size: 1,
|
|
2043
|
+
accessor: "getLineParallelIndex",
|
|
2044
|
+
type: GL.FLOAT
|
|
2045
|
+
},
|
|
2046
|
+
instanceLineAngles: {
|
|
2047
|
+
size: 3,
|
|
2048
|
+
accessor: "getLineAngles",
|
|
2049
|
+
type: GL.FLOAT
|
|
2050
|
+
},
|
|
2051
|
+
instanceProximityFactors: {
|
|
2052
|
+
size: 2,
|
|
2053
|
+
accessor: "getProximityFactors",
|
|
2054
|
+
type: GL.FLOAT
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
finalizeState(context) {
|
|
2059
|
+
super.finalizeState(context);
|
|
2060
|
+
this.state.stop = true;
|
|
2061
|
+
}
|
|
2062
|
+
createTexture2D(gl, data, elementSize, format, dataFormat) {
|
|
2063
|
+
const start = performance.now();
|
|
2064
|
+
const elementCount = data.length / elementSize;
|
|
2065
|
+
const n = Math.ceil(Math.log2(elementCount) / 2);
|
|
2066
|
+
const textureSize = 2 ** n;
|
|
2067
|
+
const { maxTextureSize } = this.state;
|
|
2068
|
+
if (textureSize > maxTextureSize) {
|
|
2069
|
+
throw new Error(`Texture size (${textureSize}) cannot be greater than ${maxTextureSize}`);
|
|
2070
|
+
}
|
|
2071
|
+
if (data.length < textureSize * textureSize * elementSize) {
|
|
2072
|
+
const oldLength = data.length;
|
|
2073
|
+
data.length = textureSize * textureSize * elementSize;
|
|
2074
|
+
data.fill(0, oldLength, textureSize * textureSize * elementSize);
|
|
2075
|
+
}
|
|
2076
|
+
const texture2d = new Texture2D(gl, {
|
|
2077
|
+
width: textureSize,
|
|
2078
|
+
height: textureSize,
|
|
2079
|
+
format,
|
|
2080
|
+
dataFormat,
|
|
2081
|
+
type: GL.FLOAT,
|
|
2082
|
+
data: new Float32Array(data),
|
|
2083
|
+
parameters: {
|
|
2084
|
+
[GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
|
|
2085
|
+
[GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
|
|
2086
|
+
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
2087
|
+
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
2088
|
+
},
|
|
2089
|
+
mipmaps: false
|
|
2090
|
+
});
|
|
2091
|
+
const stop = performance.now();
|
|
2092
|
+
console.info(
|
|
2093
|
+
`Texture of ${elementCount} elements (${textureSize} * ${textureSize}) created in ${stop - start} ms`
|
|
2094
|
+
);
|
|
2095
|
+
return texture2d;
|
|
2096
|
+
}
|
|
2097
|
+
createTexturesStructure(props) {
|
|
2098
|
+
const start = performance.now();
|
|
2099
|
+
const linePositionsTextureData = [];
|
|
2100
|
+
const lineDistancesTextureData = [];
|
|
2101
|
+
const lineAttributes = /* @__PURE__ */ new Map();
|
|
2102
|
+
let lineDistance = 0;
|
|
2103
|
+
const lines = [...new Set(props.data.map((arrow) => this.props.getLine(arrow)))];
|
|
2104
|
+
lines.forEach((line) => {
|
|
2105
|
+
const positions = props.getLinePositions(line);
|
|
2106
|
+
if (!positions) {
|
|
2107
|
+
throw new Error(`Invalid positions for line ${line.id}`);
|
|
2108
|
+
}
|
|
2109
|
+
const linePositionsTextureOffset = linePositionsTextureData.length / 2;
|
|
2110
|
+
const lineDistancesTextureOffset = lineDistancesTextureData.length;
|
|
2111
|
+
let linePointCount = 0;
|
|
2112
|
+
if (positions.length > 0) {
|
|
2113
|
+
positions.forEach((position) => {
|
|
2114
|
+
linePositionsTextureData.push(position[0]);
|
|
2115
|
+
linePositionsTextureData.push(position[1]);
|
|
2116
|
+
linePointCount++;
|
|
2117
|
+
});
|
|
2118
|
+
lineDistancesTextureData.push(...line.cumulativeDistances ?? []);
|
|
2119
|
+
lineDistance = line.cumulativeDistances[line.cumulativeDistances.length - 1];
|
|
2120
|
+
}
|
|
2121
|
+
if (linePointCount > MAX_LINE_POINT_COUNT) {
|
|
2122
|
+
throw new Error(`Too many line point count (${linePointCount}), maximum is ${MAX_LINE_POINT_COUNT}`);
|
|
2123
|
+
}
|
|
2124
|
+
lineAttributes.set(line, {
|
|
2125
|
+
distance: lineDistance,
|
|
2126
|
+
positionsTextureOffset: linePositionsTextureOffset,
|
|
2127
|
+
distancesTextureOffset: lineDistancesTextureOffset,
|
|
2128
|
+
pointCount: linePointCount
|
|
2129
|
+
});
|
|
2130
|
+
});
|
|
2131
|
+
const stop = performance.now();
|
|
2132
|
+
console.info(`Texture data created in ${stop - start} ms`);
|
|
2133
|
+
return {
|
|
2134
|
+
linePositionsTextureData,
|
|
2135
|
+
lineDistancesTextureData,
|
|
2136
|
+
lineAttributes
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
updateGeometry({ props, changeFlags }) {
|
|
2140
|
+
var _a;
|
|
2141
|
+
const geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getLinePositions);
|
|
2142
|
+
if (geometryChanged) {
|
|
2143
|
+
const { gl } = this.context;
|
|
2144
|
+
const { linePositionsTextureData, lineDistancesTextureData, lineAttributes } = this.createTexturesStructure(props);
|
|
2145
|
+
const linePositionsTexture = this.createTexture2D(
|
|
2146
|
+
gl,
|
|
2147
|
+
linePositionsTextureData,
|
|
2148
|
+
2,
|
|
2149
|
+
this.state.webgl2 ? GL.RG32F : GL.LUMINANCE_ALPHA,
|
|
2150
|
+
this.state.webgl2 ? GL.RG : GL.LUMINANCE_ALPHA
|
|
2151
|
+
);
|
|
2152
|
+
const lineDistancesTexture = this.createTexture2D(
|
|
2153
|
+
gl,
|
|
2154
|
+
lineDistancesTextureData,
|
|
2155
|
+
1,
|
|
2156
|
+
this.state.webgl2 ? GL.R32F : GL.LUMINANCE,
|
|
2157
|
+
this.state.webgl2 ? GL.RED : GL.LUMINANCE
|
|
2158
|
+
);
|
|
2159
|
+
this.setState({
|
|
2160
|
+
linePositionsTexture,
|
|
2161
|
+
lineDistancesTexture,
|
|
2162
|
+
lineAttributes
|
|
2163
|
+
});
|
|
2164
|
+
if (!changeFlags.dataChanged) {
|
|
2165
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.invalidateAll();
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
updateModel({ changeFlags }) {
|
|
2170
|
+
var _a;
|
|
2171
|
+
if (changeFlags.extensionsChanged) {
|
|
2172
|
+
const { gl } = this.context;
|
|
2173
|
+
const { model } = this.state;
|
|
2174
|
+
if (model) {
|
|
2175
|
+
model.delete();
|
|
2176
|
+
}
|
|
2177
|
+
this.setState({
|
|
2178
|
+
model: this._getModel(gl)
|
|
2179
|
+
});
|
|
2180
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.invalidateAll();
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
updateState(updateParams) {
|
|
2184
|
+
super.updateState(updateParams);
|
|
2185
|
+
this.updateGeometry(updateParams);
|
|
2186
|
+
this.updateModel(updateParams);
|
|
2187
|
+
const { props, oldProps } = updateParams;
|
|
2188
|
+
if (props.animated !== oldProps.animated) {
|
|
2189
|
+
this.setState({
|
|
2190
|
+
stop: !props.animated,
|
|
2191
|
+
timestamp: 0
|
|
2192
|
+
});
|
|
2193
|
+
if (props.animated) {
|
|
2194
|
+
this.startAnimation();
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
animate(timestamp) {
|
|
2199
|
+
if (this.state.stop) {
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2202
|
+
this.setState({
|
|
2203
|
+
timestamp
|
|
2204
|
+
});
|
|
2205
|
+
this.startAnimation();
|
|
2206
|
+
}
|
|
2207
|
+
startAnimation() {
|
|
2208
|
+
window.requestAnimationFrame((timestamp) => this.animate(timestamp));
|
|
2209
|
+
}
|
|
2210
|
+
// TODO find the full type for record values
|
|
2211
|
+
draw({ uniforms }) {
|
|
2212
|
+
var _a;
|
|
2213
|
+
const { sizeMinPixels, sizeMaxPixels } = this.props;
|
|
2214
|
+
const { linePositionsTexture, lineDistancesTexture, timestamp, webgl2 } = this.state;
|
|
2215
|
+
(_a = this.state.model) == null ? void 0 : _a.setUniforms(uniforms).setUniforms({
|
|
2216
|
+
sizeMinPixels,
|
|
2217
|
+
sizeMaxPixels,
|
|
2218
|
+
linePositionsTexture,
|
|
2219
|
+
lineDistancesTexture,
|
|
2220
|
+
// TODO we ask an opacity but we don't seem to set or used it?
|
|
2221
|
+
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2222
|
+
linePositionsTextureSize: [linePositionsTexture == null ? void 0 : linePositionsTexture.width, linePositionsTexture == null ? void 0 : linePositionsTexture.height],
|
|
2223
|
+
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2224
|
+
lineDistancesTextureSize: [lineDistancesTexture == null ? void 0 : lineDistancesTexture.width, lineDistancesTexture == null ? void 0 : lineDistancesTexture.height],
|
|
2225
|
+
timestamp,
|
|
2226
|
+
webgl2,
|
|
2227
|
+
distanceBetweenLines: this.props.getDistanceBetweenLines,
|
|
2228
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
2229
|
+
minParallelOffset: this.props.minParallelOffset
|
|
2230
|
+
}).draw();
|
|
2231
|
+
}
|
|
2232
|
+
// TODO Did you mean getModels?
|
|
2233
|
+
_getModel(gl) {
|
|
2234
|
+
return new Model(
|
|
2235
|
+
gl,
|
|
2236
|
+
Object.assign(this.getShaders(), {
|
|
2237
|
+
id: this.props.id,
|
|
2238
|
+
geometry: new Geometry({
|
|
2239
|
+
drawMode: GL.TRIANGLES,
|
|
2240
|
+
vertexCount: 6,
|
|
2241
|
+
attributes: {
|
|
2242
|
+
positions: {
|
|
2243
|
+
size: 3,
|
|
2244
|
+
value: new Float32Array([-1, -1, 0, 0, 1, 0, 0, -0.6, 0, 1, -1, 0, 0, 1, 0, 0, -0.6, 0])
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}),
|
|
2248
|
+
isInstanced: true
|
|
2249
|
+
})
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
_ArrowLayer.layerName = "ArrowLayer";
|
|
2254
|
+
_ArrowLayer.defaultProps = defaultProps$3;
|
|
2255
|
+
let ArrowLayer = _ArrowLayer;
|
|
2256
|
+
const substationPositionByIdIndexer = (map, substation) => {
|
|
2257
|
+
map.set(substation.id, substation.coordinate);
|
|
2258
|
+
return map;
|
|
2259
|
+
};
|
|
2260
|
+
const linePositionByIdIndexer = (map, line) => {
|
|
2261
|
+
map.set(line.id, line.coordinates);
|
|
2262
|
+
return map;
|
|
2263
|
+
};
|
|
2264
|
+
class GeoData {
|
|
2265
|
+
constructor(substationPositionsById, linePositionsById) {
|
|
2266
|
+
this.substationPositionsById = /* @__PURE__ */ new Map();
|
|
2267
|
+
this.linePositionsById = /* @__PURE__ */ new Map();
|
|
2268
|
+
this.substationPositionsById = substationPositionsById;
|
|
2269
|
+
this.linePositionsById = linePositionsById;
|
|
2270
|
+
}
|
|
2271
|
+
setSubstationPositions(positions) {
|
|
2272
|
+
this.substationPositionsById = positions.reduce(substationPositionByIdIndexer, /* @__PURE__ */ new Map());
|
|
2273
|
+
}
|
|
2274
|
+
updateSubstationPositions(substationIdsToUpdate, fetchedPositions) {
|
|
2275
|
+
fetchedPositions.forEach((pos) => this.substationPositionsById.set(pos.id, pos.coordinate));
|
|
2276
|
+
substationIdsToUpdate.filter((id) => !fetchedPositions.map((pos) => pos.id).includes(id)).forEach((id) => this.substationPositionsById.delete(id));
|
|
2277
|
+
}
|
|
2278
|
+
getSubstationPosition(substationId) {
|
|
2279
|
+
const position = this.substationPositionsById.get(substationId);
|
|
2280
|
+
if (!position) {
|
|
2281
|
+
console.warn(`Position not found for ${substationId}`);
|
|
2282
|
+
return [0, 0];
|
|
2283
|
+
}
|
|
2284
|
+
return [position.lon, position.lat];
|
|
2285
|
+
}
|
|
2286
|
+
setLinePositions(positions) {
|
|
2287
|
+
this.linePositionsById = positions.reduce(linePositionByIdIndexer, /* @__PURE__ */ new Map());
|
|
2288
|
+
}
|
|
2289
|
+
updateLinePositions(lineIdsToUpdate, fetchedPositions) {
|
|
2290
|
+
fetchedPositions.forEach((pos) => {
|
|
2291
|
+
this.linePositionsById.set(pos.id, pos.coordinates);
|
|
2292
|
+
});
|
|
2293
|
+
lineIdsToUpdate.filter((id) => !fetchedPositions.map((pos) => pos.id).includes(id)).forEach((id) => this.linePositionsById.delete(id));
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Get line positions always ordered from side 1 to side 2.
|
|
2297
|
+
*/
|
|
2298
|
+
getLinePositions(network, line, detailed = true) {
|
|
2299
|
+
const voltageLevel1 = network.getVoltageLevel(line.voltageLevelId1);
|
|
2300
|
+
if (!voltageLevel1) {
|
|
2301
|
+
throw new Error(`Voltage level side 1 '${line.voltageLevelId1}' not found`);
|
|
2302
|
+
}
|
|
2303
|
+
const voltageLevel2 = network.getVoltageLevel(line.voltageLevelId2);
|
|
2304
|
+
if (!voltageLevel2) {
|
|
2305
|
+
throw new Error(`Voltage level side 2 '${line.voltageLevelId1}' not found`);
|
|
2306
|
+
}
|
|
2307
|
+
const substationPosition1 = this.getSubstationPosition(voltageLevel1.substationId);
|
|
2308
|
+
const substationPosition2 = this.getSubstationPosition(voltageLevel2.substationId);
|
|
2309
|
+
if (substationPosition1[0] === 0 && substationPosition1[1] === 0 || substationPosition2[0] === 0 && substationPosition2[1] === 0) {
|
|
2310
|
+
return [
|
|
2311
|
+
[0, 0],
|
|
2312
|
+
[0, 0]
|
|
2313
|
+
];
|
|
2314
|
+
}
|
|
2315
|
+
if (detailed) {
|
|
2316
|
+
const linePositions = this.linePositionsById.get(line.id);
|
|
2317
|
+
if (linePositions) {
|
|
2318
|
+
const positions = new Array(linePositions.length);
|
|
2319
|
+
for (const [index, position] of linePositions.entries()) {
|
|
2320
|
+
positions[index] = [position.lon, position.lat];
|
|
2321
|
+
}
|
|
2322
|
+
return positions;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
return [substationPosition1, substationPosition2];
|
|
2326
|
+
}
|
|
2327
|
+
getLineDistances(positions) {
|
|
2328
|
+
if (positions !== null && positions.length > 1) {
|
|
2329
|
+
const cumulativeDistanceArray = [0];
|
|
2330
|
+
let cumulativeDistance = 0;
|
|
2331
|
+
let segmentDistance;
|
|
2332
|
+
let ruler;
|
|
2333
|
+
for (let i = 0; i < positions.length - 1; i++) {
|
|
2334
|
+
ruler = new CheapRuler(positions[i][1], "meters");
|
|
2335
|
+
segmentDistance = ruler.lineDistance(positions.slice(i, i + 2));
|
|
2336
|
+
cumulativeDistance = cumulativeDistance + segmentDistance;
|
|
2337
|
+
cumulativeDistanceArray[i + 1] = cumulativeDistance;
|
|
2338
|
+
}
|
|
2339
|
+
return cumulativeDistanceArray;
|
|
2340
|
+
}
|
|
2341
|
+
return null;
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Find the segment in which we reach the wanted distance and return the segment
|
|
2345
|
+
* along with the remaining distance to travel on this segment to be at the exact wanted distance
|
|
2346
|
+
* (implemented using a binary search)
|
|
2347
|
+
*/
|
|
2348
|
+
findSegment(positions, cumulativeDistances, wantedDistance) {
|
|
2349
|
+
let lowerBound = 0;
|
|
2350
|
+
let upperBound = cumulativeDistances.length - 1;
|
|
2351
|
+
let middlePoint;
|
|
2352
|
+
while (lowerBound + 1 !== upperBound) {
|
|
2353
|
+
middlePoint = Math.floor((lowerBound + upperBound) / 2);
|
|
2354
|
+
const middlePointDistance = cumulativeDistances[middlePoint];
|
|
2355
|
+
if (middlePointDistance <= wantedDistance) {
|
|
2356
|
+
lowerBound = middlePoint;
|
|
2357
|
+
} else {
|
|
2358
|
+
upperBound = middlePoint;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
return {
|
|
2362
|
+
idx: lowerBound,
|
|
2363
|
+
segment: positions.slice(lowerBound, lowerBound + 2),
|
|
2364
|
+
remainingDistance: wantedDistance - cumulativeDistances[lowerBound]
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
labelDisplayPosition(positions, cumulativeDistances, arrowPosition, arrowDirection, lineParallelIndex, lineAngle, proximityAngle, distanceBetweenLines, proximityFactor) {
|
|
2368
|
+
if (arrowPosition > 1 || arrowPosition < 0) {
|
|
2369
|
+
throw new Error("Proportional position value incorrect: " + arrowPosition);
|
|
2370
|
+
}
|
|
2371
|
+
if (cumulativeDistances === null || cumulativeDistances.length < 2 || cumulativeDistances[cumulativeDistances.length - 1] === 0) {
|
|
2372
|
+
return null;
|
|
2373
|
+
}
|
|
2374
|
+
const lineDistance = cumulativeDistances[cumulativeDistances.length - 1];
|
|
2375
|
+
let wantedDistance = lineDistance * arrowPosition;
|
|
2376
|
+
if (cumulativeDistances.length === 2) {
|
|
2377
|
+
wantedDistance = wantedDistance - 2 * distanceBetweenLines * arrowPosition * proximityFactor;
|
|
2378
|
+
}
|
|
2379
|
+
const goodSegment = this.findSegment(positions, cumulativeDistances, wantedDistance);
|
|
2380
|
+
let multiplier;
|
|
2381
|
+
switch (arrowDirection) {
|
|
2382
|
+
case ArrowDirection.FROM_SIDE_2_TO_SIDE_1:
|
|
2383
|
+
multiplier = 1.005;
|
|
2384
|
+
break;
|
|
2385
|
+
case ArrowDirection.FROM_SIDE_1_TO_SIDE_2:
|
|
2386
|
+
multiplier = 0.995;
|
|
2387
|
+
break;
|
|
2388
|
+
case ArrowDirection.NONE:
|
|
2389
|
+
multiplier = 1;
|
|
2390
|
+
break;
|
|
2391
|
+
default:
|
|
2392
|
+
throw new Error("impossible");
|
|
2393
|
+
}
|
|
2394
|
+
const remainingDistance = goodSegment.remainingDistance * multiplier;
|
|
2395
|
+
const angle = this.getMapAngle(goodSegment.segment[0], goodSegment.segment[1]);
|
|
2396
|
+
const neededOffset = this.getLabelOffset(angle, 20, arrowDirection);
|
|
2397
|
+
const position = {
|
|
2398
|
+
position: es.computeDestinationPoint(goodSegment.segment[0], remainingDistance, angle),
|
|
2399
|
+
angle,
|
|
2400
|
+
offset: neededOffset
|
|
2401
|
+
};
|
|
2402
|
+
position.position = es.computeDestinationPoint(
|
|
2403
|
+
position.position,
|
|
2404
|
+
distanceBetweenLines * lineParallelIndex,
|
|
2405
|
+
lineAngle + 90
|
|
2406
|
+
);
|
|
2407
|
+
if (cumulativeDistances.length === 2) {
|
|
2408
|
+
position.position = es.computeDestinationPoint(
|
|
2409
|
+
position.position,
|
|
2410
|
+
-distanceBetweenLines * proximityFactor,
|
|
2411
|
+
lineAngle
|
|
2412
|
+
);
|
|
2413
|
+
} else if (goodSegment.idx === 0 || goodSegment.idx === cumulativeDistances.length - 2) {
|
|
2414
|
+
const segmentDistance = cumulativeDistances[goodSegment.idx + 1] - cumulativeDistances[goodSegment.idx];
|
|
2415
|
+
const alreadyDoneDistance = segmentDistance - remainingDistance;
|
|
2416
|
+
let labelDistanceInSegment;
|
|
2417
|
+
if (goodSegment.idx === 0) {
|
|
2418
|
+
labelDistanceInSegment = -alreadyDoneDistance;
|
|
2419
|
+
} else {
|
|
2420
|
+
labelDistanceInSegment = remainingDistance;
|
|
2421
|
+
}
|
|
2422
|
+
const labelPercentage = labelDistanceInSegment / segmentDistance;
|
|
2423
|
+
position.position = es.computeDestinationPoint(
|
|
2424
|
+
position.position,
|
|
2425
|
+
distanceBetweenLines * labelPercentage,
|
|
2426
|
+
proximityAngle
|
|
2427
|
+
);
|
|
2428
|
+
}
|
|
2429
|
+
return position;
|
|
2430
|
+
}
|
|
2431
|
+
getLabelOffset(angle, offsetDistance, arrowDirection) {
|
|
2432
|
+
const radiantAngle = (-angle + 90) / (180 / Math.PI);
|
|
2433
|
+
let direction = 0;
|
|
2434
|
+
switch (arrowDirection) {
|
|
2435
|
+
case ArrowDirection.FROM_SIDE_2_TO_SIDE_1:
|
|
2436
|
+
direction = 1;
|
|
2437
|
+
break;
|
|
2438
|
+
case ArrowDirection.FROM_SIDE_1_TO_SIDE_2:
|
|
2439
|
+
direction = -1;
|
|
2440
|
+
break;
|
|
2441
|
+
case ArrowDirection.NONE:
|
|
2442
|
+
direction = 0;
|
|
2443
|
+
break;
|
|
2444
|
+
default:
|
|
2445
|
+
throw new Error("impossible");
|
|
2446
|
+
}
|
|
2447
|
+
return [
|
|
2448
|
+
Math.cos(radiantAngle) * offsetDistance * direction,
|
|
2449
|
+
-Math.sin(radiantAngle) * offsetDistance * direction
|
|
2450
|
+
];
|
|
2451
|
+
}
|
|
2452
|
+
//returns the angle between point1 and point2 in degrees [0-360)
|
|
2453
|
+
getMapAngle(point1, point2) {
|
|
2454
|
+
let angle = es.getRhumbLineBearing(point1, point2);
|
|
2455
|
+
const angle2 = es.getGreatCircleBearing(point1, point2);
|
|
2456
|
+
const coeff = 0.1;
|
|
2457
|
+
angle = coeff * angle + (1 - coeff) * angle2;
|
|
2458
|
+
return angle;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
const BoltIcon = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20enable-background='new%200%200%2024%2024'%20height='24px'%20viewBox='0%200%2024%2024'%20width='24px'%20fill='%23000000'%3e%3cg%3e%3crect%20fill='none'%20height='24'%20width='24'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M11,21h-1l1-7H7.5c-0.88,0-0.33-0.75-0.31-0.78C8.48,10.94,10.42,7.54,13.01,3h1l-1,7h3.51c0.4,0,0.62,0.19,0.4,0.66%20C12.97,17.55,11,21,11,21z'/%3e%3c/g%3e%3c/svg%3e";
|
|
2462
|
+
const PadlockIcon = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%200%2024%2024'%20width='24px'%20fill='%23000000'%3e%3cg%20fill='none'%3e%3cpath%20d='M0%200h24v24H0V0z'/%3e%3cpath%20d='M0%200h24v24H0V0z'%20opacity='.87'/%3e%3c/g%3e%3cpath%20d='M18%208h-1V6c0-2.76-2.24-5-5-5S7%203.24%207%206v2H6c-1.1%200-2%20.9-2%202v10c0%201.1.9%202%202%202h12c1.1%200%202-.9%202-2V10c0-1.1-.9-2-2-2zM9%206c0-1.66%201.34-3%203-3s3%201.34%203%203v2H9V6zm9%2014H6V10h12v10zm-6-3c1.1%200%202-.9%202-2s-.9-2-2-2-2%20.9-2%202%20.9%202%202%202z'/%3e%3c/svg%3e";
|
|
2463
|
+
function getNominalVoltageColor(nominalVoltage) {
|
|
2464
|
+
if (nominalVoltage >= 300) {
|
|
2465
|
+
return [255, 0, 0];
|
|
2466
|
+
} else if (nominalVoltage >= 170 && nominalVoltage < 300) {
|
|
2467
|
+
return [34, 139, 34];
|
|
2468
|
+
} else if (nominalVoltage >= 120 && nominalVoltage < 170) {
|
|
2469
|
+
return [1, 175, 175];
|
|
2470
|
+
} else if (nominalVoltage >= 70 && nominalVoltage < 120) {
|
|
2471
|
+
return [204, 85, 0];
|
|
2472
|
+
} else if (nominalVoltage >= 50 && nominalVoltage < 70) {
|
|
2473
|
+
return [160, 32, 240];
|
|
2474
|
+
} else if (nominalVoltage >= 30 && nominalVoltage < 50) {
|
|
2475
|
+
return [255, 130, 144];
|
|
2476
|
+
} else {
|
|
2477
|
+
return [171, 175, 40];
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
const INVALID_FLOW_OPACITY = 0.2;
|
|
2481
|
+
const SUBSTATION_RADIUS = 500;
|
|
2482
|
+
const SUBSTATION_RADIUS_MAX_PIXEL = 5;
|
|
2483
|
+
const SUBSTATION_RADIUS_MIN_PIXEL = 1;
|
|
2484
|
+
const defaultProps$2 = {
|
|
2485
|
+
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2486
|
+
getLineAngle: { type: "accessor", value: 0 },
|
|
2487
|
+
distanceBetweenLines: { type: "number", value: 1e3 },
|
|
2488
|
+
maxParallelOffset: { type: "number", value: 100 },
|
|
2489
|
+
minParallelOffset: { type: "number", value: 3 },
|
|
2490
|
+
substationRadius: { type: "number", value: 500 },
|
|
2491
|
+
substationMaxPixel: { type: "number", value: 5 },
|
|
2492
|
+
minSubstationRadiusPixel: { type: "number", value: 1 }
|
|
2493
|
+
};
|
|
2494
|
+
const _ForkLineLayer = class _ForkLineLayer extends LineLayer$1 {
|
|
2495
|
+
getShaders() {
|
|
2496
|
+
const shaders = super.getShaders();
|
|
2497
|
+
shaders.inject = {
|
|
2498
|
+
"vs:#decl": `
|
|
2499
|
+
attribute float instanceLineParallelIndex;
|
|
2500
|
+
attribute float instanceLineAngle;
|
|
2501
|
+
attribute float instanceOffsetStart;
|
|
2502
|
+
attribute float instanceProximityFactor;
|
|
2503
|
+
uniform float distanceBetweenLines;
|
|
2504
|
+
uniform float maxParallelOffset;
|
|
2505
|
+
uniform float minParallelOffset;
|
|
2506
|
+
uniform float substationRadius;
|
|
2507
|
+
uniform float substationMaxPixel;
|
|
2508
|
+
uniform float minSubstationRadiusPixel;
|
|
2509
|
+
`,
|
|
2510
|
+
"float segmentIndex = positions.x": `;
|
|
2511
|
+
target = source ;
|
|
2512
|
+
float offsetPixels = clamp(project_size_to_pixel( distanceBetweenLines), minParallelOffset, maxParallelOffset );
|
|
2513
|
+
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2514
|
+
|
|
2515
|
+
float offsetSubstation = clamp(project_size_to_pixel(substationRadius*instanceOffsetStart ),
|
|
2516
|
+
minSubstationRadiusPixel,
|
|
2517
|
+
substationMaxPixel * instanceOffsetStart );
|
|
2518
|
+
float offsetSubstationCommonSpace = project_pixel_size(offsetSubstation) ;
|
|
2519
|
+
|
|
2520
|
+
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle ), 0, 0.) * instanceLineParallelIndex;
|
|
2521
|
+
|
|
2522
|
+
trans.x -= sin(instanceLineAngle) * instanceProximityFactor;
|
|
2523
|
+
trans.y -= cos(instanceLineAngle) * instanceProximityFactor;
|
|
2524
|
+
|
|
2525
|
+
source+=project_common_position_to_clipspace(trans * (offsetSubstationCommonSpace / sqrt(trans.x*trans.x+trans.y*trans.y))) - project_uCenter;
|
|
2526
|
+
target+=project_common_position_to_clipspace(trans * offsetCommonSpace) - project_uCenter;
|
|
2527
|
+
|
|
2528
|
+
`
|
|
2529
|
+
};
|
|
2530
|
+
return shaders;
|
|
2531
|
+
}
|
|
2532
|
+
initializeState() {
|
|
2533
|
+
super.initializeState();
|
|
2534
|
+
const attributeManager = this.getAttributeManager();
|
|
2535
|
+
attributeManager == null ? void 0 : attributeManager.addInstanced({
|
|
2536
|
+
instanceLineParallelIndex: {
|
|
2537
|
+
size: 1,
|
|
2538
|
+
type: GL.FLOAT,
|
|
2539
|
+
accessor: "getLineParallelIndex"
|
|
2540
|
+
},
|
|
2541
|
+
instanceLineAngle: {
|
|
2542
|
+
size: 1,
|
|
2543
|
+
type: GL.FLOAT,
|
|
2544
|
+
accessor: "getLineAngle"
|
|
2545
|
+
},
|
|
2546
|
+
instanceOffsetStart: {
|
|
2547
|
+
size: 1,
|
|
2548
|
+
type: GL.FLOAT,
|
|
2549
|
+
accessor: "getSubstationOffset"
|
|
2550
|
+
},
|
|
2551
|
+
instanceProximityFactor: {
|
|
2552
|
+
size: 1,
|
|
2553
|
+
type: GL.FLOAT,
|
|
2554
|
+
accessor: "getProximityFactor"
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
// TODO find the full type for record values
|
|
2559
|
+
draw({ uniforms }) {
|
|
2560
|
+
super.draw({
|
|
2561
|
+
uniforms: {
|
|
2562
|
+
...uniforms,
|
|
2563
|
+
distanceBetweenLines: this.props.getDistanceBetweenLines,
|
|
2564
|
+
maxParallelOffset: this.props.getMaxParallelOffset,
|
|
2565
|
+
minParallelOffset: this.props.getMinParallelOffset,
|
|
2566
|
+
substationRadius: this.props.getSubstationRadius,
|
|
2567
|
+
substationMaxPixel: this.props.getSubstationMaxPixel,
|
|
2568
|
+
minSubstationRadiusPixel: this.props.getMinSubstationRadiusPixel
|
|
2569
|
+
}
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
};
|
|
2573
|
+
_ForkLineLayer.layerName = "ForkLineLayer";
|
|
2574
|
+
_ForkLineLayer.defaultProps = defaultProps$2;
|
|
2575
|
+
let ForkLineLayer = _ForkLineLayer;
|
|
2576
|
+
const defaultProps$1 = {
|
|
2577
|
+
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2578
|
+
getLineAngle: { type: "accessor", value: 0 },
|
|
2579
|
+
distanceBetweenLines: { type: "number", value: 1e3 },
|
|
2580
|
+
maxParallelOffset: { type: "number", value: 100 },
|
|
2581
|
+
minParallelOffset: { type: "number", value: 3 }
|
|
2582
|
+
};
|
|
2583
|
+
const _ParallelPathLayer = class _ParallelPathLayer extends PathLayer {
|
|
2584
|
+
getShaders() {
|
|
2585
|
+
const shaders = super.getShaders();
|
|
2586
|
+
shaders.inject = Object.assign({}, shaders.inject, {
|
|
2587
|
+
"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.
|
|
2588
|
+
// with webgl2, this might be raised in the future to 32 on most platforms...
|
|
2589
|
+
// The PathLayer that this class extends already uses 13 attributes (and 15 with the dash extension).
|
|
2590
|
+
// we have packed all our attributes together in a single attribute to
|
|
2591
|
+
// workaround the low limit of the number of vertex attrbutes...
|
|
2592
|
+
// To pack the attributes, for now we use a very simple system. If needed, we can change it to a more efficient packing.
|
|
2593
|
+
// We just add an extra float to the line angles vec3. The
|
|
2594
|
+
// extra float contains the previous attributes:
|
|
2595
|
+
// parallelIndex (an half integer, between -15.5 and +15.5 (32 lines max..))
|
|
2596
|
+
// proximityFactors (two floats, between 0 and 1)
|
|
2597
|
+
//
|
|
2598
|
+
// To simplify further, we use only positive integers for
|
|
2599
|
+
// this extra float, ie values only from 0 to 2^24. For parallelIndex, we encode the half integers from -15.5 to 15.5
|
|
2600
|
+
// to 0..62, which fits in 6 bits.
|
|
2601
|
+
// For proximityFactors, We switch from floating to a fixed precision of 9 bits
|
|
2602
|
+
// without the 0 (ie multiples of 512: 1/512, 2/512, ..., 1).
|
|
2603
|
+
// So in the 24 bits of the integer value of the float, we have 6 bits of parallel index,
|
|
2604
|
+
// 9 bits of proximity factor start, 9 bits of proximity factor end, for a total of 24 bits.
|
|
2605
|
+
//Note2: packing the attributes together, in addition to not beeing very readable,
|
|
2606
|
+
// also has the downside that you can't update one attribute and reconstruct
|
|
2607
|
+
// only its buffer, so it hurts performance a bit in this case.
|
|
2608
|
+
// But this is a rare case for us (changing parameters) so it doesn't matter much.
|
|
2609
|
+
attribute vec4 instanceExtraAttributes;
|
|
2610
|
+
uniform float distanceBetweenLines;
|
|
2611
|
+
uniform float maxParallelOffset;
|
|
2612
|
+
uniform float minParallelOffset;
|
|
2613
|
+
`,
|
|
2614
|
+
"vs:#main-end": shaders.inject["vs:#main-end"] + `
|
|
2615
|
+
bool isSegmentEnd = isEnd > EPSILON;
|
|
2616
|
+
bool isFirstSegment = (instanceTypes == 1.0 || instanceTypes == 3.0);
|
|
2617
|
+
bool isLastSegment = (instanceTypes == 2.0 || instanceTypes == 3.0);
|
|
2618
|
+
|
|
2619
|
+
float instanceLineAngle = instanceExtraAttributes[1];
|
|
2620
|
+
if ( !isSegmentEnd && isFirstSegment ){
|
|
2621
|
+
instanceLineAngle = instanceExtraAttributes[0];
|
|
2622
|
+
}
|
|
2623
|
+
else if ( isSegmentEnd && isLastSegment){
|
|
2624
|
+
instanceLineAngle = instanceExtraAttributes[2];
|
|
2625
|
+
}
|
|
2626
|
+
float instanceLineParallelIndex = (mod(instanceExtraAttributes[3], 64.0) - 31.0) / 2.0;
|
|
2627
|
+
|
|
2628
|
+
float offsetPixels = clamp(project_size_to_pixel(distanceBetweenLines), minParallelOffset, maxParallelOffset);
|
|
2629
|
+
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2630
|
+
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle), 0, 0.) * instanceLineParallelIndex;
|
|
2631
|
+
|
|
2632
|
+
if(isSegmentEnd && isLastSegment) {
|
|
2633
|
+
float pf = (mod(instanceExtraAttributes[3] / 64.0, 512.0) + 1.0) / 512.0;
|
|
2634
|
+
trans.x += sin(instanceLineAngle) * pf ;
|
|
2635
|
+
trans.y += cos(instanceLineAngle) * pf;
|
|
2636
|
+
}
|
|
2637
|
+
else if (!isSegmentEnd && isFirstSegment)
|
|
2638
|
+
{
|
|
2639
|
+
float pf = (mod(instanceExtraAttributes[3] / 32768.0, 512.0) + 1.0) / 512.0;
|
|
2640
|
+
trans.x -= sin(instanceLineAngle) * pf;
|
|
2641
|
+
trans.y -= cos(instanceLineAngle) * pf;
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
trans = trans * offsetCommonSpace;
|
|
2645
|
+
gl_Position += project_common_position_to_clipspace(trans) - project_uCenter;
|
|
2646
|
+
`
|
|
2647
|
+
});
|
|
2648
|
+
return shaders;
|
|
2649
|
+
}
|
|
2650
|
+
initializeState() {
|
|
2651
|
+
var _a;
|
|
2652
|
+
super.initializeState();
|
|
2653
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.addInstanced({
|
|
2654
|
+
// too much instances variables need to compact some...
|
|
2655
|
+
instanceExtraAttributes: {
|
|
2656
|
+
size: 4,
|
|
2657
|
+
type: GL.FLOAT,
|
|
2658
|
+
accessor: "getExtraAttributes"
|
|
2659
|
+
}
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
// TODO find the full type for record values
|
|
2663
|
+
draw({ uniforms }) {
|
|
2664
|
+
super.draw({
|
|
2665
|
+
uniforms: {
|
|
2666
|
+
...uniforms,
|
|
2667
|
+
distanceBetweenLines: this.props.distanceBetweenLines,
|
|
2668
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
2669
|
+
minParallelOffset: this.props.minParallelOffset
|
|
2670
|
+
}
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2674
|
+
_ParallelPathLayer.layerName = "ParallelPathLayer";
|
|
2675
|
+
_ParallelPathLayer.defaultProps = defaultProps$1;
|
|
2676
|
+
let ParallelPathLayer = _ParallelPathLayer;
|
|
2677
|
+
const DISTANCE_BETWEEN_ARROWS = 1e4;
|
|
2678
|
+
const START_ARROW_POSITION = 0.1;
|
|
2679
|
+
const END_ARROW_POSITION = 0.9;
|
|
2680
|
+
var LineFlowMode = /* @__PURE__ */ ((LineFlowMode2) => {
|
|
2681
|
+
LineFlowMode2["STATIC_ARROWS"] = "staticArrows";
|
|
2682
|
+
LineFlowMode2["ANIMATED_ARROWS"] = "animatedArrows";
|
|
2683
|
+
LineFlowMode2["FEEDERS"] = "feeders";
|
|
2684
|
+
return LineFlowMode2;
|
|
2685
|
+
})(LineFlowMode || {});
|
|
2686
|
+
var LineFlowColorMode = /* @__PURE__ */ ((LineFlowColorMode2) => {
|
|
2687
|
+
LineFlowColorMode2["NOMINAL_VOLTAGE"] = "nominalVoltage";
|
|
2688
|
+
LineFlowColorMode2["OVERLOADS"] = "overloads";
|
|
2689
|
+
return LineFlowColorMode2;
|
|
2690
|
+
})(LineFlowColorMode || {});
|
|
2691
|
+
const noDashArray = [0, 0];
|
|
2692
|
+
const dashArray = [15, 10];
|
|
2693
|
+
function doDash(lineConnection) {
|
|
2694
|
+
return !lineConnection.terminal1Connected || !lineConnection.terminal2Connected;
|
|
2695
|
+
}
|
|
2696
|
+
function getArrowDirection(p = 0) {
|
|
2697
|
+
if (p < 0) {
|
|
2698
|
+
return ArrowDirection.FROM_SIDE_2_TO_SIDE_1;
|
|
2699
|
+
} else if (p > 0) {
|
|
2700
|
+
return ArrowDirection.FROM_SIDE_1_TO_SIDE_2;
|
|
2701
|
+
} else {
|
|
2702
|
+
return ArrowDirection.NONE;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
function getLineLoadingZoneOfSide(limit, intensity, lineFlowAlertThreshold) {
|
|
2706
|
+
if (limit === void 0 || intensity === void 0 || intensity === 0) {
|
|
2707
|
+
return 0;
|
|
2708
|
+
} else {
|
|
2709
|
+
const threshold = lineFlowAlertThreshold * limit / 100;
|
|
2710
|
+
const absoluteIntensity = Math.abs(intensity);
|
|
2711
|
+
if (absoluteIntensity < threshold) {
|
|
2712
|
+
return 1;
|
|
2713
|
+
} else if (absoluteIntensity >= threshold && absoluteIntensity < limit) {
|
|
2714
|
+
return 2;
|
|
2715
|
+
} else {
|
|
2716
|
+
return 3;
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
function getLineLoadingZone(line, lineFlowAlertThreshold) {
|
|
2721
|
+
var _a, _b;
|
|
2722
|
+
const zone1 = getLineLoadingZoneOfSide((_a = line.currentLimits1) == null ? void 0 : _a.permanentLimit, line.i1, lineFlowAlertThreshold);
|
|
2723
|
+
const zone2 = getLineLoadingZoneOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2, lineFlowAlertThreshold);
|
|
2724
|
+
return Math.max(zone1, zone2);
|
|
2725
|
+
}
|
|
2726
|
+
function getLineLoadingZoneColor(zone) {
|
|
2727
|
+
if (zone === 0) {
|
|
2728
|
+
return [128, 128, 128];
|
|
2729
|
+
} else if (zone === 1) {
|
|
2730
|
+
return [107, 178, 40];
|
|
2731
|
+
} else if (zone === 2) {
|
|
2732
|
+
return [210, 179, 63];
|
|
2733
|
+
} else if (zone === 3) {
|
|
2734
|
+
return [255, 0, 0];
|
|
2735
|
+
} else {
|
|
2736
|
+
throw new Error("Unsupported line loading zone: " + zone);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
function getLineColor(line, nominalVoltageColor, props, lineConnection) {
|
|
2740
|
+
if (props.lineFlowColorMode === "nominalVoltage") {
|
|
2741
|
+
if (!lineConnection.terminal1Connected && !lineConnection.terminal2Connected) {
|
|
2742
|
+
return props.disconnectedLineColor;
|
|
2743
|
+
} else {
|
|
2744
|
+
return nominalVoltageColor;
|
|
2745
|
+
}
|
|
2746
|
+
} else if (props.lineFlowColorMode === "overloads") {
|
|
2747
|
+
const zone = getLineLoadingZone(line, props.lineFlowAlertThreshold);
|
|
2748
|
+
return getLineLoadingZoneColor(zone);
|
|
2749
|
+
} else {
|
|
2750
|
+
return nominalVoltageColor;
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
function getLineIcon(lineStatus) {
|
|
2754
|
+
return {
|
|
2755
|
+
url: lineStatus === "PLANNED_OUTAGE" ? PadlockIcon : lineStatus === "FORCED_OUTAGE" ? BoltIcon : "",
|
|
2756
|
+
height: 24,
|
|
2757
|
+
width: 24,
|
|
2758
|
+
mask: true
|
|
2759
|
+
};
|
|
2760
|
+
}
|
|
2761
|
+
function getArrowSpeedOfSide(limit, intensity) {
|
|
2762
|
+
if (limit === void 0 || intensity === void 0 || intensity === 0) {
|
|
2763
|
+
return 0;
|
|
2764
|
+
} else {
|
|
2765
|
+
if (intensity > 0 && intensity < limit / 3) {
|
|
2766
|
+
return 1;
|
|
2767
|
+
} else if (intensity >= limit / 3 && intensity < limit * 2 / 3) {
|
|
2768
|
+
return 2;
|
|
2769
|
+
} else if (intensity >= limit * 2 / 3 && intensity < limit) {
|
|
2770
|
+
return 3;
|
|
2771
|
+
} else {
|
|
2772
|
+
return 4;
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
function getArrowSpeed(line) {
|
|
2777
|
+
var _a, _b;
|
|
2778
|
+
const speed1 = getArrowSpeedOfSide((_a = line.currentLimits1) == null ? void 0 : _a.permanentLimit, line.i1);
|
|
2779
|
+
const speed2 = getArrowSpeedOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2);
|
|
2780
|
+
return Math.max(speed1, speed2);
|
|
2781
|
+
}
|
|
2782
|
+
function getArrowSpeedFactor(speed) {
|
|
2783
|
+
switch (speed) {
|
|
2784
|
+
case 0:
|
|
2785
|
+
return 0;
|
|
2786
|
+
case 1:
|
|
2787
|
+
return 0.5;
|
|
2788
|
+
case 2:
|
|
2789
|
+
return 2;
|
|
2790
|
+
case 3:
|
|
2791
|
+
return 4;
|
|
2792
|
+
case 4:
|
|
2793
|
+
return 10;
|
|
2794
|
+
default:
|
|
2795
|
+
throw new Error("Unknown arrow speed: " + speed);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
const _LineLayer = class _LineLayer extends CompositeLayer {
|
|
2799
|
+
initializeState(context) {
|
|
2800
|
+
super.initializeState(context);
|
|
2801
|
+
this.state = {
|
|
2802
|
+
compositeData: [],
|
|
2803
|
+
linesConnection: /* @__PURE__ */ new Map(),
|
|
2804
|
+
linesStatus: /* @__PURE__ */ new Map()
|
|
2805
|
+
};
|
|
2806
|
+
}
|
|
2807
|
+
getVoltageLevelIndex(voltageLevelId) {
|
|
2808
|
+
const { network } = this.props;
|
|
2809
|
+
const vl = network.getVoltageLevel(voltageLevelId);
|
|
2810
|
+
const substation = network.getSubstation(vl == null ? void 0 : vl.substationId);
|
|
2811
|
+
return [
|
|
2812
|
+
...new Set(
|
|
2813
|
+
substation == null ? void 0 : substation.voltageLevels.map((vl2) => vl2.nominalV)
|
|
2814
|
+
// only one voltage level
|
|
2815
|
+
)
|
|
2816
|
+
].sort((a, b) => {
|
|
2817
|
+
return a - b;
|
|
2818
|
+
}).indexOf(vl == null ? void 0 : vl.nominalV) + 1;
|
|
2819
|
+
}
|
|
2820
|
+
//TODO this is a huge function, refactor
|
|
2821
|
+
updateState({ props, oldProps, changeFlags }) {
|
|
2822
|
+
let compositeData;
|
|
2823
|
+
let linesConnection;
|
|
2824
|
+
let linesStatus;
|
|
2825
|
+
if (changeFlags.dataChanged) {
|
|
2826
|
+
compositeData = [];
|
|
2827
|
+
linesConnection = /* @__PURE__ */ new Map();
|
|
2828
|
+
linesStatus = /* @__PURE__ */ new Map();
|
|
2829
|
+
if (props.network != null && props.network.substations && props.data.length !== 0 && props.geoData != null) {
|
|
2830
|
+
const lineNominalVoltageIndexer = (map, line) => {
|
|
2831
|
+
const network = props.network;
|
|
2832
|
+
const vl1 = network.getVoltageLevel(line.voltageLevelId1);
|
|
2833
|
+
const vl2 = network.getVoltageLevel(line.voltageLevelId2);
|
|
2834
|
+
const vl = vl1 || vl2;
|
|
2835
|
+
let list = map.get(vl == null ? void 0 : vl.nominalV);
|
|
2836
|
+
if (!list) {
|
|
2837
|
+
list = [];
|
|
2838
|
+
map.set(vl == null ? void 0 : vl.nominalV, list);
|
|
2839
|
+
}
|
|
2840
|
+
if ((vl1 == null ? void 0 : vl1.substationId) !== (vl2 == null ? void 0 : vl2.substationId)) {
|
|
2841
|
+
list.push(line);
|
|
2842
|
+
}
|
|
2843
|
+
return map;
|
|
2844
|
+
};
|
|
2845
|
+
const linesByNominalVoltage = props.data.reduce(
|
|
2846
|
+
lineNominalVoltageIndexer,
|
|
2847
|
+
/* @__PURE__ */ new Map()
|
|
2848
|
+
);
|
|
2849
|
+
compositeData = Array.from(linesByNominalVoltage.entries()).map((e) => {
|
|
2850
|
+
return { nominalV: e[0], lines: e[1] };
|
|
2851
|
+
}).sort((a, b) => b.nominalV - a.nominalV);
|
|
2852
|
+
compositeData.forEach((compositeData2) => {
|
|
2853
|
+
var _a;
|
|
2854
|
+
const mapOriginDestination = /* @__PURE__ */ new Map();
|
|
2855
|
+
compositeData2.mapOriginDestination = mapOriginDestination;
|
|
2856
|
+
(_a = compositeData2.lines) == null ? void 0 : _a.forEach((line) => {
|
|
2857
|
+
linesConnection.set(line.id, {
|
|
2858
|
+
terminal1Connected: line.terminal1Connected,
|
|
2859
|
+
terminal2Connected: line.terminal2Connected
|
|
2860
|
+
});
|
|
2861
|
+
linesStatus.set(line.id, {
|
|
2862
|
+
operatingStatus: line.operatingStatus
|
|
2863
|
+
});
|
|
2864
|
+
const key = this.genLineKey(line);
|
|
2865
|
+
const val = mapOriginDestination.get(key);
|
|
2866
|
+
if (val == null) {
|
|
2867
|
+
mapOriginDestination.set(key, /* @__PURE__ */ new Set([line]));
|
|
2868
|
+
} else {
|
|
2869
|
+
mapOriginDestination.set(key, val.add(line));
|
|
2870
|
+
}
|
|
2871
|
+
});
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
} else {
|
|
2875
|
+
compositeData = this.state.compositeData;
|
|
2876
|
+
linesConnection = this.state.linesConnection;
|
|
2877
|
+
linesStatus = this.state.linesStatus;
|
|
2878
|
+
if (props.updatedLines !== oldProps.updatedLines) {
|
|
2879
|
+
props.updatedLines.forEach((line1) => {
|
|
2880
|
+
linesConnection.set(line1.id, {
|
|
2881
|
+
terminal1Connected: line1.terminal1Connected,
|
|
2882
|
+
terminal2Connected: line1.terminal2Connected
|
|
2883
|
+
});
|
|
2884
|
+
linesStatus.set(line1.id, {
|
|
2885
|
+
operatingStatus: line1.operatingStatus
|
|
2886
|
+
});
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2891
|
+
this.recomputeParallelLinesIndex(compositeData, props);
|
|
2892
|
+
}
|
|
2893
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || oldProps.geoData !== props.geoData)) {
|
|
2894
|
+
compositeData.forEach((compositeData2) => {
|
|
2895
|
+
var _a;
|
|
2896
|
+
const lineMap = /* @__PURE__ */ new Map();
|
|
2897
|
+
(_a = compositeData2.lines) == null ? void 0 : _a.forEach((line) => {
|
|
2898
|
+
const positions = props.geoData.getLinePositions(props.network, line, props.lineFullPath);
|
|
2899
|
+
const cumulativeDistances = props.geoData.getLineDistances(positions);
|
|
2900
|
+
lineMap.set(line.id, {
|
|
2901
|
+
positions,
|
|
2902
|
+
// @ts-expect-error TODO: manage null case
|
|
2903
|
+
cumulativeDistances,
|
|
2904
|
+
line
|
|
2905
|
+
});
|
|
2906
|
+
});
|
|
2907
|
+
compositeData2.lineMap = lineMap;
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2910
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (props.lineFullPath !== oldProps.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2911
|
+
this.recomputeForkLines(compositeData, props);
|
|
2912
|
+
}
|
|
2913
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2914
|
+
compositeData.forEach((compositeData2) => {
|
|
2915
|
+
var _a;
|
|
2916
|
+
compositeData2.activePower = [];
|
|
2917
|
+
(_a = compositeData2.lines) == null ? void 0 : _a.forEach((line) => {
|
|
2918
|
+
var _a2, _b, _c;
|
|
2919
|
+
const lineData = (_a2 = compositeData2.lineMap) == null ? void 0 : _a2.get(line.id);
|
|
2920
|
+
const arrowDirection = getArrowDirection(line.p1);
|
|
2921
|
+
const coordinates1 = props.geoData.labelDisplayPosition(
|
|
2922
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2923
|
+
lineData == null ? void 0 : lineData.positions,
|
|
2924
|
+
lineData == null ? void 0 : lineData.cumulativeDistances,
|
|
2925
|
+
START_ARROW_POSITION,
|
|
2926
|
+
arrowDirection,
|
|
2927
|
+
line.parallelIndex,
|
|
2928
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2929
|
+
line.angle * 180 / Math.PI,
|
|
2930
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2931
|
+
line.angleStart * 180 / Math.PI,
|
|
2932
|
+
props.distanceBetweenLines,
|
|
2933
|
+
line.proximityFactorStart
|
|
2934
|
+
);
|
|
2935
|
+
const coordinates2 = props.geoData.labelDisplayPosition(
|
|
2936
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2937
|
+
lineData == null ? void 0 : lineData.positions,
|
|
2938
|
+
lineData == null ? void 0 : lineData.cumulativeDistances,
|
|
2939
|
+
END_ARROW_POSITION,
|
|
2940
|
+
arrowDirection,
|
|
2941
|
+
line.parallelIndex,
|
|
2942
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2943
|
+
line.angle * 180 / Math.PI,
|
|
2944
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2945
|
+
line.angleEnd * 180 / Math.PI,
|
|
2946
|
+
props.distanceBetweenLines,
|
|
2947
|
+
line.proximityFactorEnd
|
|
2948
|
+
);
|
|
2949
|
+
if (coordinates1 !== null && coordinates2 !== null) {
|
|
2950
|
+
(_b = compositeData2.activePower) == null ? void 0 : _b.push({
|
|
2951
|
+
line,
|
|
2952
|
+
p: line.p1,
|
|
2953
|
+
printPosition: [coordinates1.position.longitude, coordinates1.position.latitude],
|
|
2954
|
+
offset: coordinates1.offset
|
|
2955
|
+
});
|
|
2956
|
+
(_c = compositeData2.activePower) == null ? void 0 : _c.push({
|
|
2957
|
+
line,
|
|
2958
|
+
p: line.p2,
|
|
2959
|
+
printPosition: [coordinates2.position.longitude, coordinates2.position.latitude],
|
|
2960
|
+
offset: coordinates2.offset
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
});
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (props.updatedLines !== oldProps.updatedLines || oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
2967
|
+
compositeData.forEach((compositeData2) => {
|
|
2968
|
+
var _a;
|
|
2969
|
+
compositeData2.operatingStatus = [];
|
|
2970
|
+
(_a = compositeData2.lines) == null ? void 0 : _a.forEach((line) => {
|
|
2971
|
+
var _a2, _b;
|
|
2972
|
+
const lineStatus = linesStatus.get(line.id);
|
|
2973
|
+
if (lineStatus !== void 0 && lineStatus.operatingStatus !== void 0 && lineStatus.operatingStatus !== "IN_OPERATION") {
|
|
2974
|
+
const lineData = (_a2 = compositeData2.lineMap) == null ? void 0 : _a2.get(line.id);
|
|
2975
|
+
const coordinatesIcon = props.geoData.labelDisplayPosition(
|
|
2976
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2977
|
+
lineData == null ? void 0 : lineData.positions,
|
|
2978
|
+
lineData == null ? void 0 : lineData.cumulativeDistances,
|
|
2979
|
+
0.5,
|
|
2980
|
+
ArrowDirection.NONE,
|
|
2981
|
+
line.parallelIndex,
|
|
2982
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2983
|
+
line.angle * 180 / Math.PI,
|
|
2984
|
+
// @ts-expect-error TODO: manage undefined case
|
|
2985
|
+
line.angleEnd * 180 / Math.PI,
|
|
2986
|
+
props.distanceBetweenLines,
|
|
2987
|
+
line.proximityFactorEnd
|
|
2988
|
+
);
|
|
2989
|
+
if (coordinatesIcon !== null) {
|
|
2990
|
+
(_b = compositeData2.operatingStatus) == null ? void 0 : _b.push({
|
|
2991
|
+
status: lineStatus.operatingStatus,
|
|
2992
|
+
printPosition: [coordinatesIcon.position.longitude, coordinatesIcon.position.latitude],
|
|
2993
|
+
offset: coordinatesIcon.offset
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
});
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || props.geoData !== oldProps.geoData || //For lineFlowMode, recompute only if mode goes to or from LineFlowMode.FEEDERS
|
|
3001
|
+
//because for LineFlowMode.STATIC_ARROWS and LineFlowMode.ANIMATED_ARROWS it's the same
|
|
3002
|
+
props.lineFlowMode !== oldProps.lineFlowMode && (props.lineFlowMode === "feeders" || oldProps.lineFlowMode === "feeders"))) {
|
|
3003
|
+
compositeData.forEach((compositeData2) => {
|
|
3004
|
+
var _a;
|
|
3005
|
+
const lineMap = compositeData2.lineMap;
|
|
3006
|
+
compositeData2.arrows = (_a = compositeData2.lines) == null ? void 0 : _a.flatMap((line) => {
|
|
3007
|
+
const lineData = lineMap == null ? void 0 : lineMap.get(line.id);
|
|
3008
|
+
line.cumulativeDistances = lineData == null ? void 0 : lineData.cumulativeDistances;
|
|
3009
|
+
line.positions = lineData == null ? void 0 : lineData.positions;
|
|
3010
|
+
if (props.lineFlowMode === "feeders") {
|
|
3011
|
+
return [
|
|
3012
|
+
{
|
|
3013
|
+
distance: START_ARROW_POSITION,
|
|
3014
|
+
line
|
|
3015
|
+
},
|
|
3016
|
+
{
|
|
3017
|
+
distance: END_ARROW_POSITION,
|
|
3018
|
+
line
|
|
3019
|
+
}
|
|
3020
|
+
];
|
|
3021
|
+
}
|
|
3022
|
+
const directLinePositions = props.geoData.getLinePositions(props.network, line, false);
|
|
3023
|
+
const directLineDistance = es.getDistance(
|
|
3024
|
+
{
|
|
3025
|
+
latitude: directLinePositions[0][1],
|
|
3026
|
+
longitude: directLinePositions[0][0]
|
|
3027
|
+
},
|
|
3028
|
+
{
|
|
3029
|
+
latitude: directLinePositions[1][1],
|
|
3030
|
+
longitude: directLinePositions[1][0]
|
|
3031
|
+
}
|
|
3032
|
+
);
|
|
3033
|
+
const arrowCount = Math.ceil(directLineDistance / DISTANCE_BETWEEN_ARROWS);
|
|
3034
|
+
return [...new Array(arrowCount).keys()].map((index) => {
|
|
3035
|
+
return {
|
|
3036
|
+
distance: index / arrowCount,
|
|
3037
|
+
line
|
|
3038
|
+
};
|
|
3039
|
+
});
|
|
3040
|
+
});
|
|
3041
|
+
});
|
|
3042
|
+
}
|
|
3043
|
+
this.setState({
|
|
3044
|
+
compositeData,
|
|
3045
|
+
linesConnection,
|
|
3046
|
+
linesStatus
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
genLineKey(line) {
|
|
3050
|
+
return line.voltageLevelId1 > line.voltageLevelId2 ? line.voltageLevelId1 + "##" + line.voltageLevelId2 : line.voltageLevelId2 + "##" + line.voltageLevelId1;
|
|
3051
|
+
}
|
|
3052
|
+
recomputeParallelLinesIndex(compositeData, props) {
|
|
3053
|
+
compositeData.forEach((compositeData2) => {
|
|
3054
|
+
const mapOriginDestination = compositeData2.mapOriginDestination;
|
|
3055
|
+
mapOriginDestination == null ? void 0 : mapOriginDestination.forEach((samePathLine, key) => {
|
|
3056
|
+
let truncatedSize = samePathLine.size;
|
|
3057
|
+
if (truncatedSize > 32) {
|
|
3058
|
+
console.warn(
|
|
3059
|
+
"Warning, more than 32 parallel lines between vls " + key + ". The map will only show 32 parallel lines."
|
|
3060
|
+
);
|
|
3061
|
+
truncatedSize = 32;
|
|
3062
|
+
}
|
|
3063
|
+
let index = -(truncatedSize - 1) / 2;
|
|
3064
|
+
samePathLine.forEach((line) => {
|
|
3065
|
+
line.parallelIndex = props.lineParallelPath ? index : 0;
|
|
3066
|
+
if (index < 15) {
|
|
3067
|
+
index += 1;
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
});
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
recomputeForkLines(compositeData, props) {
|
|
3074
|
+
const mapMinProximityFactor = /* @__PURE__ */ new Map();
|
|
3075
|
+
compositeData.forEach((compositeData2) => {
|
|
3076
|
+
compositeData2.lines.forEach((line) => {
|
|
3077
|
+
var _a, _b;
|
|
3078
|
+
const positions = (_b = (_a = compositeData2.lineMap) == null ? void 0 : _a.get(line.id)) == null ? void 0 : _b.positions;
|
|
3079
|
+
line.origin = positions[0];
|
|
3080
|
+
line.end = positions[positions.length - 1];
|
|
3081
|
+
line.substationIndexStart = this.getVoltageLevelIndex(line.voltageLevelId1);
|
|
3082
|
+
line.substationIndexEnd = this.getVoltageLevelIndex(line.voltageLevelId2);
|
|
3083
|
+
line.angle = this.computeAngle(props, positions[0], positions[positions.length - 1]);
|
|
3084
|
+
line.angleStart = this.computeAngle(props, positions[0], positions[1]);
|
|
3085
|
+
line.angleEnd = this.computeAngle(
|
|
3086
|
+
props,
|
|
3087
|
+
positions[positions.length - 2],
|
|
3088
|
+
positions[positions.length - 1]
|
|
3089
|
+
);
|
|
3090
|
+
line.proximityFactorStart = this.getProximityFactor(positions[0], positions[1]);
|
|
3091
|
+
line.proximityFactorEnd = this.getProximityFactor(
|
|
3092
|
+
positions[positions.length - 2],
|
|
3093
|
+
positions[positions.length - 1]
|
|
3094
|
+
);
|
|
3095
|
+
const key = this.genLineKey(line);
|
|
3096
|
+
const val = mapMinProximityFactor.get(key);
|
|
3097
|
+
if (val == null) {
|
|
3098
|
+
mapMinProximityFactor.set(key, {
|
|
3099
|
+
lines: [line],
|
|
3100
|
+
start: line.proximityFactorStart,
|
|
3101
|
+
end: line.proximityFactorEnd
|
|
3102
|
+
});
|
|
3103
|
+
} else {
|
|
3104
|
+
val.lines.push(line);
|
|
3105
|
+
val.start = Math.min(val.start, line.proximityFactorStart);
|
|
3106
|
+
val.end = Math.min(val.end, line.proximityFactorEnd);
|
|
3107
|
+
mapMinProximityFactor.set(key, val);
|
|
3108
|
+
}
|
|
3109
|
+
});
|
|
3110
|
+
});
|
|
3111
|
+
mapMinProximityFactor.forEach(
|
|
3112
|
+
(samePathLine) => samePathLine.lines.forEach((line) => {
|
|
3113
|
+
line.proximityFactorStart = samePathLine.start;
|
|
3114
|
+
line.proximityFactorEnd = samePathLine.end;
|
|
3115
|
+
})
|
|
3116
|
+
);
|
|
3117
|
+
}
|
|
3118
|
+
getProximityFactor(firstPosition, secondPosition) {
|
|
3119
|
+
let factor = es.getDistance(firstPosition, secondPosition) / (3 * this.props.distanceBetweenLines);
|
|
3120
|
+
if (factor > 1) {
|
|
3121
|
+
factor = 1;
|
|
3122
|
+
}
|
|
3123
|
+
return factor;
|
|
3124
|
+
}
|
|
3125
|
+
computeAngle(props, position1, position2) {
|
|
3126
|
+
let angle = props.geoData.getMapAngle(position1, position2);
|
|
3127
|
+
angle = angle * Math.PI / 180 + Math.PI;
|
|
3128
|
+
if (angle < 0) {
|
|
3129
|
+
angle += 2 * Math.PI;
|
|
3130
|
+
}
|
|
3131
|
+
return angle;
|
|
3132
|
+
}
|
|
3133
|
+
renderLayers() {
|
|
3134
|
+
const layers = [];
|
|
3135
|
+
const linePathUpdateTriggers = [
|
|
3136
|
+
this.props.lineFullPath,
|
|
3137
|
+
this.props.geoData.linePositionsById,
|
|
3138
|
+
this.props.network.lines
|
|
3139
|
+
];
|
|
3140
|
+
this.state.compositeData.forEach((compositeData) => {
|
|
3141
|
+
const nominalVoltageColor = this.props.getNominalVoltageColor(compositeData.nominalV);
|
|
3142
|
+
const lineLayer = new ParallelPathLayer(
|
|
3143
|
+
this.getSubLayerProps({
|
|
3144
|
+
id: "LineNominalVoltage" + compositeData.nominalV,
|
|
3145
|
+
data: compositeData.lines,
|
|
3146
|
+
widthScale: 20,
|
|
3147
|
+
widthMinPixels: 1,
|
|
3148
|
+
widthMaxPixels: 2,
|
|
3149
|
+
getPath: (line) => this.props.geoData.getLinePositions(this.props.network, line, this.props.lineFullPath),
|
|
3150
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3151
|
+
getColor: (line) => (
|
|
3152
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3153
|
+
getLineColor(line, nominalVoltageColor, this.props, this.state.linesConnection.get(line.id))
|
|
3154
|
+
),
|
|
3155
|
+
getWidth: 2,
|
|
3156
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3157
|
+
getLineParallelIndex: (line) => line.parallelIndex,
|
|
3158
|
+
getExtraAttributes: (line) => [
|
|
3159
|
+
line.angleStart,
|
|
3160
|
+
line.angle,
|
|
3161
|
+
line.angleEnd,
|
|
3162
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3163
|
+
line.parallelIndex * 2 + 31 + // @ts-expect-error TODO: manage undefined case
|
|
3164
|
+
64 * (Math.ceil(line.proximityFactorStart * 512) - 1) + // @ts-expect-error TODO: manage undefined case
|
|
3165
|
+
64 * 512 * (Math.ceil(line.proximityFactorEnd * 512) - 1)
|
|
3166
|
+
],
|
|
3167
|
+
distanceBetweenLines: this.props.distanceBetweenLines,
|
|
3168
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
3169
|
+
minParallelOffset: this.props.minParallelOffset,
|
|
3170
|
+
visible: !this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV),
|
|
3171
|
+
updateTriggers: {
|
|
3172
|
+
getPath: linePathUpdateTriggers,
|
|
3173
|
+
getExtraAttributes: [this.props.lineParallelPath, linePathUpdateTriggers],
|
|
3174
|
+
getColor: [
|
|
3175
|
+
this.props.disconnectedLineColor,
|
|
3176
|
+
this.props.lineFlowColorMode,
|
|
3177
|
+
this.props.lineFlowAlertThreshold,
|
|
3178
|
+
this.props.updatedLines
|
|
3179
|
+
],
|
|
3180
|
+
getDashArray: [this.props.updatedLines]
|
|
3181
|
+
},
|
|
3182
|
+
getDashArray: (line) => (
|
|
3183
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3184
|
+
doDash(this.state.linesConnection.get(line.id)) ? dashArray : noDashArray
|
|
3185
|
+
),
|
|
3186
|
+
extensions: [new PathStyleExtension({ dash: true })]
|
|
3187
|
+
})
|
|
3188
|
+
);
|
|
3189
|
+
layers.push(lineLayer);
|
|
3190
|
+
const arrowLayer = new ArrowLayer(
|
|
3191
|
+
this.getSubLayerProps(
|
|
3192
|
+
{
|
|
3193
|
+
id: "ArrowNominalVoltage" + compositeData.nominalV,
|
|
3194
|
+
data: compositeData.arrows,
|
|
3195
|
+
sizeMinPixels: 3,
|
|
3196
|
+
sizeMaxPixels: 7,
|
|
3197
|
+
getDistance: (arrow) => arrow.distance,
|
|
3198
|
+
getLine: (arrow) => arrow.line,
|
|
3199
|
+
getLinePositions: (line) => this.props.geoData.getLinePositions(this.props.network, line, this.props.lineFullPath),
|
|
3200
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3201
|
+
getColor: (arrow) => getLineColor(
|
|
3202
|
+
arrow.line,
|
|
3203
|
+
nominalVoltageColor,
|
|
3204
|
+
this.props,
|
|
3205
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3206
|
+
this.state.linesConnection.get(arrow.line.id)
|
|
3207
|
+
),
|
|
3208
|
+
getSize: 700,
|
|
3209
|
+
getSpeedFactor: (arrow) => getArrowSpeedFactor(getArrowSpeed(arrow.line)),
|
|
3210
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3211
|
+
getLineParallelIndex: (arrow) => arrow.line.parallelIndex,
|
|
3212
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3213
|
+
getLineAngles: (arrow) => [arrow.line.angleStart, arrow.line.angle, arrow.line.angleEnd],
|
|
3214
|
+
getProximityFactors: (arrow) => [
|
|
3215
|
+
arrow.line.proximityFactorStart,
|
|
3216
|
+
arrow.line.proximityFactorEnd
|
|
3217
|
+
],
|
|
3218
|
+
getDistanceBetweenLines: this.props.distanceBetweenLines,
|
|
3219
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
3220
|
+
minParallelOffset: this.props.minParallelOffset,
|
|
3221
|
+
getDirection: (arrow) => {
|
|
3222
|
+
return getArrowDirection(arrow.line.p1);
|
|
3223
|
+
},
|
|
3224
|
+
animated: this.props.showLineFlow && this.props.lineFlowMode === "animatedArrows",
|
|
3225
|
+
visible: this.props.showLineFlow && (!this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV)),
|
|
3226
|
+
opacity: this.props.areFlowsValid ? 1 : INVALID_FLOW_OPACITY,
|
|
3227
|
+
updateTriggers: {
|
|
3228
|
+
getLinePositions: linePathUpdateTriggers,
|
|
3229
|
+
getLineParallelIndex: [this.props.lineParallelPath],
|
|
3230
|
+
getLineAngles: linePathUpdateTriggers,
|
|
3231
|
+
getColor: [
|
|
3232
|
+
this.props.disconnectedLineColor,
|
|
3233
|
+
this.props.lineFlowColorMode,
|
|
3234
|
+
this.props.lineFlowAlertThreshold,
|
|
3235
|
+
this.props.updatedLines
|
|
3236
|
+
],
|
|
3237
|
+
opacity: [this.props.areFlowsValid]
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
/*<Arrow>*/
|
|
3241
|
+
)
|
|
3242
|
+
);
|
|
3243
|
+
layers.push(arrowLayer);
|
|
3244
|
+
const startFork = new ForkLineLayer(
|
|
3245
|
+
this.getSubLayerProps({
|
|
3246
|
+
id: "LineForkStart" + compositeData.nominalV,
|
|
3247
|
+
getSourcePosition: (line) => line.origin,
|
|
3248
|
+
getTargetPosition: (line) => line.end,
|
|
3249
|
+
getSubstationOffset: (line) => line.substationIndexStart,
|
|
3250
|
+
data: compositeData.lines,
|
|
3251
|
+
widthScale: 20,
|
|
3252
|
+
widthMinPixels: 1,
|
|
3253
|
+
widthMaxPixels: 2,
|
|
3254
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3255
|
+
getColor: (line) => (
|
|
3256
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3257
|
+
getLineColor(line, nominalVoltageColor, this.props, this.state.linesConnection.get(line.id))
|
|
3258
|
+
),
|
|
3259
|
+
getWidth: 2,
|
|
3260
|
+
getProximityFactor: (line) => line.proximityFactorStart,
|
|
3261
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3262
|
+
getLineParallelIndex: (line) => line.parallelIndex,
|
|
3263
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3264
|
+
getLineAngle: (line) => line.angleStart,
|
|
3265
|
+
getDistanceBetweenLines: this.props.distanceBetweenLines,
|
|
3266
|
+
getMaxParallelOffset: this.props.maxParallelOffset,
|
|
3267
|
+
getMinParallelOffset: this.props.minParallelOffset,
|
|
3268
|
+
getSubstationRadius: this.props.substationRadius,
|
|
3269
|
+
getSubstationMaxPixel: this.props.substationMaxPixel,
|
|
3270
|
+
getMinSubstationRadiusPixel: this.props.minSubstationRadiusPixel,
|
|
3271
|
+
visible: !this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV),
|
|
3272
|
+
updateTriggers: {
|
|
3273
|
+
getLineParallelIndex: linePathUpdateTriggers,
|
|
3274
|
+
getSourcePosition: linePathUpdateTriggers,
|
|
3275
|
+
getTargetPosition: linePathUpdateTriggers,
|
|
3276
|
+
getLineAngle: linePathUpdateTriggers,
|
|
3277
|
+
getProximityFactor: linePathUpdateTriggers,
|
|
3278
|
+
getColor: [
|
|
3279
|
+
this.props.disconnectedLineColor,
|
|
3280
|
+
this.props.lineFlowColorMode,
|
|
3281
|
+
this.props.lineFlowAlertThreshold,
|
|
3282
|
+
this.props.updatedLines
|
|
3283
|
+
]
|
|
3284
|
+
}
|
|
3285
|
+
})
|
|
3286
|
+
);
|
|
3287
|
+
layers.push(startFork);
|
|
3288
|
+
const endFork = new ForkLineLayer(
|
|
3289
|
+
this.getSubLayerProps({
|
|
3290
|
+
id: "LineForkEnd" + compositeData.nominalV,
|
|
3291
|
+
getSourcePosition: (line) => line.end,
|
|
3292
|
+
getTargetPosition: (line) => line.origin,
|
|
3293
|
+
getSubstationOffset: (line) => line.substationIndexEnd,
|
|
3294
|
+
data: compositeData.lines,
|
|
3295
|
+
widthScale: 20,
|
|
3296
|
+
widthMinPixels: 1,
|
|
3297
|
+
widthMaxPixels: 2,
|
|
3298
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3299
|
+
getColor: (line) => (
|
|
3300
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3301
|
+
getLineColor(line, nominalVoltageColor, this.props, this.state.linesConnection.get(line.id))
|
|
3302
|
+
),
|
|
3303
|
+
getWidth: 2,
|
|
3304
|
+
getProximityFactor: (line) => line.proximityFactorEnd,
|
|
3305
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3306
|
+
getLineParallelIndex: (line) => -line.parallelIndex,
|
|
3307
|
+
// @ts-expect-error TODO: manage undefined case
|
|
3308
|
+
getLineAngle: (line) => line.angleEnd + Math.PI,
|
|
3309
|
+
getDistanceBetweenLines: this.props.distanceBetweenLines,
|
|
3310
|
+
getMaxParallelOffset: this.props.maxParallelOffset,
|
|
3311
|
+
getMinParallelOffset: this.props.minParallelOffset,
|
|
3312
|
+
getSubstationRadius: this.props.substationRadius,
|
|
3313
|
+
getSubstationMaxPixel: this.props.substationMaxPixel,
|
|
3314
|
+
getMinSubstationRadiusPixel: this.props.minSubstationRadiusPixel,
|
|
3315
|
+
visible: !this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV),
|
|
3316
|
+
updateTriggers: {
|
|
3317
|
+
getLineParallelIndex: [this.props.lineParallelPath],
|
|
3318
|
+
getSourcePosition: linePathUpdateTriggers,
|
|
3319
|
+
getTargetPosition: linePathUpdateTriggers,
|
|
3320
|
+
getLineAngle: linePathUpdateTriggers,
|
|
3321
|
+
getProximityFactor: linePathUpdateTriggers,
|
|
3322
|
+
getColor: [
|
|
3323
|
+
this.props.disconnectedLineColor,
|
|
3324
|
+
this.props.lineFlowColorMode,
|
|
3325
|
+
this.props.lineFlowAlertThreshold,
|
|
3326
|
+
this.props.updatedLines
|
|
3327
|
+
]
|
|
3328
|
+
}
|
|
3329
|
+
})
|
|
3330
|
+
);
|
|
3331
|
+
layers.push(endFork);
|
|
3332
|
+
const lineActivePowerLabelsLayer = new TextLayer(
|
|
3333
|
+
this.getSubLayerProps({
|
|
3334
|
+
id: "ActivePower" + compositeData.nominalV,
|
|
3335
|
+
data: compositeData.activePower,
|
|
3336
|
+
getText: (activePower) => activePower.p !== void 0 ? Math.round(activePower.p).toString() : "",
|
|
3337
|
+
// The position passed to this layer causes a bug when zooming and maxParallelOffset is reached:
|
|
3338
|
+
// the label is not correctly positioned on the lines, they are slightly off.
|
|
3339
|
+
// In the custom layers, we clamp the distanceBetweenLines. This is not done in the deck.gl TextLayer
|
|
3340
|
+
// and IconLayer or in the position calculated here.
|
|
3341
|
+
getPosition: (activePower) => activePower.printPosition,
|
|
3342
|
+
getColor: this.props.labelColor,
|
|
3343
|
+
fontFamily: "Roboto",
|
|
3344
|
+
getSize: this.props.labelSize,
|
|
3345
|
+
getAngle: 0,
|
|
3346
|
+
getPixelOffset: (activePower) => [...activePower.offset],
|
|
3347
|
+
getTextAnchor: "middle",
|
|
3348
|
+
visible: (!this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV)) && this.props.labelsVisible,
|
|
3349
|
+
opacity: this.props.areFlowsValid ? 1 : INVALID_FLOW_OPACITY,
|
|
3350
|
+
updateTriggers: {
|
|
3351
|
+
getPosition: [this.props.lineParallelPath, linePathUpdateTriggers],
|
|
3352
|
+
getPixelOffset: linePathUpdateTriggers,
|
|
3353
|
+
opacity: [this.props.areFlowsValid]
|
|
3354
|
+
}
|
|
3355
|
+
})
|
|
3356
|
+
);
|
|
3357
|
+
layers.push(lineActivePowerLabelsLayer);
|
|
3358
|
+
const lineStatusIconLayer = new IconLayer(
|
|
3359
|
+
this.getSubLayerProps({
|
|
3360
|
+
id: "OperatingStatus" + compositeData.nominalV,
|
|
3361
|
+
data: compositeData.operatingStatus,
|
|
3362
|
+
// The position passed to this layer causes a bug when zooming and maxParallelOffset is reached:
|
|
3363
|
+
// the icon is not correctly positioned on the lines, they are slightly off.
|
|
3364
|
+
// In the custom layers, we clamp the distanceBetweenLines. This is not done in the deck.gl TextLayer
|
|
3365
|
+
// and IconLayer or in the position calculated here.
|
|
3366
|
+
getPosition: (operatingStatus) => operatingStatus.printPosition,
|
|
3367
|
+
getIcon: (operatingStatus) => getLineIcon(operatingStatus.status),
|
|
3368
|
+
getSize: this.props.iconSize,
|
|
3369
|
+
getColor: () => this.props.labelColor,
|
|
3370
|
+
getPixelOffset: (operatingStatus) => operatingStatus.offset,
|
|
3371
|
+
visible: (!this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(compositeData.nominalV)) && this.props.labelsVisible,
|
|
3372
|
+
updateTriggers: {
|
|
3373
|
+
getPosition: [this.props.lineParallelPath, linePathUpdateTriggers],
|
|
3374
|
+
getPixelOffset: linePathUpdateTriggers,
|
|
3375
|
+
getIcon: [this.state.linesStatus],
|
|
3376
|
+
getColor: [this.props.labelColor]
|
|
3377
|
+
}
|
|
3378
|
+
})
|
|
3379
|
+
);
|
|
3380
|
+
layers.push(lineStatusIconLayer);
|
|
3381
|
+
});
|
|
3382
|
+
return layers;
|
|
3383
|
+
}
|
|
3384
|
+
};
|
|
3385
|
+
_LineLayer.layerName = "LineLayer";
|
|
3386
|
+
_LineLayer.defaultProps = {
|
|
3387
|
+
network: void 0,
|
|
3388
|
+
geoData: void 0,
|
|
3389
|
+
getNominalVoltageColor: {
|
|
3390
|
+
type: "accessor",
|
|
3391
|
+
value: () => [255, 255, 255]
|
|
3392
|
+
/*getNominalVoltageColor*/
|
|
3393
|
+
},
|
|
3394
|
+
disconnectedLineColor: { type: "color", value: [255, 255, 255] },
|
|
3395
|
+
filteredNominalVoltages: void 0,
|
|
3396
|
+
lineFlowMode: "feeders",
|
|
3397
|
+
lineFlowColorMode: "nominalVoltage",
|
|
3398
|
+
lineFlowAlertThreshold: 100,
|
|
3399
|
+
showLineFlow: true,
|
|
3400
|
+
lineFullPath: true,
|
|
3401
|
+
lineParallelPath: true,
|
|
3402
|
+
labelSize: 12,
|
|
3403
|
+
iconSize: 48,
|
|
3404
|
+
distanceBetweenLines: 1e3,
|
|
3405
|
+
maxParallelOffset: 100,
|
|
3406
|
+
minParallelOffset: 3,
|
|
3407
|
+
substationRadius: { type: "number", value: SUBSTATION_RADIUS },
|
|
3408
|
+
substationMaxPixel: { type: "number", value: SUBSTATION_RADIUS_MAX_PIXEL },
|
|
3409
|
+
minSubstationRadiusPixel: {
|
|
3410
|
+
type: "number",
|
|
3411
|
+
value: SUBSTATION_RADIUS_MIN_PIXEL
|
|
3412
|
+
},
|
|
3413
|
+
labelColor: [255, 255, 255]
|
|
3414
|
+
};
|
|
3415
|
+
let LineLayer = _LineLayer;
|
|
3416
|
+
const elementIdIndexer = (map, element) => map.set(element.id, element);
|
|
3417
|
+
class MapEquipments {
|
|
3418
|
+
constructor() {
|
|
3419
|
+
this.substations = [];
|
|
3420
|
+
this.substationsById = /* @__PURE__ */ new Map();
|
|
3421
|
+
this.lines = [];
|
|
3422
|
+
this.linesById = /* @__PURE__ */ new Map();
|
|
3423
|
+
this.tieLines = [];
|
|
3424
|
+
this.tieLinesById = /* @__PURE__ */ new Map();
|
|
3425
|
+
this.hvdcLines = [];
|
|
3426
|
+
this.hvdcLinesById = /* @__PURE__ */ new Map();
|
|
3427
|
+
this.voltageLevels = [];
|
|
3428
|
+
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3429
|
+
this.nominalVoltages = [];
|
|
3430
|
+
}
|
|
3431
|
+
newMapEquipmentForUpdate() {
|
|
3432
|
+
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
3433
|
+
}
|
|
3434
|
+
checkAndGetValues(equipments) {
|
|
3435
|
+
return equipments ?? [];
|
|
3436
|
+
}
|
|
3437
|
+
completeSubstationsInfos(equipmentsToIndex) {
|
|
3438
|
+
const nominalVoltagesSet = new Set(this.nominalVoltages);
|
|
3439
|
+
if ((equipmentsToIndex == null ? void 0 : equipmentsToIndex.length) === 0) {
|
|
3440
|
+
this.substationsById = /* @__PURE__ */ new Map();
|
|
3441
|
+
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3442
|
+
}
|
|
3443
|
+
const substations = (equipmentsToIndex == null ? void 0 : equipmentsToIndex.length) > 0 ? equipmentsToIndex : this.substations;
|
|
3444
|
+
substations.forEach((substation) => {
|
|
3445
|
+
substation.voltageLevels = substation.voltageLevels.sort(
|
|
3446
|
+
(voltageLevel1, voltageLevel2) => voltageLevel1.nominalV - voltageLevel2.nominalV
|
|
3447
|
+
);
|
|
3448
|
+
this.substationsById.set(substation.id, substation);
|
|
3449
|
+
substation.voltageLevels.forEach((voltageLevel) => {
|
|
3450
|
+
voltageLevel.substationId = substation.id;
|
|
3451
|
+
voltageLevel.substationName = substation.name;
|
|
3452
|
+
this.voltageLevelsById.set(voltageLevel.id, voltageLevel);
|
|
3453
|
+
nominalVoltagesSet.add(voltageLevel.nominalV);
|
|
3454
|
+
});
|
|
3455
|
+
});
|
|
3456
|
+
this.voltageLevels = Array.from(this.voltageLevelsById.values());
|
|
3457
|
+
this.nominalVoltages = Array.from(nominalVoltagesSet).sort((a, b) => b - a);
|
|
3458
|
+
}
|
|
3459
|
+
updateEquipments(currentEquipments, newEquipments) {
|
|
3460
|
+
currentEquipments.forEach((equipment1, index) => {
|
|
3461
|
+
const found = newEquipments.filter((equipment2) => equipment2.id === equipment1.id);
|
|
3462
|
+
currentEquipments[index] = found.length > 0 ? found[0] : equipment1;
|
|
3463
|
+
});
|
|
3464
|
+
const eqptsToAdd = newEquipments.filter(
|
|
3465
|
+
(eqpt) => !currentEquipments.some((otherEqpt) => otherEqpt.id === eqpt.id)
|
|
3466
|
+
);
|
|
3467
|
+
if (eqptsToAdd.length === 0) {
|
|
3468
|
+
return currentEquipments;
|
|
3469
|
+
}
|
|
3470
|
+
return [...currentEquipments, ...eqptsToAdd];
|
|
3471
|
+
}
|
|
3472
|
+
updateSubstations(substations, fullReload) {
|
|
3473
|
+
if (fullReload) {
|
|
3474
|
+
this.substations = [];
|
|
3475
|
+
this.nominalVoltages = [];
|
|
3476
|
+
}
|
|
3477
|
+
let voltageLevelAdded = false;
|
|
3478
|
+
this.substations.forEach((substation1, index) => {
|
|
3479
|
+
const found = substations.filter((substation2) => substation2.id === substation1.id);
|
|
3480
|
+
if (found.length > 0) {
|
|
3481
|
+
if (found[0].voltageLevels.length > substation1.voltageLevels.length) {
|
|
3482
|
+
voltageLevelAdded = true;
|
|
3483
|
+
}
|
|
3484
|
+
this.substations[index] = found[0];
|
|
3485
|
+
}
|
|
3486
|
+
});
|
|
3487
|
+
let substationAdded = false;
|
|
3488
|
+
substations.forEach((substation1) => {
|
|
3489
|
+
const found = this.substations.find((substation2) => substation2.id === substation1.id);
|
|
3490
|
+
if (found === void 0) {
|
|
3491
|
+
this.substations.push(substation1);
|
|
3492
|
+
substationAdded = true;
|
|
3493
|
+
}
|
|
3494
|
+
});
|
|
3495
|
+
if (substationAdded || voltageLevelAdded) {
|
|
3496
|
+
this.substations = [...this.substations];
|
|
3497
|
+
}
|
|
3498
|
+
this.completeSubstationsInfos(fullReload ? [] : substations);
|
|
3499
|
+
}
|
|
3500
|
+
completeLinesInfos(equipmentsToIndex) {
|
|
3501
|
+
if ((equipmentsToIndex == null ? void 0 : equipmentsToIndex.length) > 0) {
|
|
3502
|
+
equipmentsToIndex.forEach((line) => {
|
|
3503
|
+
var _a;
|
|
3504
|
+
(_a = this.linesById) == null ? void 0 : _a.set(line.id, line);
|
|
3505
|
+
});
|
|
3506
|
+
} else {
|
|
3507
|
+
this.linesById = this.lines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
completeTieLinesInfos(equipmentsToIndex) {
|
|
3511
|
+
if ((equipmentsToIndex == null ? void 0 : equipmentsToIndex.length) > 0) {
|
|
3512
|
+
equipmentsToIndex.forEach((tieLine) => {
|
|
3513
|
+
var _a;
|
|
3514
|
+
(_a = this.tieLinesById) == null ? void 0 : _a.set(tieLine.id, tieLine);
|
|
3515
|
+
});
|
|
3516
|
+
} else {
|
|
3517
|
+
this.tieLinesById = this.tieLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
updateLines(lines, fullReload) {
|
|
3521
|
+
if (fullReload) {
|
|
3522
|
+
this.lines = [];
|
|
3523
|
+
}
|
|
3524
|
+
this.lines = this.updateEquipments(this.lines, lines);
|
|
3525
|
+
this.completeLinesInfos(fullReload ? [] : lines);
|
|
3526
|
+
}
|
|
3527
|
+
updateTieLines(tieLines, fullReload) {
|
|
3528
|
+
if (fullReload) {
|
|
3529
|
+
this.tieLines = [];
|
|
3530
|
+
}
|
|
3531
|
+
this.tieLines = this.updateEquipments(this.tieLines, tieLines);
|
|
3532
|
+
this.completeTieLinesInfos(fullReload ? [] : tieLines);
|
|
3533
|
+
}
|
|
3534
|
+
updateHvdcLines(hvdcLines, fullReload) {
|
|
3535
|
+
if (fullReload) {
|
|
3536
|
+
this.hvdcLines = [];
|
|
3537
|
+
}
|
|
3538
|
+
this.hvdcLines = this.updateEquipments(this.hvdcLines, hvdcLines);
|
|
3539
|
+
this.completeHvdcLinesInfos(fullReload ? [] : hvdcLines);
|
|
3540
|
+
}
|
|
3541
|
+
completeHvdcLinesInfos(equipmentsToIndex) {
|
|
3542
|
+
if ((equipmentsToIndex == null ? void 0 : equipmentsToIndex.length) > 0) {
|
|
3543
|
+
equipmentsToIndex.forEach((hvdcLine) => {
|
|
3544
|
+
var _a;
|
|
3545
|
+
(_a = this.hvdcLinesById) == null ? void 0 : _a.set(hvdcLine.id, hvdcLine);
|
|
3546
|
+
});
|
|
3547
|
+
} else {
|
|
3548
|
+
this.hvdcLinesById = this.hvdcLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
removeBranchesOfVoltageLevel(branchesList, voltageLevelId) {
|
|
3552
|
+
const remainingLines = branchesList.filter(
|
|
3553
|
+
(l) => l.voltageLevelId1 !== voltageLevelId && l.voltageLevelId2 !== voltageLevelId
|
|
3554
|
+
);
|
|
3555
|
+
branchesList.filter((l) => !remainingLines.includes(l)).forEach((l) => this.linesById.delete(l.id));
|
|
3556
|
+
return remainingLines;
|
|
3557
|
+
}
|
|
3558
|
+
removeEquipment(equipmentType, equipmentId) {
|
|
3559
|
+
var _a, _b;
|
|
3560
|
+
switch (equipmentType) {
|
|
3561
|
+
case EQUIPMENT_TYPES.LINE: {
|
|
3562
|
+
this.lines = this.lines.filter((l) => l.id !== equipmentId);
|
|
3563
|
+
this.linesById.delete(equipmentId);
|
|
3564
|
+
break;
|
|
3565
|
+
}
|
|
3566
|
+
case EQUIPMENT_TYPES.VOLTAGE_LEVEL: {
|
|
3567
|
+
const substationId = (_a = this.voltageLevelsById.get(equipmentId)) == null ? void 0 : _a.substationId;
|
|
3568
|
+
let voltageLevelsOfSubstation = (_b = this.substationsById.get(substationId)) == null ? void 0 : _b.voltageLevels;
|
|
3569
|
+
voltageLevelsOfSubstation = voltageLevelsOfSubstation == null ? void 0 : voltageLevelsOfSubstation.filter((l) => l.id !== equipmentId);
|
|
3570
|
+
const substation = this.substationsById.get(substationId);
|
|
3571
|
+
if (substation !== void 0) {
|
|
3572
|
+
substation.voltageLevels = voltageLevelsOfSubstation;
|
|
3573
|
+
}
|
|
3574
|
+
this.removeBranchesOfVoltageLevel(this.lines, equipmentId);
|
|
3575
|
+
this.substations = [...this.substations];
|
|
3576
|
+
break;
|
|
3577
|
+
}
|
|
3578
|
+
case EQUIPMENT_TYPES.SUBSTATION: {
|
|
3579
|
+
this.substations = this.substations.filter((l) => l.id !== equipmentId);
|
|
3580
|
+
const substation = this.substationsById.get(equipmentId);
|
|
3581
|
+
substation == null ? void 0 : substation.voltageLevels.forEach((vl) => this.removeEquipment(EQUIPMENT_TYPES.VOLTAGE_LEVEL, vl.id));
|
|
3582
|
+
this.completeSubstationsInfos([substation]);
|
|
3583
|
+
break;
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
getVoltageLevels() {
|
|
3588
|
+
return this.voltageLevels;
|
|
3589
|
+
}
|
|
3590
|
+
getVoltageLevel(id) {
|
|
3591
|
+
return this.voltageLevelsById.get(id);
|
|
3592
|
+
}
|
|
3593
|
+
getSubstations() {
|
|
3594
|
+
return this.substations;
|
|
3595
|
+
}
|
|
3596
|
+
getSubstation(id) {
|
|
3597
|
+
return this.substationsById.get(id);
|
|
3598
|
+
}
|
|
3599
|
+
getNominalVoltages() {
|
|
3600
|
+
return this.nominalVoltages;
|
|
3601
|
+
}
|
|
3602
|
+
getLines() {
|
|
3603
|
+
return this.lines;
|
|
3604
|
+
}
|
|
3605
|
+
getLine(id) {
|
|
3606
|
+
return this.linesById.get(id);
|
|
3607
|
+
}
|
|
3608
|
+
getHvdcLines() {
|
|
3609
|
+
return this.hvdcLines;
|
|
3610
|
+
}
|
|
3611
|
+
getHvdcLine(id) {
|
|
3612
|
+
return this.hvdcLinesById.get(id);
|
|
3613
|
+
}
|
|
3614
|
+
getTieLines() {
|
|
3615
|
+
return this.tieLines;
|
|
3616
|
+
}
|
|
3617
|
+
getTieLine(id) {
|
|
3618
|
+
return this.tieLinesById.get(id);
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
const defaultProps = {
|
|
3622
|
+
getRadiusMaxPixels: { type: "accessor", value: 1 }
|
|
3623
|
+
};
|
|
3624
|
+
const _ScatterplotLayerExt = class _ScatterplotLayerExt extends ScatterplotLayer {
|
|
3625
|
+
getShaders() {
|
|
3626
|
+
const shaders = super.getShaders();
|
|
3627
|
+
return Object.assign({}, shaders, {
|
|
3628
|
+
vs: shaders.vs.replace(", radiusMaxPixels", ", instanceRadiusMaxPixels"),
|
|
3629
|
+
// hack to replace the uniform variable to corresponding attribute
|
|
3630
|
+
inject: {
|
|
3631
|
+
"vs:#decl": `attribute float instanceRadiusMaxPixels;
|
|
3632
|
+
`
|
|
3633
|
+
}
|
|
3634
|
+
});
|
|
3635
|
+
}
|
|
3636
|
+
initializeState() {
|
|
3637
|
+
var _a;
|
|
3638
|
+
super.initializeState();
|
|
3639
|
+
(_a = this.getAttributeManager()) == null ? void 0 : _a.addInstanced({
|
|
3640
|
+
instanceRadiusMaxPixels: {
|
|
3641
|
+
size: 1,
|
|
3642
|
+
transition: true,
|
|
3643
|
+
accessor: "getRadiusMaxPixels",
|
|
3644
|
+
type: GL.FLOAT,
|
|
3645
|
+
defaultValue: 0
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
};
|
|
3650
|
+
_ScatterplotLayerExt.layerName = "ScatterplotLayerExt";
|
|
3651
|
+
_ScatterplotLayerExt.defaultProps = defaultProps;
|
|
3652
|
+
let ScatterplotLayerExt = _ScatterplotLayerExt;
|
|
3653
|
+
function voltageLevelNominalVoltageIndexer(map, voltageLevel) {
|
|
3654
|
+
let list = map.get(voltageLevel.nominalV);
|
|
3655
|
+
if (!list) {
|
|
3656
|
+
list = [];
|
|
3657
|
+
map.set(voltageLevel.nominalV, list);
|
|
3658
|
+
}
|
|
3659
|
+
list.push(voltageLevel);
|
|
3660
|
+
return map;
|
|
3661
|
+
}
|
|
3662
|
+
const _SubstationLayer = class _SubstationLayer extends CompositeLayer {
|
|
3663
|
+
initializeState(context) {
|
|
3664
|
+
super.initializeState(context);
|
|
3665
|
+
this.state = {
|
|
3666
|
+
compositeData: [],
|
|
3667
|
+
substationsLabels: [],
|
|
3668
|
+
metaVoltageLevelsByNominalVoltage: []
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
updateState({ props, oldProps, changeFlags }) {
|
|
3672
|
+
if (changeFlags.dataChanged) {
|
|
3673
|
+
const metaVoltageLevelsByNominalVoltage = /* @__PURE__ */ new Map();
|
|
3674
|
+
if (props.network != null && props.geoData != null) {
|
|
3675
|
+
props.data.forEach((substation) => {
|
|
3676
|
+
const voltageLevelsByNominalVoltage = substation.voltageLevels.reduce(
|
|
3677
|
+
voltageLevelNominalVoltageIndexer,
|
|
3678
|
+
/* @__PURE__ */ new Map()
|
|
3679
|
+
);
|
|
3680
|
+
const nominalVoltages = [
|
|
3681
|
+
...new Set(
|
|
3682
|
+
substation.voltageLevels.map((voltageLevel) => voltageLevel.nominalV).sort((nominalVoltage1, nominalVoltage2) => nominalVoltage1 - nominalVoltage2)
|
|
3683
|
+
)
|
|
3684
|
+
];
|
|
3685
|
+
Array.from(voltageLevelsByNominalVoltage.entries()).forEach((e) => {
|
|
3686
|
+
const nominalV = e[0];
|
|
3687
|
+
const voltageLevels = e[1];
|
|
3688
|
+
let metaVoltageLevels = metaVoltageLevelsByNominalVoltage.get(nominalV);
|
|
3689
|
+
if (!metaVoltageLevels) {
|
|
3690
|
+
metaVoltageLevels = [];
|
|
3691
|
+
metaVoltageLevelsByNominalVoltage.set(nominalV, metaVoltageLevels);
|
|
3692
|
+
}
|
|
3693
|
+
metaVoltageLevels.push({
|
|
3694
|
+
voltageLevels,
|
|
3695
|
+
nominalVoltageIndex: nominalVoltages.indexOf(nominalV)
|
|
3696
|
+
});
|
|
3697
|
+
});
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
const metaVoltageLevelsByNominalVoltageArray = Array.from(metaVoltageLevelsByNominalVoltage).map((e) => ({ nominalV: e[0], metaVoltageLevels: e[1] })).sort((a, b) => b.nominalV - a.nominalV);
|
|
3701
|
+
this.setState({ metaVoltageLevelsByNominalVoltage: metaVoltageLevelsByNominalVoltageArray });
|
|
3702
|
+
}
|
|
3703
|
+
if (changeFlags.dataChanged || props.getNameOrId !== oldProps.getNameOrId || props.filteredNominalVoltages !== oldProps.filteredNominalVoltages) {
|
|
3704
|
+
let substationsLabels = props.data;
|
|
3705
|
+
if (props.network != null && props.geoData != null && props.filteredNominalVoltages != null) {
|
|
3706
|
+
substationsLabels = substationsLabels.filter(
|
|
3707
|
+
(substation) => substation.voltageLevels.find((v) => {
|
|
3708
|
+
var _a;
|
|
3709
|
+
return (_a = props.filteredNominalVoltages) == null ? void 0 : _a.includes(v.nominalV);
|
|
3710
|
+
}) !== void 0
|
|
3711
|
+
);
|
|
3712
|
+
}
|
|
3713
|
+
this.setState({ substationsLabels });
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
renderLayers() {
|
|
3717
|
+
const layers = [];
|
|
3718
|
+
this.state.metaVoltageLevelsByNominalVoltage.forEach((e) => {
|
|
3719
|
+
const substationsLayer = new ScatterplotLayerExt(
|
|
3720
|
+
this.getSubLayerProps({
|
|
3721
|
+
id: "NominalVoltage" + e.nominalV,
|
|
3722
|
+
data: e.metaVoltageLevels,
|
|
3723
|
+
radiusMinPixels: SUBSTATION_RADIUS_MIN_PIXEL,
|
|
3724
|
+
getRadiusMaxPixels: (metaVoltageLevel) => SUBSTATION_RADIUS_MAX_PIXEL * (metaVoltageLevel.nominalVoltageIndex + 1),
|
|
3725
|
+
getPosition: (metaVoltageLevel) => this.props.geoData.getSubstationPosition(metaVoltageLevel.voltageLevels[0].substationId),
|
|
3726
|
+
getFillColor: this.props.getNominalVoltageColor(e.nominalV),
|
|
3727
|
+
getRadius: (voltageLevel) => SUBSTATION_RADIUS * (voltageLevel.nominalVoltageIndex + 1),
|
|
3728
|
+
visible: !this.props.filteredNominalVoltages || this.props.filteredNominalVoltages.includes(e.nominalV),
|
|
3729
|
+
updateTriggers: {
|
|
3730
|
+
getPosition: [this.props.geoData.substationPositionsById, this.props.network.substations]
|
|
3731
|
+
}
|
|
3732
|
+
})
|
|
3733
|
+
);
|
|
3734
|
+
layers.push(substationsLayer);
|
|
3735
|
+
});
|
|
3736
|
+
const substationLabelsLayer = new TextLayer(
|
|
3737
|
+
this.getSubLayerProps({
|
|
3738
|
+
id: "Label",
|
|
3739
|
+
data: this.state.substationsLabels,
|
|
3740
|
+
getPosition: (substation) => this.props.geoData.getSubstationPosition(substation.id),
|
|
3741
|
+
getText: (substation) => this.props.getNameOrId(substation) ?? "",
|
|
3742
|
+
getColor: this.props.labelColor,
|
|
3743
|
+
fontFamily: "Roboto",
|
|
3744
|
+
getSize: this.props.labelSize,
|
|
3745
|
+
getAngle: 0,
|
|
3746
|
+
getTextAnchor: "start",
|
|
3747
|
+
getAlignmentBaseline: "center",
|
|
3748
|
+
getPixelOffset: [20 / 1.5, 0],
|
|
3749
|
+
visible: this.props.labelsVisible,
|
|
3750
|
+
updateTriggers: {
|
|
3751
|
+
getText: [this.props.getNameOrId],
|
|
3752
|
+
getPosition: [this.props.geoData.substationPositionsById, this.props.network.substations]
|
|
3753
|
+
}
|
|
3754
|
+
})
|
|
3755
|
+
);
|
|
3756
|
+
layers.push(substationLabelsLayer);
|
|
3757
|
+
return layers;
|
|
3758
|
+
}
|
|
3759
|
+
};
|
|
3760
|
+
_SubstationLayer.layerName = "SubstationLayer";
|
|
3761
|
+
_SubstationLayer.defaultProps = {
|
|
3762
|
+
network: void 0,
|
|
3763
|
+
geoData: void 0,
|
|
3764
|
+
getNominalVoltageColor: { type: "accessor", value: () => [255, 255, 255] },
|
|
3765
|
+
filteredNominalVoltages: null,
|
|
3766
|
+
labelsVisible: false,
|
|
3767
|
+
labelColor: { type: "color", value: [255, 255, 255] },
|
|
3768
|
+
labelSize: 12
|
|
3769
|
+
};
|
|
3770
|
+
let SubstationLayer = _SubstationLayer;
|
|
3771
|
+
var Country = /* @__PURE__ */ ((Country2) => {
|
|
3772
|
+
Country2["AF"] = "AFGHANISTAN";
|
|
3773
|
+
Country2["AX"] = "ÅLAND ISLANDS";
|
|
3774
|
+
Country2["AL"] = "ALBANIA";
|
|
3775
|
+
Country2["DZ"] = "ALGERIA";
|
|
3776
|
+
Country2["AS"] = "AMERICAN SAMOA";
|
|
3777
|
+
Country2["AD"] = "ANDORRA";
|
|
3778
|
+
Country2["AO"] = "ANGOLA";
|
|
3779
|
+
Country2["AI"] = "ANGUILLA";
|
|
3780
|
+
Country2["AQ"] = "ANTARCTICA";
|
|
3781
|
+
Country2["AG"] = "ANTIGUA AND BARBUDA";
|
|
3782
|
+
Country2["AR"] = "ARGENTINA";
|
|
3783
|
+
Country2["AM"] = "ARMENIA";
|
|
3784
|
+
Country2["AW"] = "ARUBA";
|
|
3785
|
+
Country2["AU"] = "AUSTRALIA";
|
|
3786
|
+
Country2["AT"] = "AUSTRIA";
|
|
3787
|
+
Country2["AZ"] = "AZERBAIJAN";
|
|
3788
|
+
Country2["BS"] = "BAHAMAS";
|
|
3789
|
+
Country2["BH"] = "BAHRAIN";
|
|
3790
|
+
Country2["BD"] = "BANGLADESH";
|
|
3791
|
+
Country2["BB"] = "BARBADOS";
|
|
3792
|
+
Country2["BY"] = "BELARUS";
|
|
3793
|
+
Country2["BE"] = "BELGIUM";
|
|
3794
|
+
Country2["BZ"] = "BELIZE";
|
|
3795
|
+
Country2["BJ"] = "BENIN";
|
|
3796
|
+
Country2["BM"] = "BERMUDA";
|
|
3797
|
+
Country2["BT"] = "BHUTAN";
|
|
3798
|
+
Country2["BO"] = "BOLIVIA, PLURINATIONAL STATE OF";
|
|
3799
|
+
Country2["BQ"] = "BONAIRE, SINT EUSTATIUS AND SABA";
|
|
3800
|
+
Country2["BA"] = "BOSNIA AND HERZEGOVINA";
|
|
3801
|
+
Country2["BW"] = "BOTSWANA";
|
|
3802
|
+
Country2["BV"] = "BOUVET ISLAND";
|
|
3803
|
+
Country2["BR"] = "BRAZIL";
|
|
3804
|
+
Country2["IO"] = "BRITISH INDIAN OCEAN TERRITORY";
|
|
3805
|
+
Country2["BN"] = "BRUNEI DARUSSALAM";
|
|
3806
|
+
Country2["BG"] = "BULGARIA";
|
|
3807
|
+
Country2["BF"] = "BURKINA FASO";
|
|
3808
|
+
Country2["BI"] = "BURUNDI";
|
|
3809
|
+
Country2["KH"] = "CAMBODIA";
|
|
3810
|
+
Country2["CM"] = "CAMEROON";
|
|
3811
|
+
Country2["CA"] = "CANADA";
|
|
3812
|
+
Country2["CV"] = "CAPE VERDE";
|
|
3813
|
+
Country2["KY"] = "CAYMAN ISLANDS";
|
|
3814
|
+
Country2["CF"] = "CENTRAL AFRICAN REPUBLIC";
|
|
3815
|
+
Country2["TD"] = "CHAD";
|
|
3816
|
+
Country2["CL"] = "CHILE";
|
|
3817
|
+
Country2["CN"] = "CHINA";
|
|
3818
|
+
Country2["CX"] = "CHRISTMAS ISLAND";
|
|
3819
|
+
Country2["CC"] = "COCOS (KEELING) ISLANDS";
|
|
3820
|
+
Country2["CO"] = "COLOMBIA";
|
|
3821
|
+
Country2["KM"] = "COMOROS";
|
|
3822
|
+
Country2["CG"] = "CONGO";
|
|
3823
|
+
Country2["CD"] = "CONGO, THE DEMOCRATIC REPUBLIC OF THE";
|
|
3824
|
+
Country2["CK"] = "COOK ISLANDS";
|
|
3825
|
+
Country2["CR"] = "COSTA RICA";
|
|
3826
|
+
Country2["CI"] = "CÔTE D'IVOIRE";
|
|
3827
|
+
Country2["HR"] = "CROATIA";
|
|
3828
|
+
Country2["CU"] = "CUBA";
|
|
3829
|
+
Country2["CW"] = "CURAÇAO";
|
|
3830
|
+
Country2["CY"] = "CYPRUS";
|
|
3831
|
+
Country2["CZ"] = "CZECH REPUBLIC";
|
|
3832
|
+
Country2["DK"] = "DENMARK";
|
|
3833
|
+
Country2["DJ"] = "DJIBOUTI";
|
|
3834
|
+
Country2["DM"] = "DOMINICA";
|
|
3835
|
+
Country2["DO"] = "DOMINICAN REPUBLIC";
|
|
3836
|
+
Country2["EC"] = "ECUADOR";
|
|
3837
|
+
Country2["EG"] = "EGYPT";
|
|
3838
|
+
Country2["SV"] = "EL SALVADOR";
|
|
3839
|
+
Country2["GQ"] = "EQUATORIAL GUINEA";
|
|
3840
|
+
Country2["ER"] = "ERITREA";
|
|
3841
|
+
Country2["EE"] = "ESTONIA";
|
|
3842
|
+
Country2["ET"] = "ETHIOPIA";
|
|
3843
|
+
Country2["FK"] = "FALKLAND ISLANDS (MALVINAS)";
|
|
3844
|
+
Country2["FO"] = "FAROE ISLANDS";
|
|
3845
|
+
Country2["FJ"] = "FIJI";
|
|
3846
|
+
Country2["FI"] = "FINLAND";
|
|
3847
|
+
Country2["FR"] = "FRANCE";
|
|
3848
|
+
Country2["GF"] = "FRENCH GUIANA";
|
|
3849
|
+
Country2["PF"] = "FRENCH POLYNESIA";
|
|
3850
|
+
Country2["TF"] = "FRENCH SOUTHERN TERRITORIES";
|
|
3851
|
+
Country2["GA"] = "GABON";
|
|
3852
|
+
Country2["GM"] = "GAMBIA";
|
|
3853
|
+
Country2["GE"] = "GEORGIA";
|
|
3854
|
+
Country2["DE"] = "GERMANY";
|
|
3855
|
+
Country2["GH"] = "GHANA";
|
|
3856
|
+
Country2["GI"] = "GIBRALTAR";
|
|
3857
|
+
Country2["GR"] = "GREECE";
|
|
3858
|
+
Country2["GL"] = "GREENLAND";
|
|
3859
|
+
Country2["GD"] = "GRENADA";
|
|
3860
|
+
Country2["GP"] = "GUADELOUPE";
|
|
3861
|
+
Country2["GU"] = "GUAM";
|
|
3862
|
+
Country2["GT"] = "GUATEMALA";
|
|
3863
|
+
Country2["GG"] = "GUERNSEY";
|
|
3864
|
+
Country2["GN"] = "GUINEA";
|
|
3865
|
+
Country2["GW"] = "GUINEA-BISSAU";
|
|
3866
|
+
Country2["GY"] = "GUYANA";
|
|
3867
|
+
Country2["HT"] = "HAITI";
|
|
3868
|
+
Country2["HM"] = "HEARD ISLAND AND MCDONALD ISLANDS";
|
|
3869
|
+
Country2["VA"] = "HOLY SEE (VATICAN CITY STATE)";
|
|
3870
|
+
Country2["HN"] = "HONDURAS";
|
|
3871
|
+
Country2["HK"] = "HONG KONG";
|
|
3872
|
+
Country2["HU"] = "HUNGARY";
|
|
3873
|
+
Country2["IS"] = "ICELAND";
|
|
3874
|
+
Country2["IN"] = "INDIA";
|
|
3875
|
+
Country2["ID"] = "INDONESIA";
|
|
3876
|
+
Country2["IR"] = "IRAN, ISLAMIC REPUBLIC OF";
|
|
3877
|
+
Country2["IQ"] = "IRAQ";
|
|
3878
|
+
Country2["IE"] = "IRELAND";
|
|
3879
|
+
Country2["IM"] = "ISLE OF MAN";
|
|
3880
|
+
Country2["IL"] = "ISRAEL";
|
|
3881
|
+
Country2["IT"] = "ITALY";
|
|
3882
|
+
Country2["JM"] = "JAMAICA";
|
|
3883
|
+
Country2["JP"] = "JAPAN";
|
|
3884
|
+
Country2["JE"] = "JERSEY";
|
|
3885
|
+
Country2["JO"] = "JORDAN";
|
|
3886
|
+
Country2["KZ"] = "KAZAKHSTAN";
|
|
3887
|
+
Country2["KE"] = "KENYA";
|
|
3888
|
+
Country2["KI"] = "KIRIBATI";
|
|
3889
|
+
Country2["KP"] = "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF";
|
|
3890
|
+
Country2["KR"] = "KOREA, REPUBLIC OF";
|
|
3891
|
+
Country2["XK"] = "KOSOVO";
|
|
3892
|
+
Country2["KW"] = "KUWAIT";
|
|
3893
|
+
Country2["KG"] = "KYRGYZSTAN";
|
|
3894
|
+
Country2["LA"] = "LAO PEOPLE'S DEMOCRATIC REPUBLIC";
|
|
3895
|
+
Country2["LV"] = "LATVIA";
|
|
3896
|
+
Country2["LB"] = "LEBANON";
|
|
3897
|
+
Country2["LS"] = "LESOTHO";
|
|
3898
|
+
Country2["LR"] = "LIBERIA";
|
|
3899
|
+
Country2["LY"] = "LIBYA";
|
|
3900
|
+
Country2["LI"] = "LIECHTENSTEIN";
|
|
3901
|
+
Country2["LT"] = "LITHUANIA";
|
|
3902
|
+
Country2["LU"] = "LUXEMBOURG";
|
|
3903
|
+
Country2["MO"] = "MACAO";
|
|
3904
|
+
Country2["MK"] = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF";
|
|
3905
|
+
Country2["MG"] = "MADAGASCAR";
|
|
3906
|
+
Country2["MW"] = "MALAWI";
|
|
3907
|
+
Country2["MY"] = "MALAYSIA";
|
|
3908
|
+
Country2["MV"] = "MALDIVES";
|
|
3909
|
+
Country2["ML"] = "MALI";
|
|
3910
|
+
Country2["MT"] = "MALTA";
|
|
3911
|
+
Country2["MH"] = "MARSHALL ISLANDS";
|
|
3912
|
+
Country2["MQ"] = "MARTINIQUE";
|
|
3913
|
+
Country2["MR"] = "MAURITANIA";
|
|
3914
|
+
Country2["MU"] = "MAURITIUS";
|
|
3915
|
+
Country2["YT"] = "MAYOTTE";
|
|
3916
|
+
Country2["MX"] = "MEXICO";
|
|
3917
|
+
Country2["FM"] = "MICRONESIA, FEDERATED STATES OF";
|
|
3918
|
+
Country2["MD"] = "MOLDOVA, REPUBLIC OF";
|
|
3919
|
+
Country2["MC"] = "MONACO";
|
|
3920
|
+
Country2["MN"] = "MONGOLIA";
|
|
3921
|
+
Country2["ME"] = "MONTENEGRO";
|
|
3922
|
+
Country2["MS"] = "MONTSERRAT";
|
|
3923
|
+
Country2["MA"] = "MOROCCO";
|
|
3924
|
+
Country2["MZ"] = "MOZAMBIQUE";
|
|
3925
|
+
Country2["MM"] = "MYANMAR";
|
|
3926
|
+
Country2["NA"] = "NAMIBIA";
|
|
3927
|
+
Country2["NR"] = "NAURU";
|
|
3928
|
+
Country2["NP"] = "NEPAL";
|
|
3929
|
+
Country2["NL"] = "NETHERLANDS";
|
|
3930
|
+
Country2["NC"] = "NEW CALEDONIA";
|
|
3931
|
+
Country2["NZ"] = "NEW ZEALAND";
|
|
3932
|
+
Country2["NI"] = "NICARAGUA";
|
|
3933
|
+
Country2["NE"] = "NIGER";
|
|
3934
|
+
Country2["NG"] = "NIGERIA";
|
|
3935
|
+
Country2["NU"] = "NIUE";
|
|
3936
|
+
Country2["NF"] = "NORFOLK ISLAND";
|
|
3937
|
+
Country2["MP"] = "NORTHERN MARIANA ISLANDS";
|
|
3938
|
+
Country2["NO"] = "NORWAY";
|
|
3939
|
+
Country2["OM"] = "OMAN";
|
|
3940
|
+
Country2["PK"] = "PAKISTAN";
|
|
3941
|
+
Country2["PW"] = "PALAU";
|
|
3942
|
+
Country2["PS"] = "PALESTINE, STATE OF";
|
|
3943
|
+
Country2["PA"] = "PANAMA";
|
|
3944
|
+
Country2["PG"] = "PAPUA NEW GUINEA";
|
|
3945
|
+
Country2["PY"] = "PARAGUAY";
|
|
3946
|
+
Country2["PE"] = "PERU";
|
|
3947
|
+
Country2["PH"] = "PHILIPPINES";
|
|
3948
|
+
Country2["PN"] = "PITCAIRN";
|
|
3949
|
+
Country2["PL"] = "POLAND";
|
|
3950
|
+
Country2["PT"] = "PORTUGAL";
|
|
3951
|
+
Country2["PR"] = "PUERTO RICO";
|
|
3952
|
+
Country2["QA"] = "QATAR";
|
|
3953
|
+
Country2["RE"] = "RÉUNION";
|
|
3954
|
+
Country2["RO"] = "ROMANIA";
|
|
3955
|
+
Country2["RU"] = "RUSSIAN FEDERATION";
|
|
3956
|
+
Country2["RW"] = "RWANDA";
|
|
3957
|
+
Country2["BL"] = "SAINT BARTHÉLEMY";
|
|
3958
|
+
Country2["SH"] = "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA";
|
|
3959
|
+
Country2["KN"] = "SAINT KITTS AND NEVIS";
|
|
3960
|
+
Country2["LC"] = "SAINT LUCIA";
|
|
3961
|
+
Country2["MF"] = "SAINT MARTIN (FRENCH PART)";
|
|
3962
|
+
Country2["PM"] = "SAINT PIERRE AND MIQUELON";
|
|
3963
|
+
Country2["VC"] = "SAINT VINCENT AND THE GRENADINES";
|
|
3964
|
+
Country2["WS"] = "SAMOA";
|
|
3965
|
+
Country2["SM"] = "SAN MARINO";
|
|
3966
|
+
Country2["ST"] = "SAO TOME AND PRINCIPE";
|
|
3967
|
+
Country2["SA"] = "SAUDI ARABIA";
|
|
3968
|
+
Country2["SN"] = "SENEGAL";
|
|
3969
|
+
Country2["RS"] = "SERBIA";
|
|
3970
|
+
Country2["SC"] = "SEYCHELLES";
|
|
3971
|
+
Country2["SL"] = "SIERRA LEONE";
|
|
3972
|
+
Country2["SG"] = "SINGAPORE";
|
|
3973
|
+
Country2["SX"] = "SINT MAARTEN (DUTCH PART)";
|
|
3974
|
+
Country2["SK"] = "SLOVAKIA";
|
|
3975
|
+
Country2["SI"] = "SLOVENIA";
|
|
3976
|
+
Country2["SB"] = "SOLOMON ISLANDS";
|
|
3977
|
+
Country2["SO"] = "SOMALIA";
|
|
3978
|
+
Country2["ZA"] = "SOUTH AFRICA";
|
|
3979
|
+
Country2["GS"] = "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS";
|
|
3980
|
+
Country2["SS"] = "SOUTH SUDAN";
|
|
3981
|
+
Country2["ES"] = "SPAIN";
|
|
3982
|
+
Country2["LK"] = "SRI LANKA";
|
|
3983
|
+
Country2["SD"] = "SUDAN";
|
|
3984
|
+
Country2["SR"] = "SURINAME";
|
|
3985
|
+
Country2["SJ"] = "SVALBARD AND JAN MAYEN";
|
|
3986
|
+
Country2["SZ"] = "SWAZILAND";
|
|
3987
|
+
Country2["SE"] = "SWEDEN";
|
|
3988
|
+
Country2["CH"] = "SWITZERLAND";
|
|
3989
|
+
Country2["SY"] = "SYRIAN ARAB REPUBLIC";
|
|
3990
|
+
Country2["TW"] = "TAIWAN, PROVINCE OF CHINA";
|
|
3991
|
+
Country2["TJ"] = "TAJIKISTAN";
|
|
3992
|
+
Country2["TZ"] = "TANZANIA, UNITED REPUBLIC OF";
|
|
3993
|
+
Country2["TH"] = "THAILAND";
|
|
3994
|
+
Country2["TL"] = "TIMOR-LESTE";
|
|
3995
|
+
Country2["TG"] = "TOGO";
|
|
3996
|
+
Country2["TK"] = "TOKELAU";
|
|
3997
|
+
Country2["TO"] = "TONGA";
|
|
3998
|
+
Country2["TT"] = "TRINIDAD AND TOBAGO";
|
|
3999
|
+
Country2["TN"] = "TUNISIA";
|
|
4000
|
+
Country2["TR"] = "TURKEY";
|
|
4001
|
+
Country2["TM"] = "TURKMENISTAN";
|
|
4002
|
+
Country2["TC"] = "TURKS AND CAICOS ISLANDS";
|
|
4003
|
+
Country2["TV"] = "TUVALU";
|
|
4004
|
+
Country2["UG"] = "UGANDA";
|
|
4005
|
+
Country2["UA"] = "UKRAINE";
|
|
4006
|
+
Country2["AE"] = "UNITED ARAB EMIRATES";
|
|
4007
|
+
Country2["GB"] = "UNITED KINGDOM";
|
|
4008
|
+
Country2["US"] = "UNITED STATES";
|
|
4009
|
+
Country2["UM"] = "UNITED STATES MINOR OUTLYING ISLANDS";
|
|
4010
|
+
Country2["UY"] = "URUGUAY";
|
|
4011
|
+
Country2["UZ"] = "UZBEKISTAN";
|
|
4012
|
+
Country2["VU"] = "VANUATU";
|
|
4013
|
+
Country2["VE"] = "VENEZUELA, BOLIVARIAN REPUBLIC OF";
|
|
4014
|
+
Country2["VN"] = "VIET NAM";
|
|
4015
|
+
Country2["VG"] = "VIRGIN ISLANDS, BRITISH";
|
|
4016
|
+
Country2["VI"] = "VIRGIN ISLANDS, U.S.";
|
|
4017
|
+
Country2["WF"] = "WALLIS AND FUTUNA";
|
|
4018
|
+
Country2["EH"] = "WESTERN SAHARA";
|
|
4019
|
+
Country2["YE"] = "YEMEN";
|
|
4020
|
+
Country2["ZM"] = "ZAMBIA";
|
|
4021
|
+
Country2["ZW"] = "ZIMBABWE";
|
|
4022
|
+
return Country2;
|
|
4023
|
+
})(Country || {});
|
|
4024
|
+
export {
|
|
4025
|
+
Country,
|
|
4026
|
+
EQUIPMENT_TYPES,
|
|
4027
|
+
GeoData,
|
|
4028
|
+
LineFlowColorMode,
|
|
4029
|
+
LineFlowMode,
|
|
4030
|
+
LineLayer,
|
|
4031
|
+
MapEquipments,
|
|
4032
|
+
SubstationLayer,
|
|
4033
|
+
getNominalVoltageColor
|
|
4034
|
+
};
|