@powsybl/network-map-layers 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +3 -11
- package/dist/index.d.ts +3 -11
- package/dist/powsybl-network-map-layers.cjs +369 -2192
- package/dist/powsybl-network-map-layers.js +364 -2187
- package/package.json +15 -9
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const CheapRuler = require("cheap-ruler");
|
|
4
|
+
const geolib = require("geolib");
|
|
5
|
+
const constants = require("@luma.gl/constants");
|
|
4
6
|
const engine = require("@luma.gl/engine");
|
|
5
7
|
const core = require("@deck.gl/core");
|
|
6
8
|
const extensions = require("@deck.gl/extensions");
|
|
@@ -27,1901 +29,7 @@ var EQUIPMENT_TYPES = /* @__PURE__ */ ((EQUIPMENT_TYPES2) => {
|
|
|
27
29
|
})(EQUIPMENT_TYPES || {});
|
|
28
30
|
const isMapSubstation = (object) => "voltageLevels" in object;
|
|
29
31
|
const isMapLine = (object) => "id" in object && "voltageLevelId1" in object && "voltageLevelId2" in object;
|
|
30
|
-
const
|
|
31
|
-
kilometers: 1,
|
|
32
|
-
miles: 1e3 / 1609.344,
|
|
33
|
-
nauticalmiles: 1e3 / 1852,
|
|
34
|
-
meters: 1e3,
|
|
35
|
-
metres: 1e3,
|
|
36
|
-
yards: 1e3 / 0.9144,
|
|
37
|
-
feet: 1e3 / 0.3048,
|
|
38
|
-
inches: 1e3 / 0.0254
|
|
39
|
-
};
|
|
40
|
-
const RE = 6378.137;
|
|
41
|
-
const FE = 1 / 298.257223563;
|
|
42
|
-
const E2 = FE * (2 - FE);
|
|
43
|
-
const RAD = Math.PI / 180;
|
|
44
|
-
class CheapRuler {
|
|
45
|
-
/**
|
|
46
|
-
* Creates a ruler object from tile coordinates (y and z).
|
|
47
|
-
*
|
|
48
|
-
* @param {number} y
|
|
49
|
-
* @param {number} z
|
|
50
|
-
* @param {keyof typeof factors} [units='kilometers']
|
|
51
|
-
* @returns {CheapRuler}
|
|
52
|
-
* @example
|
|
53
|
-
* const ruler = cheapRuler.fromTile(1567, 12);
|
|
54
|
-
* //=ruler
|
|
55
|
-
*/
|
|
56
|
-
static fromTile(y, z, units) {
|
|
57
|
-
const n = Math.PI * (1 - 2 * (y + 0.5) / Math.pow(2, z));
|
|
58
|
-
const lat = Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) / RAD;
|
|
59
|
-
return new CheapRuler(lat, units);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Multipliers for converting between units.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* // convert 50 meters to yards
|
|
66
|
-
* 50 * CheapRuler.units.yards / CheapRuler.units.meters;
|
|
67
|
-
*/
|
|
68
|
-
static get units() {
|
|
69
|
-
return factors;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
|
|
73
|
-
*
|
|
74
|
-
* @param {number} lat latitude
|
|
75
|
-
* @param {keyof typeof factors} [units='kilometers']
|
|
76
|
-
* @example
|
|
77
|
-
* const ruler = cheapRuler(35.05, 'miles');
|
|
78
|
-
* //=ruler
|
|
79
|
-
*/
|
|
80
|
-
constructor(lat, units) {
|
|
81
|
-
if (lat === void 0) throw new Error("No latitude given.");
|
|
82
|
-
if (units && !factors[units]) throw new Error(`Unknown unit ${units}. Use one of: ${Object.keys(factors).join(", ")}`);
|
|
83
|
-
const m = RAD * RE * (units ? factors[units] : 1);
|
|
84
|
-
const coslat = Math.cos(lat * RAD);
|
|
85
|
-
const w2 = 1 / (1 - E2 * (1 - coslat * coslat));
|
|
86
|
-
const w = Math.sqrt(w2);
|
|
87
|
-
this.kx = m * w * coslat;
|
|
88
|
-
this.ky = m * w * w2 * (1 - E2);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Given two points of the form [longitude, latitude], returns the distance.
|
|
92
|
-
*
|
|
93
|
-
* @param {[number, number]} a point [longitude, latitude]
|
|
94
|
-
* @param {[number, number]} b point [longitude, latitude]
|
|
95
|
-
* @returns {number} distance
|
|
96
|
-
* @example
|
|
97
|
-
* const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
|
|
98
|
-
* //=distance
|
|
99
|
-
*/
|
|
100
|
-
distance(a, b) {
|
|
101
|
-
const dx = wrap(a[0] - b[0]) * this.kx;
|
|
102
|
-
const dy = (a[1] - b[1]) * this.ky;
|
|
103
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns the bearing between two points in angles.
|
|
107
|
-
*
|
|
108
|
-
* @param {[number, number]} a point [longitude, latitude]
|
|
109
|
-
* @param {[number, number]} b point [longitude, latitude]
|
|
110
|
-
* @returns {number} bearing
|
|
111
|
-
* @example
|
|
112
|
-
* const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
|
|
113
|
-
* //=bearing
|
|
114
|
-
*/
|
|
115
|
-
bearing(a, b) {
|
|
116
|
-
const dx = wrap(b[0] - a[0]) * this.kx;
|
|
117
|
-
const dy = (b[1] - a[1]) * this.ky;
|
|
118
|
-
return Math.atan2(dx, dy) / RAD;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns a new point given distance and bearing from the starting point.
|
|
122
|
-
*
|
|
123
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
124
|
-
* @param {number} dist distance
|
|
125
|
-
* @param {number} bearing
|
|
126
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
127
|
-
* @example
|
|
128
|
-
* const point = ruler.destination([30.5, 50.5], 0.1, 90);
|
|
129
|
-
* //=point
|
|
130
|
-
*/
|
|
131
|
-
destination(p, dist, bearing) {
|
|
132
|
-
const a = bearing * RAD;
|
|
133
|
-
return this.offset(
|
|
134
|
-
p,
|
|
135
|
-
Math.sin(a) * dist,
|
|
136
|
-
Math.cos(a) * dist
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Returns a new point given easting and northing offsets (in ruler units) from the starting point.
|
|
141
|
-
*
|
|
142
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
143
|
-
* @param {number} dx easting
|
|
144
|
-
* @param {number} dy northing
|
|
145
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
146
|
-
* @example
|
|
147
|
-
* const point = ruler.offset([30.5, 50.5], 10, 10);
|
|
148
|
-
* //=point
|
|
149
|
-
*/
|
|
150
|
-
offset(p, dx, dy) {
|
|
151
|
-
return [
|
|
152
|
-
p[0] + dx / this.kx,
|
|
153
|
-
p[1] + dy / this.ky
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Given a line (an array of points), returns the total line distance.
|
|
158
|
-
*
|
|
159
|
-
* @param {[number, number][]} points [longitude, latitude]
|
|
160
|
-
* @returns {number} total line distance
|
|
161
|
-
* @example
|
|
162
|
-
* const length = ruler.lineDistance([
|
|
163
|
-
* [-67.031, 50.458], [-67.031, 50.534],
|
|
164
|
-
* [-66.929, 50.534], [-66.929, 50.458]
|
|
165
|
-
* ]);
|
|
166
|
-
* //=length
|
|
167
|
-
*/
|
|
168
|
-
lineDistance(points) {
|
|
169
|
-
let total = 0;
|
|
170
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
171
|
-
total += this.distance(points[i], points[i + 1]);
|
|
172
|
-
}
|
|
173
|
-
return total;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Given a polygon (an array of rings, where each ring is an array of points), returns the area.
|
|
177
|
-
*
|
|
178
|
-
* @param {[number, number][][]} polygon
|
|
179
|
-
* @returns {number} area value in the specified units (square kilometers by default)
|
|
180
|
-
* @example
|
|
181
|
-
* const area = ruler.area([[
|
|
182
|
-
* [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
|
|
183
|
-
* [-66.929, 50.458], [-67.031, 50.458]
|
|
184
|
-
* ]]);
|
|
185
|
-
* //=area
|
|
186
|
-
*/
|
|
187
|
-
area(polygon) {
|
|
188
|
-
let sum = 0;
|
|
189
|
-
for (let i = 0; i < polygon.length; i++) {
|
|
190
|
-
const ring = polygon[i];
|
|
191
|
-
for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
|
|
192
|
-
sum += wrap(ring[j][0] - ring[k][0]) * (ring[j][1] + ring[k][1]) * (i ? -1 : 1);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return Math.abs(sum) / 2 * this.kx * this.ky;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Returns the point at a specified distance along the line.
|
|
199
|
-
*
|
|
200
|
-
* @param {[number, number][]} line
|
|
201
|
-
* @param {number} dist distance
|
|
202
|
-
* @returns {[number, number]} point [longitude, latitude]
|
|
203
|
-
* @example
|
|
204
|
-
* const point = ruler.along(line, 2.5);
|
|
205
|
-
* //=point
|
|
206
|
-
*/
|
|
207
|
-
along(line, dist) {
|
|
208
|
-
let sum = 0;
|
|
209
|
-
if (dist <= 0) return line[0];
|
|
210
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
211
|
-
const p0 = line[i];
|
|
212
|
-
const p1 = line[i + 1];
|
|
213
|
-
const d = this.distance(p0, p1);
|
|
214
|
-
sum += d;
|
|
215
|
-
if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
|
|
216
|
-
}
|
|
217
|
-
return line[line.length - 1];
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Returns the distance from a point `p` to a line segment `a` to `b`.
|
|
221
|
-
*
|
|
222
|
-
* @pointToSegmentDistance
|
|
223
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
224
|
-
* @param {[number, number]} a segment point 1 [longitude, latitude]
|
|
225
|
-
* @param {[number, number]} b segment point 2 [longitude, latitude]
|
|
226
|
-
* @returns {number} distance
|
|
227
|
-
* @example
|
|
228
|
-
* const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
|
|
229
|
-
* //=distance
|
|
230
|
-
*/
|
|
231
|
-
pointToSegmentDistance(p, a, b) {
|
|
232
|
-
let [x, y] = a;
|
|
233
|
-
let dx = wrap(b[0] - x) * this.kx;
|
|
234
|
-
let dy = (b[1] - y) * this.ky;
|
|
235
|
-
if (dx !== 0 || dy !== 0) {
|
|
236
|
-
const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
237
|
-
if (t > 1) {
|
|
238
|
-
x = b[0];
|
|
239
|
-
y = b[1];
|
|
240
|
-
} else if (t > 0) {
|
|
241
|
-
x += dx / this.kx * t;
|
|
242
|
-
y += dy / this.ky * t;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
dx = wrap(p[0] - x) * this.kx;
|
|
246
|
-
dy = (p[1] - y) * this.ky;
|
|
247
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Returns an object of the form {point, index, t}, where point is closest point on the line
|
|
251
|
-
* from the given point, index is the start index of the segment with the closest point,
|
|
252
|
-
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
|
|
253
|
-
*
|
|
254
|
-
* @param {[number, number][]} line
|
|
255
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
256
|
-
* @returns {{point: [number, number], index: number, t: number}} {point, index, t}
|
|
257
|
-
* @example
|
|
258
|
-
* const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
|
|
259
|
-
* //=point
|
|
260
|
-
*/
|
|
261
|
-
pointOnLine(line, p) {
|
|
262
|
-
let minDist = Infinity;
|
|
263
|
-
let minX = line[0][0];
|
|
264
|
-
let minY = line[0][1];
|
|
265
|
-
let minI = 0;
|
|
266
|
-
let minT = 0;
|
|
267
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
268
|
-
let x = line[i][0];
|
|
269
|
-
let y = line[i][1];
|
|
270
|
-
let dx = wrap(line[i + 1][0] - x) * this.kx;
|
|
271
|
-
let dy = (line[i + 1][1] - y) * this.ky;
|
|
272
|
-
let t = 0;
|
|
273
|
-
if (dx !== 0 || dy !== 0) {
|
|
274
|
-
t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
275
|
-
if (t > 1) {
|
|
276
|
-
x = line[i + 1][0];
|
|
277
|
-
y = line[i + 1][1];
|
|
278
|
-
} else if (t > 0) {
|
|
279
|
-
x += dx / this.kx * t;
|
|
280
|
-
y += dy / this.ky * t;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
dx = wrap(p[0] - x) * this.kx;
|
|
284
|
-
dy = (p[1] - y) * this.ky;
|
|
285
|
-
const sqDist = dx * dx + dy * dy;
|
|
286
|
-
if (sqDist < minDist) {
|
|
287
|
-
minDist = sqDist;
|
|
288
|
-
minX = x;
|
|
289
|
-
minY = y;
|
|
290
|
-
minI = i;
|
|
291
|
-
minT = t;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return {
|
|
295
|
-
point: [minX, minY],
|
|
296
|
-
index: minI,
|
|
297
|
-
t: Math.max(0, Math.min(1, minT))
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Returns a part of the given line between the start and the stop points (or their closest points on the line).
|
|
302
|
-
*
|
|
303
|
-
* @param {[number, number]} start point [longitude, latitude]
|
|
304
|
-
* @param {[number, number]} stop point [longitude, latitude]
|
|
305
|
-
* @param {[number, number][]} line
|
|
306
|
-
* @returns {[number, number][]} line part of a line
|
|
307
|
-
* @example
|
|
308
|
-
* const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
|
|
309
|
-
* //=line2
|
|
310
|
-
*/
|
|
311
|
-
lineSlice(start, stop, line) {
|
|
312
|
-
let p1 = this.pointOnLine(line, start);
|
|
313
|
-
let p2 = this.pointOnLine(line, stop);
|
|
314
|
-
if (p1.index > p2.index || p1.index === p2.index && p1.t > p2.t) {
|
|
315
|
-
const tmp = p1;
|
|
316
|
-
p1 = p2;
|
|
317
|
-
p2 = tmp;
|
|
318
|
-
}
|
|
319
|
-
const slice = [p1.point];
|
|
320
|
-
const l = p1.index + 1;
|
|
321
|
-
const r = p2.index;
|
|
322
|
-
if (!equals(line[l], slice[0]) && l <= r)
|
|
323
|
-
slice.push(line[l]);
|
|
324
|
-
for (let i = l + 1; i <= r; i++) {
|
|
325
|
-
slice.push(line[i]);
|
|
326
|
-
}
|
|
327
|
-
if (!equals(line[r], p2.point))
|
|
328
|
-
slice.push(p2.point);
|
|
329
|
-
return slice;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
|
|
333
|
-
*
|
|
334
|
-
* @param {number} start start distance
|
|
335
|
-
* @param {number} stop stop distance
|
|
336
|
-
* @param {[number, number][]} line
|
|
337
|
-
* @returns {[number, number][]} part of a line
|
|
338
|
-
* @example
|
|
339
|
-
* const line2 = ruler.lineSliceAlong(10, 20, line1);
|
|
340
|
-
* //=line2
|
|
341
|
-
*/
|
|
342
|
-
lineSliceAlong(start, stop, line) {
|
|
343
|
-
let sum = 0;
|
|
344
|
-
const slice = [];
|
|
345
|
-
for (let i = 0; i < line.length - 1; i++) {
|
|
346
|
-
const p0 = line[i];
|
|
347
|
-
const p1 = line[i + 1];
|
|
348
|
-
const d = this.distance(p0, p1);
|
|
349
|
-
sum += d;
|
|
350
|
-
if (sum > start && slice.length === 0) {
|
|
351
|
-
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
|
|
352
|
-
}
|
|
353
|
-
if (sum >= stop) {
|
|
354
|
-
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
|
|
355
|
-
return slice;
|
|
356
|
-
}
|
|
357
|
-
if (sum > start) slice.push(p1);
|
|
358
|
-
}
|
|
359
|
-
return slice;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
|
|
363
|
-
*
|
|
364
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
365
|
-
* @param {number} buffer
|
|
366
|
-
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
367
|
-
* @example
|
|
368
|
-
* const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
|
|
369
|
-
* //=bbox
|
|
370
|
-
*/
|
|
371
|
-
bufferPoint(p, buffer) {
|
|
372
|
-
const v = buffer / this.ky;
|
|
373
|
-
const h = buffer / this.kx;
|
|
374
|
-
return [
|
|
375
|
-
p[0] - h,
|
|
376
|
-
p[1] - v,
|
|
377
|
-
p[0] + h,
|
|
378
|
-
p[1] + v
|
|
379
|
-
];
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Given a bounding box, returns the box buffered by a given distance.
|
|
383
|
-
*
|
|
384
|
-
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
385
|
-
* @param {number} buffer
|
|
386
|
-
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
387
|
-
* @example
|
|
388
|
-
* const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
|
|
389
|
-
* //=bbox
|
|
390
|
-
*/
|
|
391
|
-
bufferBBox(bbox, buffer) {
|
|
392
|
-
const v = buffer / this.ky;
|
|
393
|
-
const h = buffer / this.kx;
|
|
394
|
-
return [
|
|
395
|
-
bbox[0] - h,
|
|
396
|
-
bbox[1] - v,
|
|
397
|
-
bbox[2] + h,
|
|
398
|
-
bbox[3] + v
|
|
399
|
-
];
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Returns true if the given point is inside in the given bounding box, otherwise false.
|
|
403
|
-
*
|
|
404
|
-
* @param {[number, number]} p point [longitude, latitude]
|
|
405
|
-
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
406
|
-
* @returns {boolean}
|
|
407
|
-
* @example
|
|
408
|
-
* const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
|
|
409
|
-
* //=inside
|
|
410
|
-
*/
|
|
411
|
-
insideBBox(p, bbox) {
|
|
412
|
-
return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
function equals(a, b) {
|
|
416
|
-
return a[0] === b[0] && a[1] === b[1];
|
|
417
|
-
}
|
|
418
|
-
function interpolate(a, b, t) {
|
|
419
|
-
const dx = wrap(b[0] - a[0]);
|
|
420
|
-
const dy = b[1] - a[1];
|
|
421
|
-
return [
|
|
422
|
-
a[0] + dx * t,
|
|
423
|
-
a[1] + dy * t
|
|
424
|
-
];
|
|
425
|
-
}
|
|
426
|
-
function wrap(deg) {
|
|
427
|
-
while (deg < -180) deg += 360;
|
|
428
|
-
while (deg > 180) deg -= 360;
|
|
429
|
-
return deg;
|
|
430
|
-
}
|
|
431
|
-
var es = {};
|
|
432
|
-
var computeDestinationPoint = {};
|
|
433
|
-
var getLatitude = {};
|
|
434
|
-
var constants = {};
|
|
435
|
-
var hasRequiredConstants;
|
|
436
|
-
function requireConstants() {
|
|
437
|
-
if (hasRequiredConstants) return constants;
|
|
438
|
-
hasRequiredConstants = 1;
|
|
439
|
-
Object.defineProperty(constants, "__esModule", { value: true });
|
|
440
|
-
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;
|
|
441
|
-
var sexagesimalPattern = /^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}(\.([0-9]{1,}))?)["″]\s*)?([NEOSW]?)$/;
|
|
442
|
-
constants.sexagesimalPattern = sexagesimalPattern;
|
|
443
|
-
var earthRadius = 6378137;
|
|
444
|
-
constants.earthRadius = earthRadius;
|
|
445
|
-
var MINLAT = -90;
|
|
446
|
-
constants.MINLAT = MINLAT;
|
|
447
|
-
var MAXLAT = 90;
|
|
448
|
-
constants.MAXLAT = MAXLAT;
|
|
449
|
-
var MINLON = -180;
|
|
450
|
-
constants.MINLON = MINLON;
|
|
451
|
-
var MAXLON = 180;
|
|
452
|
-
constants.MAXLON = MAXLON;
|
|
453
|
-
var longitudeKeys = ["lng", "lon", "longitude", 0];
|
|
454
|
-
constants.longitudeKeys = longitudeKeys;
|
|
455
|
-
var latitudeKeys = ["lat", "latitude", 1];
|
|
456
|
-
constants.latitudeKeys = latitudeKeys;
|
|
457
|
-
var altitudeKeys = ["alt", "altitude", "elevation", "elev", 2];
|
|
458
|
-
constants.altitudeKeys = altitudeKeys;
|
|
459
|
-
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 };
|
|
460
|
-
constants.distanceConversion = distanceConversion;
|
|
461
|
-
var timeConversion = { m: 60, h: 3600, d: 86400 };
|
|
462
|
-
constants.timeConversion = timeConversion;
|
|
463
|
-
var areaConversion = { m2: 1, km2: 1e-6, ha: 1e-4, a: 0.01, ft2: 10.763911, yd2: 1.19599, in2: 1550.0031 };
|
|
464
|
-
constants.areaConversion = areaConversion;
|
|
465
|
-
areaConversion.sqm = areaConversion.m2;
|
|
466
|
-
areaConversion.sqkm = areaConversion.km2;
|
|
467
|
-
areaConversion.sqft = areaConversion.ft2;
|
|
468
|
-
areaConversion.sqyd = areaConversion.yd2;
|
|
469
|
-
areaConversion.sqin = areaConversion.in2;
|
|
470
|
-
return constants;
|
|
471
|
-
}
|
|
472
|
-
var getCoordinateKey = {};
|
|
473
|
-
var hasRequiredGetCoordinateKey;
|
|
474
|
-
function requireGetCoordinateKey() {
|
|
475
|
-
if (hasRequiredGetCoordinateKey) return getCoordinateKey;
|
|
476
|
-
hasRequiredGetCoordinateKey = 1;
|
|
477
|
-
Object.defineProperty(getCoordinateKey, "__esModule", { value: true });
|
|
478
|
-
getCoordinateKey.default = void 0;
|
|
479
|
-
var getCoordinateKey$1 = function getCoordinateKey2(point, keysToLookup) {
|
|
480
|
-
return keysToLookup.reduce(function(foundKey, key) {
|
|
481
|
-
if (typeof point === "undefined" || point === null) {
|
|
482
|
-
throw new Error("'".concat(point, "' is no valid coordinate."));
|
|
483
|
-
}
|
|
484
|
-
if (Object.prototype.hasOwnProperty.call(point, key) && typeof key !== "undefined" && typeof foundKey === "undefined") {
|
|
485
|
-
foundKey = key;
|
|
486
|
-
return key;
|
|
487
|
-
}
|
|
488
|
-
return foundKey;
|
|
489
|
-
}, void 0);
|
|
490
|
-
};
|
|
491
|
-
var _default = getCoordinateKey$1;
|
|
492
|
-
getCoordinateKey.default = _default;
|
|
493
|
-
return getCoordinateKey;
|
|
494
|
-
}
|
|
495
|
-
var toDecimal = {};
|
|
496
|
-
var isDecimal = {};
|
|
497
|
-
var hasRequiredIsDecimal;
|
|
498
|
-
function requireIsDecimal() {
|
|
499
|
-
if (hasRequiredIsDecimal) return isDecimal;
|
|
500
|
-
hasRequiredIsDecimal = 1;
|
|
501
|
-
Object.defineProperty(isDecimal, "__esModule", { value: true });
|
|
502
|
-
isDecimal.default = void 0;
|
|
503
|
-
var isDecimal$1 = function isDecimal2(value) {
|
|
504
|
-
var checkedValue = value.toString().trim();
|
|
505
|
-
if (isNaN(parseFloat(checkedValue))) {
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
return parseFloat(checkedValue) === Number(checkedValue);
|
|
509
|
-
};
|
|
510
|
-
var _default = isDecimal$1;
|
|
511
|
-
isDecimal.default = _default;
|
|
512
|
-
return isDecimal;
|
|
513
|
-
}
|
|
514
|
-
var isSexagesimal = {};
|
|
515
|
-
var hasRequiredIsSexagesimal;
|
|
516
|
-
function requireIsSexagesimal() {
|
|
517
|
-
if (hasRequiredIsSexagesimal) return isSexagesimal;
|
|
518
|
-
hasRequiredIsSexagesimal = 1;
|
|
519
|
-
Object.defineProperty(isSexagesimal, "__esModule", { value: true });
|
|
520
|
-
isSexagesimal.default = void 0;
|
|
521
|
-
var _constants = requireConstants();
|
|
522
|
-
var isSexagesimal$1 = function isSexagesimal2(value) {
|
|
523
|
-
return _constants.sexagesimalPattern.test(value.toString().trim());
|
|
524
|
-
};
|
|
525
|
-
var _default = isSexagesimal$1;
|
|
526
|
-
isSexagesimal.default = _default;
|
|
527
|
-
return isSexagesimal;
|
|
528
|
-
}
|
|
529
|
-
var sexagesimalToDecimal = {};
|
|
530
|
-
var hasRequiredSexagesimalToDecimal;
|
|
531
|
-
function requireSexagesimalToDecimal() {
|
|
532
|
-
if (hasRequiredSexagesimalToDecimal) return sexagesimalToDecimal;
|
|
533
|
-
hasRequiredSexagesimalToDecimal = 1;
|
|
534
|
-
Object.defineProperty(sexagesimalToDecimal, "__esModule", { value: true });
|
|
535
|
-
sexagesimalToDecimal.default = void 0;
|
|
536
|
-
var _constants = requireConstants();
|
|
537
|
-
var sexagesimalToDecimal$1 = function sexagesimalToDecimal2(sexagesimal) {
|
|
538
|
-
var data = new RegExp(_constants.sexagesimalPattern).exec(sexagesimal.toString().trim());
|
|
539
|
-
if (typeof data === "undefined" || data === null) {
|
|
540
|
-
throw new Error("Given value is not in sexagesimal format");
|
|
541
|
-
}
|
|
542
|
-
var min = Number(data[2]) / 60 || 0;
|
|
543
|
-
var sec = Number(data[4]) / 3600 || 0;
|
|
544
|
-
var decimal = parseFloat(data[1]) + min + sec;
|
|
545
|
-
return ["S", "W"].includes(data[7]) ? -decimal : decimal;
|
|
546
|
-
};
|
|
547
|
-
var _default = sexagesimalToDecimal$1;
|
|
548
|
-
sexagesimalToDecimal.default = _default;
|
|
549
|
-
return sexagesimalToDecimal;
|
|
550
|
-
}
|
|
551
|
-
var isValidCoordinate = {};
|
|
552
|
-
var getCoordinateKeys = {};
|
|
553
|
-
var hasRequiredGetCoordinateKeys;
|
|
554
|
-
function requireGetCoordinateKeys() {
|
|
555
|
-
if (hasRequiredGetCoordinateKeys) return getCoordinateKeys;
|
|
556
|
-
hasRequiredGetCoordinateKeys = 1;
|
|
557
|
-
Object.defineProperty(getCoordinateKeys, "__esModule", { value: true });
|
|
558
|
-
getCoordinateKeys.default = void 0;
|
|
559
|
-
var _constants = requireConstants();
|
|
560
|
-
var _getCoordinateKey = _interopRequireDefault(requireGetCoordinateKey());
|
|
561
|
-
function _interopRequireDefault(obj) {
|
|
562
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
563
|
-
}
|
|
564
|
-
function ownKeys(object, enumerableOnly) {
|
|
565
|
-
var keys = Object.keys(object);
|
|
566
|
-
if (Object.getOwnPropertySymbols) {
|
|
567
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
568
|
-
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
569
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
570
|
-
});
|
|
571
|
-
keys.push.apply(keys, symbols);
|
|
572
|
-
}
|
|
573
|
-
return keys;
|
|
574
|
-
}
|
|
575
|
-
function _objectSpread(target) {
|
|
576
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
577
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
578
|
-
if (i % 2) {
|
|
579
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
580
|
-
_defineProperty(target, key, source[key]);
|
|
581
|
-
});
|
|
582
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
583
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
584
|
-
} else {
|
|
585
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
586
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
return target;
|
|
591
|
-
}
|
|
592
|
-
function _defineProperty(obj, key, value) {
|
|
593
|
-
if (key in obj) {
|
|
594
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
595
|
-
} else {
|
|
596
|
-
obj[key] = value;
|
|
597
|
-
}
|
|
598
|
-
return obj;
|
|
599
|
-
}
|
|
600
|
-
var getCoordinateKeys$1 = function getCoordinateKeys2(point) {
|
|
601
|
-
var keysToLookup = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { longitude: _constants.longitudeKeys, latitude: _constants.latitudeKeys, altitude: _constants.altitudeKeys };
|
|
602
|
-
var longitude = (0, _getCoordinateKey.default)(point, keysToLookup.longitude);
|
|
603
|
-
var latitude = (0, _getCoordinateKey.default)(point, keysToLookup.latitude);
|
|
604
|
-
var altitude = (0, _getCoordinateKey.default)(point, keysToLookup.altitude);
|
|
605
|
-
return _objectSpread({ latitude, longitude }, altitude ? { altitude } : {});
|
|
606
|
-
};
|
|
607
|
-
var _default = getCoordinateKeys$1;
|
|
608
|
-
getCoordinateKeys.default = _default;
|
|
609
|
-
return getCoordinateKeys;
|
|
610
|
-
}
|
|
611
|
-
var isValidLatitude = {};
|
|
612
|
-
var hasRequiredIsValidLatitude;
|
|
613
|
-
function requireIsValidLatitude() {
|
|
614
|
-
if (hasRequiredIsValidLatitude) return isValidLatitude;
|
|
615
|
-
hasRequiredIsValidLatitude = 1;
|
|
616
|
-
Object.defineProperty(isValidLatitude, "__esModule", { value: true });
|
|
617
|
-
isValidLatitude.default = void 0;
|
|
618
|
-
var _isDecimal = _interopRequireDefault(requireIsDecimal());
|
|
619
|
-
var _isSexagesimal = _interopRequireDefault(requireIsSexagesimal());
|
|
620
|
-
var _sexagesimalToDecimal = _interopRequireDefault(requireSexagesimalToDecimal());
|
|
621
|
-
var _constants = requireConstants();
|
|
622
|
-
function _interopRequireDefault(obj) {
|
|
623
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
624
|
-
}
|
|
625
|
-
var isValidLatitude$1 = function isValidLatitude2(value) {
|
|
626
|
-
if ((0, _isDecimal.default)(value)) {
|
|
627
|
-
if (parseFloat(value) > _constants.MAXLAT || value < _constants.MINLAT) {
|
|
628
|
-
return false;
|
|
629
|
-
}
|
|
630
|
-
return true;
|
|
631
|
-
}
|
|
632
|
-
if ((0, _isSexagesimal.default)(value)) {
|
|
633
|
-
return isValidLatitude2((0, _sexagesimalToDecimal.default)(value));
|
|
634
|
-
}
|
|
635
|
-
return false;
|
|
636
|
-
};
|
|
637
|
-
var _default = isValidLatitude$1;
|
|
638
|
-
isValidLatitude.default = _default;
|
|
639
|
-
return isValidLatitude;
|
|
640
|
-
}
|
|
641
|
-
var isValidLongitude = {};
|
|
642
|
-
var hasRequiredIsValidLongitude;
|
|
643
|
-
function requireIsValidLongitude() {
|
|
644
|
-
if (hasRequiredIsValidLongitude) return isValidLongitude;
|
|
645
|
-
hasRequiredIsValidLongitude = 1;
|
|
646
|
-
Object.defineProperty(isValidLongitude, "__esModule", { value: true });
|
|
647
|
-
isValidLongitude.default = void 0;
|
|
648
|
-
var _isDecimal = _interopRequireDefault(requireIsDecimal());
|
|
649
|
-
var _isSexagesimal = _interopRequireDefault(requireIsSexagesimal());
|
|
650
|
-
var _sexagesimalToDecimal = _interopRequireDefault(requireSexagesimalToDecimal());
|
|
651
|
-
var _constants = requireConstants();
|
|
652
|
-
function _interopRequireDefault(obj) {
|
|
653
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
654
|
-
}
|
|
655
|
-
var isValidLongitude$1 = function isValidLongitude2(value) {
|
|
656
|
-
if ((0, _isDecimal.default)(value)) {
|
|
657
|
-
if (parseFloat(value) > _constants.MAXLON || value < _constants.MINLON) {
|
|
658
|
-
return false;
|
|
659
|
-
}
|
|
660
|
-
return true;
|
|
661
|
-
}
|
|
662
|
-
if ((0, _isSexagesimal.default)(value)) {
|
|
663
|
-
return isValidLongitude2((0, _sexagesimalToDecimal.default)(value));
|
|
664
|
-
}
|
|
665
|
-
return false;
|
|
666
|
-
};
|
|
667
|
-
var _default = isValidLongitude$1;
|
|
668
|
-
isValidLongitude.default = _default;
|
|
669
|
-
return isValidLongitude;
|
|
670
|
-
}
|
|
671
|
-
var hasRequiredIsValidCoordinate;
|
|
672
|
-
function requireIsValidCoordinate() {
|
|
673
|
-
if (hasRequiredIsValidCoordinate) return isValidCoordinate;
|
|
674
|
-
hasRequiredIsValidCoordinate = 1;
|
|
675
|
-
Object.defineProperty(isValidCoordinate, "__esModule", { value: true });
|
|
676
|
-
isValidCoordinate.default = void 0;
|
|
677
|
-
var _getCoordinateKeys2 = _interopRequireDefault(requireGetCoordinateKeys());
|
|
678
|
-
var _isValidLatitude = _interopRequireDefault(requireIsValidLatitude());
|
|
679
|
-
var _isValidLongitude = _interopRequireDefault(requireIsValidLongitude());
|
|
680
|
-
function _interopRequireDefault(obj) {
|
|
681
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
682
|
-
}
|
|
683
|
-
var isValidCoordinate$1 = function isValidCoordinate2(point) {
|
|
684
|
-
var _getCoordinateKeys = (0, _getCoordinateKeys2.default)(point), latitude = _getCoordinateKeys.latitude, longitude = _getCoordinateKeys.longitude;
|
|
685
|
-
if (Array.isArray(point) && point.length >= 2) {
|
|
686
|
-
return (0, _isValidLongitude.default)(point[0]) && (0, _isValidLatitude.default)(point[1]);
|
|
687
|
-
}
|
|
688
|
-
if (typeof latitude === "undefined" || typeof longitude === "undefined") {
|
|
689
|
-
return false;
|
|
690
|
-
}
|
|
691
|
-
var lon = point[longitude];
|
|
692
|
-
var lat = point[latitude];
|
|
693
|
-
if (typeof lat === "undefined" || typeof lon === "undefined") {
|
|
694
|
-
return false;
|
|
695
|
-
}
|
|
696
|
-
if ((0, _isValidLatitude.default)(lat) === false || (0, _isValidLongitude.default)(lon) === false) {
|
|
697
|
-
return false;
|
|
698
|
-
}
|
|
699
|
-
return true;
|
|
700
|
-
};
|
|
701
|
-
var _default = isValidCoordinate$1;
|
|
702
|
-
isValidCoordinate.default = _default;
|
|
703
|
-
return isValidCoordinate;
|
|
704
|
-
}
|
|
705
|
-
var hasRequiredToDecimal;
|
|
706
|
-
function requireToDecimal() {
|
|
707
|
-
if (hasRequiredToDecimal) return toDecimal;
|
|
708
|
-
hasRequiredToDecimal = 1;
|
|
709
|
-
Object.defineProperty(toDecimal, "__esModule", { value: true });
|
|
710
|
-
toDecimal.default = void 0;
|
|
711
|
-
var _isDecimal = _interopRequireDefault(requireIsDecimal());
|
|
712
|
-
var _isSexagesimal = _interopRequireDefault(requireIsSexagesimal());
|
|
713
|
-
var _sexagesimalToDecimal = _interopRequireDefault(requireSexagesimalToDecimal());
|
|
714
|
-
var _isValidCoordinate = _interopRequireDefault(requireIsValidCoordinate());
|
|
715
|
-
var _getCoordinateKeys = _interopRequireDefault(requireGetCoordinateKeys());
|
|
716
|
-
function _interopRequireDefault(obj) {
|
|
717
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
718
|
-
}
|
|
719
|
-
function ownKeys(object, enumerableOnly) {
|
|
720
|
-
var keys = Object.keys(object);
|
|
721
|
-
if (Object.getOwnPropertySymbols) {
|
|
722
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
723
|
-
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
724
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
725
|
-
});
|
|
726
|
-
keys.push.apply(keys, symbols);
|
|
727
|
-
}
|
|
728
|
-
return keys;
|
|
729
|
-
}
|
|
730
|
-
function _objectSpread(target) {
|
|
731
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
732
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
733
|
-
if (i % 2) {
|
|
734
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
735
|
-
_defineProperty(target, key, source[key]);
|
|
736
|
-
});
|
|
737
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
738
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
739
|
-
} else {
|
|
740
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
741
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
return target;
|
|
746
|
-
}
|
|
747
|
-
function _defineProperty(obj, key, value) {
|
|
748
|
-
if (key in obj) {
|
|
749
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
750
|
-
} else {
|
|
751
|
-
obj[key] = value;
|
|
752
|
-
}
|
|
753
|
-
return obj;
|
|
754
|
-
}
|
|
755
|
-
var toDecimal$1 = function toDecimal2(value) {
|
|
756
|
-
if ((0, _isDecimal.default)(value)) {
|
|
757
|
-
return Number(value);
|
|
758
|
-
}
|
|
759
|
-
if ((0, _isSexagesimal.default)(value)) {
|
|
760
|
-
return (0, _sexagesimalToDecimal.default)(value);
|
|
761
|
-
}
|
|
762
|
-
if ((0, _isValidCoordinate.default)(value)) {
|
|
763
|
-
var keys = (0, _getCoordinateKeys.default)(value);
|
|
764
|
-
if (Array.isArray(value)) {
|
|
765
|
-
return value.map(function(v, index) {
|
|
766
|
-
return [0, 1].includes(index) ? toDecimal2(v) : v;
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
return _objectSpread(_objectSpread(_objectSpread({}, value), keys.latitude && _defineProperty({}, keys.latitude, toDecimal2(value[keys.latitude]))), keys.longitude && _defineProperty({}, keys.longitude, toDecimal2(value[keys.longitude])));
|
|
770
|
-
}
|
|
771
|
-
if (Array.isArray(value)) {
|
|
772
|
-
return value.map(function(point) {
|
|
773
|
-
return (0, _isValidCoordinate.default)(point) ? toDecimal2(point) : point;
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
return value;
|
|
777
|
-
};
|
|
778
|
-
var _default = toDecimal$1;
|
|
779
|
-
toDecimal.default = _default;
|
|
780
|
-
return toDecimal;
|
|
781
|
-
}
|
|
782
|
-
var hasRequiredGetLatitude;
|
|
783
|
-
function requireGetLatitude() {
|
|
784
|
-
if (hasRequiredGetLatitude) return getLatitude;
|
|
785
|
-
hasRequiredGetLatitude = 1;
|
|
786
|
-
Object.defineProperty(getLatitude, "__esModule", { value: true });
|
|
787
|
-
getLatitude.default = void 0;
|
|
788
|
-
var _constants = requireConstants();
|
|
789
|
-
var _getCoordinateKey = _interopRequireDefault(requireGetCoordinateKey());
|
|
790
|
-
var _toDecimal = _interopRequireDefault(requireToDecimal());
|
|
791
|
-
function _interopRequireDefault(obj) {
|
|
792
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
793
|
-
}
|
|
794
|
-
var getLatitude$1 = function getLatitude2(point, raw) {
|
|
795
|
-
var latKey = (0, _getCoordinateKey.default)(point, _constants.latitudeKeys);
|
|
796
|
-
if (typeof latKey === "undefined" || latKey === null) {
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
var value = point[latKey];
|
|
800
|
-
return raw === true ? value : (0, _toDecimal.default)(value);
|
|
801
|
-
};
|
|
802
|
-
var _default = getLatitude$1;
|
|
803
|
-
getLatitude.default = _default;
|
|
804
|
-
return getLatitude;
|
|
805
|
-
}
|
|
806
|
-
var getLongitude = {};
|
|
807
|
-
var hasRequiredGetLongitude;
|
|
808
|
-
function requireGetLongitude() {
|
|
809
|
-
if (hasRequiredGetLongitude) return getLongitude;
|
|
810
|
-
hasRequiredGetLongitude = 1;
|
|
811
|
-
Object.defineProperty(getLongitude, "__esModule", { value: true });
|
|
812
|
-
getLongitude.default = void 0;
|
|
813
|
-
var _constants = requireConstants();
|
|
814
|
-
var _getCoordinateKey = _interopRequireDefault(requireGetCoordinateKey());
|
|
815
|
-
var _toDecimal = _interopRequireDefault(requireToDecimal());
|
|
816
|
-
function _interopRequireDefault(obj) {
|
|
817
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
818
|
-
}
|
|
819
|
-
var getLongitude$1 = function getLongitude2(point, raw) {
|
|
820
|
-
var latKey = (0, _getCoordinateKey.default)(point, _constants.longitudeKeys);
|
|
821
|
-
if (typeof latKey === "undefined" || latKey === null) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
var value = point[latKey];
|
|
825
|
-
return raw === true ? value : (0, _toDecimal.default)(value);
|
|
826
|
-
};
|
|
827
|
-
var _default = getLongitude$1;
|
|
828
|
-
getLongitude.default = _default;
|
|
829
|
-
return getLongitude;
|
|
830
|
-
}
|
|
831
|
-
var toRad = {};
|
|
832
|
-
var hasRequiredToRad;
|
|
833
|
-
function requireToRad() {
|
|
834
|
-
if (hasRequiredToRad) return toRad;
|
|
835
|
-
hasRequiredToRad = 1;
|
|
836
|
-
Object.defineProperty(toRad, "__esModule", { value: true });
|
|
837
|
-
toRad.default = void 0;
|
|
838
|
-
var toRad$1 = function toRad2(value) {
|
|
839
|
-
return value * Math.PI / 180;
|
|
840
|
-
};
|
|
841
|
-
var _default = toRad$1;
|
|
842
|
-
toRad.default = _default;
|
|
843
|
-
return toRad;
|
|
844
|
-
}
|
|
845
|
-
var toDeg = {};
|
|
846
|
-
var hasRequiredToDeg;
|
|
847
|
-
function requireToDeg() {
|
|
848
|
-
if (hasRequiredToDeg) return toDeg;
|
|
849
|
-
hasRequiredToDeg = 1;
|
|
850
|
-
Object.defineProperty(toDeg, "__esModule", { value: true });
|
|
851
|
-
toDeg.default = void 0;
|
|
852
|
-
var toDeg$1 = function toDeg2(value) {
|
|
853
|
-
return value * 180 / Math.PI;
|
|
854
|
-
};
|
|
855
|
-
var _default = toDeg$1;
|
|
856
|
-
toDeg.default = _default;
|
|
857
|
-
return toDeg;
|
|
858
|
-
}
|
|
859
|
-
var hasRequiredComputeDestinationPoint;
|
|
860
|
-
function requireComputeDestinationPoint() {
|
|
861
|
-
if (hasRequiredComputeDestinationPoint) return computeDestinationPoint;
|
|
862
|
-
hasRequiredComputeDestinationPoint = 1;
|
|
863
|
-
Object.defineProperty(computeDestinationPoint, "__esModule", { value: true });
|
|
864
|
-
computeDestinationPoint.default = void 0;
|
|
865
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
866
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
867
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
868
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
869
|
-
var _constants = requireConstants();
|
|
870
|
-
function _interopRequireDefault(obj) {
|
|
871
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
872
|
-
}
|
|
873
|
-
var computeDestinationPoint$1 = function computeDestinationPoint2(start, distance, bearing) {
|
|
874
|
-
var radius = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 6371e3;
|
|
875
|
-
var lat = (0, _getLatitude.default)(start);
|
|
876
|
-
var lng = (0, _getLongitude.default)(start);
|
|
877
|
-
var delta = distance / radius;
|
|
878
|
-
var theta = (0, _toRad.default)(bearing);
|
|
879
|
-
var phi1 = (0, _toRad.default)(lat);
|
|
880
|
-
var lambda1 = (0, _toRad.default)(lng);
|
|
881
|
-
var phi2 = Math.asin(Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta));
|
|
882
|
-
var lambda2 = lambda1 + Math.atan2(Math.sin(theta) * Math.sin(delta) * Math.cos(phi1), Math.cos(delta) - Math.sin(phi1) * Math.sin(phi2));
|
|
883
|
-
var longitude = (0, _toDeg.default)(lambda2);
|
|
884
|
-
if (longitude < _constants.MINLON || longitude > _constants.MAXLON) {
|
|
885
|
-
lambda2 = (lambda2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
|
|
886
|
-
longitude = (0, _toDeg.default)(lambda2);
|
|
887
|
-
}
|
|
888
|
-
return { latitude: (0, _toDeg.default)(phi2), longitude };
|
|
889
|
-
};
|
|
890
|
-
var _default = computeDestinationPoint$1;
|
|
891
|
-
computeDestinationPoint.default = _default;
|
|
892
|
-
return computeDestinationPoint;
|
|
893
|
-
}
|
|
894
|
-
var convertArea = {};
|
|
895
|
-
var hasRequiredConvertArea;
|
|
896
|
-
function requireConvertArea() {
|
|
897
|
-
if (hasRequiredConvertArea) return convertArea;
|
|
898
|
-
hasRequiredConvertArea = 1;
|
|
899
|
-
Object.defineProperty(convertArea, "__esModule", { value: true });
|
|
900
|
-
convertArea.default = void 0;
|
|
901
|
-
var _constants = requireConstants();
|
|
902
|
-
var convertArea$1 = function convertArea2(squareMeters) {
|
|
903
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
904
|
-
var factor = _constants.areaConversion[targetUnit];
|
|
905
|
-
if (factor) {
|
|
906
|
-
return squareMeters * factor;
|
|
907
|
-
}
|
|
908
|
-
throw new Error("Invalid unit used for area conversion.");
|
|
909
|
-
};
|
|
910
|
-
var _default = convertArea$1;
|
|
911
|
-
convertArea.default = _default;
|
|
912
|
-
return convertArea;
|
|
913
|
-
}
|
|
914
|
-
var convertDistance = {};
|
|
915
|
-
var hasRequiredConvertDistance;
|
|
916
|
-
function requireConvertDistance() {
|
|
917
|
-
if (hasRequiredConvertDistance) return convertDistance;
|
|
918
|
-
hasRequiredConvertDistance = 1;
|
|
919
|
-
Object.defineProperty(convertDistance, "__esModule", { value: true });
|
|
920
|
-
convertDistance.default = void 0;
|
|
921
|
-
var _constants = requireConstants();
|
|
922
|
-
var convertDistance$1 = function convertDistance2(meters) {
|
|
923
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "m";
|
|
924
|
-
var factor = _constants.distanceConversion[targetUnit];
|
|
925
|
-
if (factor) {
|
|
926
|
-
return meters * factor;
|
|
927
|
-
}
|
|
928
|
-
throw new Error("Invalid unit used for distance conversion.");
|
|
929
|
-
};
|
|
930
|
-
var _default = convertDistance$1;
|
|
931
|
-
convertDistance.default = _default;
|
|
932
|
-
return convertDistance;
|
|
933
|
-
}
|
|
934
|
-
var convertSpeed = {};
|
|
935
|
-
var hasRequiredConvertSpeed;
|
|
936
|
-
function requireConvertSpeed() {
|
|
937
|
-
if (hasRequiredConvertSpeed) return convertSpeed;
|
|
938
|
-
hasRequiredConvertSpeed = 1;
|
|
939
|
-
Object.defineProperty(convertSpeed, "__esModule", { value: true });
|
|
940
|
-
convertSpeed.default = void 0;
|
|
941
|
-
var _constants = requireConstants();
|
|
942
|
-
var convertSpeed$1 = function convertSpeed2(metersPerSecond) {
|
|
943
|
-
var targetUnit = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "kmh";
|
|
944
|
-
switch (targetUnit) {
|
|
945
|
-
case "kmh":
|
|
946
|
-
return metersPerSecond * _constants.timeConversion.h * _constants.distanceConversion.km;
|
|
947
|
-
case "mph":
|
|
948
|
-
return metersPerSecond * _constants.timeConversion.h * _constants.distanceConversion.mi;
|
|
949
|
-
default:
|
|
950
|
-
return metersPerSecond;
|
|
951
|
-
}
|
|
952
|
-
};
|
|
953
|
-
var _default = convertSpeed$1;
|
|
954
|
-
convertSpeed.default = _default;
|
|
955
|
-
return convertSpeed;
|
|
956
|
-
}
|
|
957
|
-
var decimalToSexagesimal = {};
|
|
958
|
-
var hasRequiredDecimalToSexagesimal;
|
|
959
|
-
function requireDecimalToSexagesimal() {
|
|
960
|
-
if (hasRequiredDecimalToSexagesimal) return decimalToSexagesimal;
|
|
961
|
-
hasRequiredDecimalToSexagesimal = 1;
|
|
962
|
-
Object.defineProperty(decimalToSexagesimal, "__esModule", { value: true });
|
|
963
|
-
decimalToSexagesimal.default = void 0;
|
|
964
|
-
function _slicedToArray(arr, i) {
|
|
965
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
966
|
-
}
|
|
967
|
-
function _nonIterableRest() {
|
|
968
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
969
|
-
}
|
|
970
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
971
|
-
if (!o) return;
|
|
972
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
973
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
974
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
975
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
976
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
977
|
-
}
|
|
978
|
-
function _arrayLikeToArray(arr, len) {
|
|
979
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
980
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
981
|
-
arr2[i] = arr[i];
|
|
982
|
-
}
|
|
983
|
-
return arr2;
|
|
984
|
-
}
|
|
985
|
-
function _iterableToArrayLimit(arr, i) {
|
|
986
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
987
|
-
var _arr = [];
|
|
988
|
-
var _n = true;
|
|
989
|
-
var _d = false;
|
|
990
|
-
var _e = void 0;
|
|
991
|
-
try {
|
|
992
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
993
|
-
_arr.push(_s.value);
|
|
994
|
-
if (i && _arr.length === i) break;
|
|
995
|
-
}
|
|
996
|
-
} catch (err) {
|
|
997
|
-
_d = true;
|
|
998
|
-
_e = err;
|
|
999
|
-
} finally {
|
|
1000
|
-
try {
|
|
1001
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1002
|
-
} finally {
|
|
1003
|
-
if (_d) throw _e;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
return _arr;
|
|
1007
|
-
}
|
|
1008
|
-
function _arrayWithHoles(arr) {
|
|
1009
|
-
if (Array.isArray(arr)) return arr;
|
|
1010
|
-
}
|
|
1011
|
-
var imprecise = function imprecise2(number) {
|
|
1012
|
-
var decimals = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
|
|
1013
|
-
var factor = Math.pow(10, decimals);
|
|
1014
|
-
return Math.round(number * factor) / factor;
|
|
1015
|
-
};
|
|
1016
|
-
var decimal2sexagesimalNext = function decimal2sexagesimalNext2(decimal) {
|
|
1017
|
-
var _decimal$toString$spl = decimal.toString().split("."), _decimal$toString$spl2 = _slicedToArray(_decimal$toString$spl, 2), pre = _decimal$toString$spl2[0], post = _decimal$toString$spl2[1];
|
|
1018
|
-
var deg = Math.abs(Number(pre));
|
|
1019
|
-
var min0 = Number("0." + (post || 0)) * 60;
|
|
1020
|
-
var sec0 = min0.toString().split(".");
|
|
1021
|
-
var min = Math.floor(min0);
|
|
1022
|
-
var sec = imprecise(Number("0." + (sec0[1] || 0)) * 60).toString();
|
|
1023
|
-
var _sec$split = sec.split("."), _sec$split2 = _slicedToArray(_sec$split, 2), secPreDec = _sec$split2[0], _sec$split2$ = _sec$split2[1], secDec = _sec$split2$ === void 0 ? "0" : _sec$split2$;
|
|
1024
|
-
return deg + "° " + min.toString().padStart(2, "0") + "' " + secPreDec.padStart(2, "0") + "." + secDec.padEnd(1, "0") + '"';
|
|
1025
|
-
};
|
|
1026
|
-
var _default = decimal2sexagesimalNext;
|
|
1027
|
-
decimalToSexagesimal.default = _default;
|
|
1028
|
-
return decimalToSexagesimal;
|
|
1029
|
-
}
|
|
1030
|
-
var findNearest = {};
|
|
1031
|
-
var orderByDistance = {};
|
|
1032
|
-
var getDistance = {};
|
|
1033
|
-
var robustAcos = {};
|
|
1034
|
-
var hasRequiredRobustAcos;
|
|
1035
|
-
function requireRobustAcos() {
|
|
1036
|
-
if (hasRequiredRobustAcos) return robustAcos;
|
|
1037
|
-
hasRequiredRobustAcos = 1;
|
|
1038
|
-
Object.defineProperty(robustAcos, "__esModule", { value: true });
|
|
1039
|
-
robustAcos.default = void 0;
|
|
1040
|
-
var robustAcos$1 = function robustAcos2(value) {
|
|
1041
|
-
if (value > 1) {
|
|
1042
|
-
return 1;
|
|
1043
|
-
}
|
|
1044
|
-
if (value < -1) {
|
|
1045
|
-
return -1;
|
|
1046
|
-
}
|
|
1047
|
-
return value;
|
|
1048
|
-
};
|
|
1049
|
-
var _default = robustAcos$1;
|
|
1050
|
-
robustAcos.default = _default;
|
|
1051
|
-
return robustAcos;
|
|
1052
|
-
}
|
|
1053
|
-
var hasRequiredGetDistance;
|
|
1054
|
-
function requireGetDistance() {
|
|
1055
|
-
if (hasRequiredGetDistance) return getDistance;
|
|
1056
|
-
hasRequiredGetDistance = 1;
|
|
1057
|
-
Object.defineProperty(getDistance, "__esModule", { value: true });
|
|
1058
|
-
getDistance.default = void 0;
|
|
1059
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1060
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1061
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1062
|
-
var _robustAcos = _interopRequireDefault(requireRobustAcos());
|
|
1063
|
-
var _constants = requireConstants();
|
|
1064
|
-
function _interopRequireDefault(obj) {
|
|
1065
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1066
|
-
}
|
|
1067
|
-
var getDistance$1 = function getDistance2(from, to) {
|
|
1068
|
-
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
1069
|
-
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
1070
|
-
var fromLat = (0, _getLatitude.default)(from);
|
|
1071
|
-
var fromLon = (0, _getLongitude.default)(from);
|
|
1072
|
-
var toLat = (0, _getLatitude.default)(to);
|
|
1073
|
-
var toLon = (0, _getLongitude.default)(to);
|
|
1074
|
-
var distance = Math.acos((0, _robustAcos.default)(Math.sin((0, _toRad.default)(toLat)) * Math.sin((0, _toRad.default)(fromLat)) + Math.cos((0, _toRad.default)(toLat)) * Math.cos((0, _toRad.default)(fromLat)) * Math.cos((0, _toRad.default)(fromLon) - (0, _toRad.default)(toLon)))) * _constants.earthRadius;
|
|
1075
|
-
return Math.round(distance / accuracy) * accuracy;
|
|
1076
|
-
};
|
|
1077
|
-
var _default = getDistance$1;
|
|
1078
|
-
getDistance.default = _default;
|
|
1079
|
-
return getDistance;
|
|
1080
|
-
}
|
|
1081
|
-
var hasRequiredOrderByDistance;
|
|
1082
|
-
function requireOrderByDistance() {
|
|
1083
|
-
if (hasRequiredOrderByDistance) return orderByDistance;
|
|
1084
|
-
hasRequiredOrderByDistance = 1;
|
|
1085
|
-
Object.defineProperty(orderByDistance, "__esModule", { value: true });
|
|
1086
|
-
orderByDistance.default = void 0;
|
|
1087
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1088
|
-
function _interopRequireDefault(obj) {
|
|
1089
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1090
|
-
}
|
|
1091
|
-
var orderByDistance$1 = function orderByDistance2(point, coords) {
|
|
1092
|
-
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance.default;
|
|
1093
|
-
distanceFn = typeof distanceFn === "function" ? distanceFn : _getDistance.default;
|
|
1094
|
-
return coords.slice().sort(function(a, b) {
|
|
1095
|
-
return distanceFn(point, a) - distanceFn(point, b);
|
|
1096
|
-
});
|
|
1097
|
-
};
|
|
1098
|
-
var _default = orderByDistance$1;
|
|
1099
|
-
orderByDistance.default = _default;
|
|
1100
|
-
return orderByDistance;
|
|
1101
|
-
}
|
|
1102
|
-
var hasRequiredFindNearest;
|
|
1103
|
-
function requireFindNearest() {
|
|
1104
|
-
if (hasRequiredFindNearest) return findNearest;
|
|
1105
|
-
hasRequiredFindNearest = 1;
|
|
1106
|
-
Object.defineProperty(findNearest, "__esModule", { value: true });
|
|
1107
|
-
findNearest.default = void 0;
|
|
1108
|
-
var _orderByDistance = _interopRequireDefault(requireOrderByDistance());
|
|
1109
|
-
function _interopRequireDefault(obj) {
|
|
1110
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1111
|
-
}
|
|
1112
|
-
var findNearest$1 = function findNearest2(point, coords) {
|
|
1113
|
-
return (0, _orderByDistance.default)(point, coords)[0];
|
|
1114
|
-
};
|
|
1115
|
-
var _default = findNearest$1;
|
|
1116
|
-
findNearest.default = _default;
|
|
1117
|
-
return findNearest;
|
|
1118
|
-
}
|
|
1119
|
-
var getAreaOfPolygon = {};
|
|
1120
|
-
var hasRequiredGetAreaOfPolygon;
|
|
1121
|
-
function requireGetAreaOfPolygon() {
|
|
1122
|
-
if (hasRequiredGetAreaOfPolygon) return getAreaOfPolygon;
|
|
1123
|
-
hasRequiredGetAreaOfPolygon = 1;
|
|
1124
|
-
Object.defineProperty(getAreaOfPolygon, "__esModule", { value: true });
|
|
1125
|
-
getAreaOfPolygon.default = void 0;
|
|
1126
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1127
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1128
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1129
|
-
var _constants = requireConstants();
|
|
1130
|
-
function _interopRequireDefault(obj) {
|
|
1131
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1132
|
-
}
|
|
1133
|
-
var getAreaOfPolygon$1 = function getAreaOfPolygon2(points) {
|
|
1134
|
-
var area = 0;
|
|
1135
|
-
if (points.length > 2) {
|
|
1136
|
-
var lowerIndex;
|
|
1137
|
-
var middleIndex;
|
|
1138
|
-
var upperIndex;
|
|
1139
|
-
for (var i = 0; i < points.length; i++) {
|
|
1140
|
-
if (i === points.length - 2) {
|
|
1141
|
-
lowerIndex = points.length - 2;
|
|
1142
|
-
middleIndex = points.length - 1;
|
|
1143
|
-
upperIndex = 0;
|
|
1144
|
-
} else if (i === points.length - 1) {
|
|
1145
|
-
lowerIndex = points.length - 1;
|
|
1146
|
-
middleIndex = 0;
|
|
1147
|
-
upperIndex = 1;
|
|
1148
|
-
} else {
|
|
1149
|
-
lowerIndex = i;
|
|
1150
|
-
middleIndex = i + 1;
|
|
1151
|
-
upperIndex = i + 2;
|
|
1152
|
-
}
|
|
1153
|
-
var p1lon = (0, _getLongitude.default)(points[lowerIndex]);
|
|
1154
|
-
var p2lat = (0, _getLatitude.default)(points[middleIndex]);
|
|
1155
|
-
var p3lon = (0, _getLongitude.default)(points[upperIndex]);
|
|
1156
|
-
area += ((0, _toRad.default)(p3lon) - (0, _toRad.default)(p1lon)) * Math.sin((0, _toRad.default)(p2lat));
|
|
1157
|
-
}
|
|
1158
|
-
area = area * _constants.earthRadius * _constants.earthRadius / 2;
|
|
1159
|
-
}
|
|
1160
|
-
return Math.abs(area);
|
|
1161
|
-
};
|
|
1162
|
-
var _default = getAreaOfPolygon$1;
|
|
1163
|
-
getAreaOfPolygon.default = _default;
|
|
1164
|
-
return getAreaOfPolygon;
|
|
1165
|
-
}
|
|
1166
|
-
var getBounds = {};
|
|
1167
|
-
var hasRequiredGetBounds;
|
|
1168
|
-
function requireGetBounds() {
|
|
1169
|
-
if (hasRequiredGetBounds) return getBounds;
|
|
1170
|
-
hasRequiredGetBounds = 1;
|
|
1171
|
-
Object.defineProperty(getBounds, "__esModule", { value: true });
|
|
1172
|
-
getBounds.default = void 0;
|
|
1173
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1174
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1175
|
-
function _interopRequireDefault(obj) {
|
|
1176
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1177
|
-
}
|
|
1178
|
-
var getBounds$1 = function getBounds2(points) {
|
|
1179
|
-
if (Array.isArray(points) === false || points.length === 0) {
|
|
1180
|
-
throw new Error("No points were given.");
|
|
1181
|
-
}
|
|
1182
|
-
return points.reduce(function(stats, point) {
|
|
1183
|
-
var latitude = (0, _getLatitude.default)(point);
|
|
1184
|
-
var longitude = (0, _getLongitude.default)(point);
|
|
1185
|
-
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) };
|
|
1186
|
-
}, { maxLat: -Infinity, minLat: Infinity, maxLng: -Infinity, minLng: Infinity });
|
|
1187
|
-
};
|
|
1188
|
-
var _default = getBounds$1;
|
|
1189
|
-
getBounds.default = _default;
|
|
1190
|
-
return getBounds;
|
|
1191
|
-
}
|
|
1192
|
-
var getBoundsOfDistance = {};
|
|
1193
|
-
var hasRequiredGetBoundsOfDistance;
|
|
1194
|
-
function requireGetBoundsOfDistance() {
|
|
1195
|
-
if (hasRequiredGetBoundsOfDistance) return getBoundsOfDistance;
|
|
1196
|
-
hasRequiredGetBoundsOfDistance = 1;
|
|
1197
|
-
Object.defineProperty(getBoundsOfDistance, "__esModule", { value: true });
|
|
1198
|
-
getBoundsOfDistance.default = void 0;
|
|
1199
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1200
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1201
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1202
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
1203
|
-
var _constants = requireConstants();
|
|
1204
|
-
function _interopRequireDefault(obj) {
|
|
1205
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1206
|
-
}
|
|
1207
|
-
var getBoundsOfDistance$1 = function getBoundsOfDistance2(point, distance) {
|
|
1208
|
-
var latitude = (0, _getLatitude.default)(point);
|
|
1209
|
-
var longitude = (0, _getLongitude.default)(point);
|
|
1210
|
-
var radLat = (0, _toRad.default)(latitude);
|
|
1211
|
-
var radLon = (0, _toRad.default)(longitude);
|
|
1212
|
-
var radDist = distance / _constants.earthRadius;
|
|
1213
|
-
var minLat = radLat - radDist;
|
|
1214
|
-
var maxLat = radLat + radDist;
|
|
1215
|
-
var MAX_LAT_RAD = (0, _toRad.default)(_constants.MAXLAT);
|
|
1216
|
-
var MIN_LAT_RAD = (0, _toRad.default)(_constants.MINLAT);
|
|
1217
|
-
var MAX_LON_RAD = (0, _toRad.default)(_constants.MAXLON);
|
|
1218
|
-
var MIN_LON_RAD = (0, _toRad.default)(_constants.MINLON);
|
|
1219
|
-
var minLon;
|
|
1220
|
-
var maxLon;
|
|
1221
|
-
if (minLat > MIN_LAT_RAD && maxLat < MAX_LAT_RAD) {
|
|
1222
|
-
var deltaLon = Math.asin(Math.sin(radDist) / Math.cos(radLat));
|
|
1223
|
-
minLon = radLon - deltaLon;
|
|
1224
|
-
if (minLon < MIN_LON_RAD) {
|
|
1225
|
-
minLon += Math.PI * 2;
|
|
1226
|
-
}
|
|
1227
|
-
maxLon = radLon + deltaLon;
|
|
1228
|
-
if (maxLon > MAX_LON_RAD) {
|
|
1229
|
-
maxLon -= Math.PI * 2;
|
|
1230
|
-
}
|
|
1231
|
-
} else {
|
|
1232
|
-
minLat = Math.max(minLat, MIN_LAT_RAD);
|
|
1233
|
-
maxLat = Math.min(maxLat, MAX_LAT_RAD);
|
|
1234
|
-
minLon = MIN_LON_RAD;
|
|
1235
|
-
maxLon = MAX_LON_RAD;
|
|
1236
|
-
}
|
|
1237
|
-
return [{ latitude: (0, _toDeg.default)(minLat), longitude: (0, _toDeg.default)(minLon) }, { latitude: (0, _toDeg.default)(maxLat), longitude: (0, _toDeg.default)(maxLon) }];
|
|
1238
|
-
};
|
|
1239
|
-
var _default = getBoundsOfDistance$1;
|
|
1240
|
-
getBoundsOfDistance.default = _default;
|
|
1241
|
-
return getBoundsOfDistance;
|
|
1242
|
-
}
|
|
1243
|
-
var getCenter = {};
|
|
1244
|
-
var hasRequiredGetCenter;
|
|
1245
|
-
function requireGetCenter() {
|
|
1246
|
-
if (hasRequiredGetCenter) return getCenter;
|
|
1247
|
-
hasRequiredGetCenter = 1;
|
|
1248
|
-
Object.defineProperty(getCenter, "__esModule", { value: true });
|
|
1249
|
-
getCenter.default = void 0;
|
|
1250
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1251
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1252
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1253
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
1254
|
-
function _interopRequireDefault(obj) {
|
|
1255
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1256
|
-
}
|
|
1257
|
-
var getCenter$1 = function getCenter2(points) {
|
|
1258
|
-
if (Array.isArray(points) === false || points.length === 0) {
|
|
1259
|
-
return false;
|
|
1260
|
-
}
|
|
1261
|
-
var numberOfPoints = points.length;
|
|
1262
|
-
var sum = points.reduce(function(acc, point) {
|
|
1263
|
-
var pointLat = (0, _toRad.default)((0, _getLatitude.default)(point));
|
|
1264
|
-
var pointLon = (0, _toRad.default)((0, _getLongitude.default)(point));
|
|
1265
|
-
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) };
|
|
1266
|
-
}, { X: 0, Y: 0, Z: 0 });
|
|
1267
|
-
var X = sum.X / numberOfPoints;
|
|
1268
|
-
var Y = sum.Y / numberOfPoints;
|
|
1269
|
-
var Z = sum.Z / numberOfPoints;
|
|
1270
|
-
return { longitude: (0, _toDeg.default)(Math.atan2(Y, X)), latitude: (0, _toDeg.default)(Math.atan2(Z, Math.sqrt(X * X + Y * Y))) };
|
|
1271
|
-
};
|
|
1272
|
-
var _default = getCenter$1;
|
|
1273
|
-
getCenter.default = _default;
|
|
1274
|
-
return getCenter;
|
|
1275
|
-
}
|
|
1276
|
-
var getCenterOfBounds = {};
|
|
1277
|
-
var hasRequiredGetCenterOfBounds;
|
|
1278
|
-
function requireGetCenterOfBounds() {
|
|
1279
|
-
if (hasRequiredGetCenterOfBounds) return getCenterOfBounds;
|
|
1280
|
-
hasRequiredGetCenterOfBounds = 1;
|
|
1281
|
-
Object.defineProperty(getCenterOfBounds, "__esModule", { value: true });
|
|
1282
|
-
getCenterOfBounds.default = void 0;
|
|
1283
|
-
var _getBounds = _interopRequireDefault(requireGetBounds());
|
|
1284
|
-
function _interopRequireDefault(obj) {
|
|
1285
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1286
|
-
}
|
|
1287
|
-
var getCenterOfBounds$1 = function getCenterOfBounds2(coords) {
|
|
1288
|
-
var bounds = (0, _getBounds.default)(coords);
|
|
1289
|
-
var latitude = bounds.minLat + (bounds.maxLat - bounds.minLat) / 2;
|
|
1290
|
-
var longitude = bounds.minLng + (bounds.maxLng - bounds.minLng) / 2;
|
|
1291
|
-
return { latitude: parseFloat(latitude.toFixed(6)), longitude: parseFloat(longitude.toFixed(6)) };
|
|
1292
|
-
};
|
|
1293
|
-
var _default = getCenterOfBounds$1;
|
|
1294
|
-
getCenterOfBounds.default = _default;
|
|
1295
|
-
return getCenterOfBounds;
|
|
1296
|
-
}
|
|
1297
|
-
var getCompassDirection = {};
|
|
1298
|
-
var getRhumbLineBearing = {};
|
|
1299
|
-
var hasRequiredGetRhumbLineBearing;
|
|
1300
|
-
function requireGetRhumbLineBearing() {
|
|
1301
|
-
if (hasRequiredGetRhumbLineBearing) return getRhumbLineBearing;
|
|
1302
|
-
hasRequiredGetRhumbLineBearing = 1;
|
|
1303
|
-
Object.defineProperty(getRhumbLineBearing, "__esModule", { value: true });
|
|
1304
|
-
getRhumbLineBearing.default = void 0;
|
|
1305
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1306
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1307
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1308
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
1309
|
-
function _interopRequireDefault(obj) {
|
|
1310
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1311
|
-
}
|
|
1312
|
-
var getRhumbLineBearing$1 = function getRhumbLineBearing2(origin, dest) {
|
|
1313
|
-
var diffLon = (0, _toRad.default)((0, _getLongitude.default)(dest)) - (0, _toRad.default)((0, _getLongitude.default)(origin));
|
|
1314
|
-
var diffPhi = Math.log(Math.tan((0, _toRad.default)((0, _getLatitude.default)(dest)) / 2 + Math.PI / 4) / Math.tan((0, _toRad.default)((0, _getLatitude.default)(origin)) / 2 + Math.PI / 4));
|
|
1315
|
-
if (Math.abs(diffLon) > Math.PI) {
|
|
1316
|
-
if (diffLon > 0) {
|
|
1317
|
-
diffLon = (Math.PI * 2 - diffLon) * -1;
|
|
1318
|
-
} else {
|
|
1319
|
-
diffLon = Math.PI * 2 + diffLon;
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
return ((0, _toDeg.default)(Math.atan2(diffLon, diffPhi)) + 360) % 360;
|
|
1323
|
-
};
|
|
1324
|
-
var _default = getRhumbLineBearing$1;
|
|
1325
|
-
getRhumbLineBearing.default = _default;
|
|
1326
|
-
return getRhumbLineBearing;
|
|
1327
|
-
}
|
|
1328
|
-
var hasRequiredGetCompassDirection;
|
|
1329
|
-
function requireGetCompassDirection() {
|
|
1330
|
-
if (hasRequiredGetCompassDirection) return getCompassDirection;
|
|
1331
|
-
hasRequiredGetCompassDirection = 1;
|
|
1332
|
-
Object.defineProperty(getCompassDirection, "__esModule", { value: true });
|
|
1333
|
-
getCompassDirection.default = void 0;
|
|
1334
|
-
var _getRhumbLineBearing = _interopRequireDefault(requireGetRhumbLineBearing());
|
|
1335
|
-
function _interopRequireDefault(obj) {
|
|
1336
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1337
|
-
}
|
|
1338
|
-
var getCompassDirection$1 = function getCompassDirection2(origin, dest) {
|
|
1339
|
-
var bearingFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getRhumbLineBearing.default;
|
|
1340
|
-
var bearing = typeof bearingFn === "function" ? bearingFn(origin, dest) : (0, _getRhumbLineBearing.default)(origin, dest);
|
|
1341
|
-
if (isNaN(bearing)) {
|
|
1342
|
-
throw new Error("Could not calculate bearing for given points. Check your bearing function");
|
|
1343
|
-
}
|
|
1344
|
-
switch (Math.round(bearing / 22.5)) {
|
|
1345
|
-
case 1:
|
|
1346
|
-
return "NNE";
|
|
1347
|
-
case 2:
|
|
1348
|
-
return "NE";
|
|
1349
|
-
case 3:
|
|
1350
|
-
return "ENE";
|
|
1351
|
-
case 4:
|
|
1352
|
-
return "E";
|
|
1353
|
-
case 5:
|
|
1354
|
-
return "ESE";
|
|
1355
|
-
case 6:
|
|
1356
|
-
return "SE";
|
|
1357
|
-
case 7:
|
|
1358
|
-
return "SSE";
|
|
1359
|
-
case 8:
|
|
1360
|
-
return "S";
|
|
1361
|
-
case 9:
|
|
1362
|
-
return "SSW";
|
|
1363
|
-
case 10:
|
|
1364
|
-
return "SW";
|
|
1365
|
-
case 11:
|
|
1366
|
-
return "WSW";
|
|
1367
|
-
case 12:
|
|
1368
|
-
return "W";
|
|
1369
|
-
case 13:
|
|
1370
|
-
return "WNW";
|
|
1371
|
-
case 14:
|
|
1372
|
-
return "NW";
|
|
1373
|
-
case 15:
|
|
1374
|
-
return "NNW";
|
|
1375
|
-
default:
|
|
1376
|
-
return "N";
|
|
1377
|
-
}
|
|
1378
|
-
};
|
|
1379
|
-
var _default = getCompassDirection$1;
|
|
1380
|
-
getCompassDirection.default = _default;
|
|
1381
|
-
return getCompassDirection;
|
|
1382
|
-
}
|
|
1383
|
-
var getDistanceFromLine = {};
|
|
1384
|
-
var hasRequiredGetDistanceFromLine;
|
|
1385
|
-
function requireGetDistanceFromLine() {
|
|
1386
|
-
if (hasRequiredGetDistanceFromLine) return getDistanceFromLine;
|
|
1387
|
-
hasRequiredGetDistanceFromLine = 1;
|
|
1388
|
-
Object.defineProperty(getDistanceFromLine, "__esModule", { value: true });
|
|
1389
|
-
getDistanceFromLine.default = void 0;
|
|
1390
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1391
|
-
var _robustAcos = _interopRequireDefault(requireRobustAcos());
|
|
1392
|
-
function _interopRequireDefault(obj) {
|
|
1393
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1394
|
-
}
|
|
1395
|
-
var getDistanceFromLine$1 = function getDistanceFromLine2(point, lineStart, lineEnd) {
|
|
1396
|
-
var accuracy = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
|
|
1397
|
-
var d1 = (0, _getDistance.default)(lineStart, point, accuracy);
|
|
1398
|
-
var d2 = (0, _getDistance.default)(point, lineEnd, accuracy);
|
|
1399
|
-
var d3 = (0, _getDistance.default)(lineStart, lineEnd, accuracy);
|
|
1400
|
-
var alpha = Math.acos((0, _robustAcos.default)((d1 * d1 + d3 * d3 - d2 * d2) / (2 * d1 * d3)));
|
|
1401
|
-
var beta = Math.acos((0, _robustAcos.default)((d2 * d2 + d3 * d3 - d1 * d1) / (2 * d2 * d3)));
|
|
1402
|
-
if (alpha > Math.PI / 2) {
|
|
1403
|
-
return d1;
|
|
1404
|
-
}
|
|
1405
|
-
if (beta > Math.PI / 2) {
|
|
1406
|
-
return d2;
|
|
1407
|
-
}
|
|
1408
|
-
return Math.sin(alpha) * d1;
|
|
1409
|
-
};
|
|
1410
|
-
var _default = getDistanceFromLine$1;
|
|
1411
|
-
getDistanceFromLine.default = _default;
|
|
1412
|
-
return getDistanceFromLine;
|
|
1413
|
-
}
|
|
1414
|
-
var getGreatCircleBearing = {};
|
|
1415
|
-
var hasRequiredGetGreatCircleBearing;
|
|
1416
|
-
function requireGetGreatCircleBearing() {
|
|
1417
|
-
if (hasRequiredGetGreatCircleBearing) return getGreatCircleBearing;
|
|
1418
|
-
hasRequiredGetGreatCircleBearing = 1;
|
|
1419
|
-
Object.defineProperty(getGreatCircleBearing, "__esModule", { value: true });
|
|
1420
|
-
getGreatCircleBearing.default = void 0;
|
|
1421
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1422
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1423
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1424
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
1425
|
-
function _interopRequireDefault(obj) {
|
|
1426
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1427
|
-
}
|
|
1428
|
-
var getGreatCircleBearing$1 = function getGreatCircleBearing2(origin, dest) {
|
|
1429
|
-
var destLat = (0, _getLatitude.default)(dest);
|
|
1430
|
-
var detLon = (0, _getLongitude.default)(dest);
|
|
1431
|
-
var originLat = (0, _getLatitude.default)(origin);
|
|
1432
|
-
var originLon = (0, _getLongitude.default)(origin);
|
|
1433
|
-
var bearing = ((0, _toDeg.default)(Math.atan2(Math.sin((0, _toRad.default)(detLon) - (0, _toRad.default)(originLon)) * Math.cos((0, _toRad.default)(destLat)), Math.cos((0, _toRad.default)(originLat)) * Math.sin((0, _toRad.default)(destLat)) - Math.sin((0, _toRad.default)(originLat)) * Math.cos((0, _toRad.default)(destLat)) * Math.cos((0, _toRad.default)(detLon) - (0, _toRad.default)(originLon)))) + 360) % 360;
|
|
1434
|
-
return bearing;
|
|
1435
|
-
};
|
|
1436
|
-
var _default = getGreatCircleBearing$1;
|
|
1437
|
-
getGreatCircleBearing.default = _default;
|
|
1438
|
-
return getGreatCircleBearing;
|
|
1439
|
-
}
|
|
1440
|
-
var getPathLength = {};
|
|
1441
|
-
var hasRequiredGetPathLength;
|
|
1442
|
-
function requireGetPathLength() {
|
|
1443
|
-
if (hasRequiredGetPathLength) return getPathLength;
|
|
1444
|
-
hasRequiredGetPathLength = 1;
|
|
1445
|
-
Object.defineProperty(getPathLength, "__esModule", { value: true });
|
|
1446
|
-
getPathLength.default = void 0;
|
|
1447
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1448
|
-
function _interopRequireDefault(obj) {
|
|
1449
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1450
|
-
}
|
|
1451
|
-
function _typeof(obj) {
|
|
1452
|
-
"@babel/helpers - typeof";
|
|
1453
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
1454
|
-
_typeof = function _typeof2(obj2) {
|
|
1455
|
-
return typeof obj2;
|
|
1456
|
-
};
|
|
1457
|
-
} else {
|
|
1458
|
-
_typeof = function _typeof2(obj2) {
|
|
1459
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
1460
|
-
};
|
|
1461
|
-
}
|
|
1462
|
-
return _typeof(obj);
|
|
1463
|
-
}
|
|
1464
|
-
var getPathLength$1 = function getPathLength2(points) {
|
|
1465
|
-
var distanceFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _getDistance.default;
|
|
1466
|
-
return points.reduce(function(acc, point) {
|
|
1467
|
-
if (_typeof(acc) === "object" && acc.last !== null) {
|
|
1468
|
-
acc.distance += distanceFn(point, acc.last);
|
|
1469
|
-
}
|
|
1470
|
-
acc.last = point;
|
|
1471
|
-
return acc;
|
|
1472
|
-
}, { last: null, distance: 0 }).distance;
|
|
1473
|
-
};
|
|
1474
|
-
var _default = getPathLength$1;
|
|
1475
|
-
getPathLength.default = _default;
|
|
1476
|
-
return getPathLength;
|
|
1477
|
-
}
|
|
1478
|
-
var getPreciseDistance = {};
|
|
1479
|
-
var hasRequiredGetPreciseDistance;
|
|
1480
|
-
function requireGetPreciseDistance() {
|
|
1481
|
-
if (hasRequiredGetPreciseDistance) return getPreciseDistance;
|
|
1482
|
-
hasRequiredGetPreciseDistance = 1;
|
|
1483
|
-
Object.defineProperty(getPreciseDistance, "__esModule", { value: true });
|
|
1484
|
-
getPreciseDistance.default = void 0;
|
|
1485
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1486
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1487
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1488
|
-
var _constants = requireConstants();
|
|
1489
|
-
function _interopRequireDefault(obj) {
|
|
1490
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1491
|
-
}
|
|
1492
|
-
var getDistance2 = function getDistance3(start, end) {
|
|
1493
|
-
var accuracy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
1494
|
-
accuracy = typeof accuracy !== "undefined" && !isNaN(accuracy) ? accuracy : 1;
|
|
1495
|
-
var startLat = (0, _getLatitude.default)(start);
|
|
1496
|
-
var startLon = (0, _getLongitude.default)(start);
|
|
1497
|
-
var endLat = (0, _getLatitude.default)(end);
|
|
1498
|
-
var endLon = (0, _getLongitude.default)(end);
|
|
1499
|
-
var b = 6356752314245e-6;
|
|
1500
|
-
var ellipsoidParams = 1 / 298.257223563;
|
|
1501
|
-
var L = (0, _toRad.default)(endLon - startLon);
|
|
1502
|
-
var cosSigma;
|
|
1503
|
-
var sigma;
|
|
1504
|
-
var sinAlpha;
|
|
1505
|
-
var cosSqAlpha;
|
|
1506
|
-
var cos2SigmaM;
|
|
1507
|
-
var sinSigma;
|
|
1508
|
-
var U1 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(startLat))));
|
|
1509
|
-
var U2 = Math.atan((1 - ellipsoidParams) * Math.tan((0, _toRad.default)(parseFloat(endLat))));
|
|
1510
|
-
var sinU1 = Math.sin(U1);
|
|
1511
|
-
var cosU1 = Math.cos(U1);
|
|
1512
|
-
var sinU2 = Math.sin(U2);
|
|
1513
|
-
var cosU2 = Math.cos(U2);
|
|
1514
|
-
var lambda = L;
|
|
1515
|
-
var lambdaP;
|
|
1516
|
-
var iterLimit = 100;
|
|
1517
|
-
do {
|
|
1518
|
-
var sinLambda = Math.sin(lambda);
|
|
1519
|
-
var cosLambda = Math.cos(lambda);
|
|
1520
|
-
sinSigma = Math.sqrt(cosU2 * sinLambda * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
|
|
1521
|
-
if (sinSigma === 0) {
|
|
1522
|
-
return 0;
|
|
1523
|
-
}
|
|
1524
|
-
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
|
|
1525
|
-
sigma = Math.atan2(sinSigma, cosSigma);
|
|
1526
|
-
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
|
|
1527
|
-
cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
|
1528
|
-
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
|
|
1529
|
-
if (isNaN(cos2SigmaM)) {
|
|
1530
|
-
cos2SigmaM = 0;
|
|
1531
|
-
}
|
|
1532
|
-
var C = ellipsoidParams / 16 * cosSqAlpha * (4 + ellipsoidParams * (4 - 3 * cosSqAlpha));
|
|
1533
|
-
lambdaP = lambda;
|
|
1534
|
-
lambda = L + (1 - C) * ellipsoidParams * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
1535
|
-
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
|
|
1536
|
-
if (iterLimit === 0) {
|
|
1537
|
-
return NaN;
|
|
1538
|
-
}
|
|
1539
|
-
var uSq = cosSqAlpha * (_constants.earthRadius * _constants.earthRadius - b * b) / (b * b);
|
|
1540
|
-
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
|
1541
|
-
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
|
1542
|
-
var deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
|
1543
|
-
var distance = b * A * (sigma - deltaSigma);
|
|
1544
|
-
return Math.round(distance / accuracy) * accuracy;
|
|
1545
|
-
};
|
|
1546
|
-
var _default = getDistance2;
|
|
1547
|
-
getPreciseDistance.default = _default;
|
|
1548
|
-
return getPreciseDistance;
|
|
1549
|
-
}
|
|
1550
|
-
var getRoughCompassDirection = {};
|
|
1551
|
-
var hasRequiredGetRoughCompassDirection;
|
|
1552
|
-
function requireGetRoughCompassDirection() {
|
|
1553
|
-
if (hasRequiredGetRoughCompassDirection) return getRoughCompassDirection;
|
|
1554
|
-
hasRequiredGetRoughCompassDirection = 1;
|
|
1555
|
-
Object.defineProperty(getRoughCompassDirection, "__esModule", { value: true });
|
|
1556
|
-
getRoughCompassDirection.default = void 0;
|
|
1557
|
-
var getRoughCompassDirection$1 = function getRoughCompassDirection2(exact) {
|
|
1558
|
-
if (/^(NNE|NE|NNW|N)$/.test(exact)) {
|
|
1559
|
-
return "N";
|
|
1560
|
-
}
|
|
1561
|
-
if (/^(ENE|E|ESE|SE)$/.test(exact)) {
|
|
1562
|
-
return "E";
|
|
1563
|
-
}
|
|
1564
|
-
if (/^(SSE|S|SSW|SW)$/.test(exact)) {
|
|
1565
|
-
return "S";
|
|
1566
|
-
}
|
|
1567
|
-
if (/^(WSW|W|WNW|NW)$/.test(exact)) {
|
|
1568
|
-
return "W";
|
|
1569
|
-
}
|
|
1570
|
-
};
|
|
1571
|
-
var _default = getRoughCompassDirection$1;
|
|
1572
|
-
getRoughCompassDirection.default = _default;
|
|
1573
|
-
return getRoughCompassDirection;
|
|
1574
|
-
}
|
|
1575
|
-
var getSpeed = {};
|
|
1576
|
-
var hasRequiredGetSpeed;
|
|
1577
|
-
function requireGetSpeed() {
|
|
1578
|
-
if (hasRequiredGetSpeed) return getSpeed;
|
|
1579
|
-
hasRequiredGetSpeed = 1;
|
|
1580
|
-
Object.defineProperty(getSpeed, "__esModule", { value: true });
|
|
1581
|
-
getSpeed.default = void 0;
|
|
1582
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1583
|
-
function _interopRequireDefault(obj) {
|
|
1584
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1585
|
-
}
|
|
1586
|
-
var getSpeed$1 = function getSpeed2(start, end) {
|
|
1587
|
-
var distanceFn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : _getDistance.default;
|
|
1588
|
-
var distance = distanceFn(start, end);
|
|
1589
|
-
var time = Number(end.time) - Number(start.time);
|
|
1590
|
-
var metersPerSecond = distance / time * 1e3;
|
|
1591
|
-
return metersPerSecond;
|
|
1592
|
-
};
|
|
1593
|
-
var _default = getSpeed$1;
|
|
1594
|
-
getSpeed.default = _default;
|
|
1595
|
-
return getSpeed;
|
|
1596
|
-
}
|
|
1597
|
-
var isPointInLine = {};
|
|
1598
|
-
var hasRequiredIsPointInLine;
|
|
1599
|
-
function requireIsPointInLine() {
|
|
1600
|
-
if (hasRequiredIsPointInLine) return isPointInLine;
|
|
1601
|
-
hasRequiredIsPointInLine = 1;
|
|
1602
|
-
Object.defineProperty(isPointInLine, "__esModule", { value: true });
|
|
1603
|
-
isPointInLine.default = void 0;
|
|
1604
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1605
|
-
function _interopRequireDefault(obj) {
|
|
1606
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1607
|
-
}
|
|
1608
|
-
var isPointInLine$1 = function isPointInLine2(point, lineStart, lineEnd) {
|
|
1609
|
-
return (0, _getDistance.default)(lineStart, point) + (0, _getDistance.default)(point, lineEnd) === (0, _getDistance.default)(lineStart, lineEnd);
|
|
1610
|
-
};
|
|
1611
|
-
var _default = isPointInLine$1;
|
|
1612
|
-
isPointInLine.default = _default;
|
|
1613
|
-
return isPointInLine;
|
|
1614
|
-
}
|
|
1615
|
-
var isPointInPolygon = {};
|
|
1616
|
-
var hasRequiredIsPointInPolygon;
|
|
1617
|
-
function requireIsPointInPolygon() {
|
|
1618
|
-
if (hasRequiredIsPointInPolygon) return isPointInPolygon;
|
|
1619
|
-
hasRequiredIsPointInPolygon = 1;
|
|
1620
|
-
Object.defineProperty(isPointInPolygon, "__esModule", { value: true });
|
|
1621
|
-
isPointInPolygon.default = void 0;
|
|
1622
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1623
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1624
|
-
function _interopRequireDefault(obj) {
|
|
1625
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1626
|
-
}
|
|
1627
|
-
var isPointInPolygon$1 = function isPointInPolygon2(point, polygon) {
|
|
1628
|
-
var isInside = false;
|
|
1629
|
-
var totalPolys = polygon.length;
|
|
1630
|
-
for (var i = -1, j = totalPolys - 1; ++i < totalPolys; j = i) {
|
|
1631
|
-
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])) {
|
|
1632
|
-
isInside = !isInside;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
return isInside;
|
|
1636
|
-
};
|
|
1637
|
-
var _default = isPointInPolygon$1;
|
|
1638
|
-
isPointInPolygon.default = _default;
|
|
1639
|
-
return isPointInPolygon;
|
|
1640
|
-
}
|
|
1641
|
-
var isPointNearLine = {};
|
|
1642
|
-
var hasRequiredIsPointNearLine;
|
|
1643
|
-
function requireIsPointNearLine() {
|
|
1644
|
-
if (hasRequiredIsPointNearLine) return isPointNearLine;
|
|
1645
|
-
hasRequiredIsPointNearLine = 1;
|
|
1646
|
-
Object.defineProperty(isPointNearLine, "__esModule", { value: true });
|
|
1647
|
-
isPointNearLine.default = void 0;
|
|
1648
|
-
var _getDistanceFromLine = _interopRequireDefault(requireGetDistanceFromLine());
|
|
1649
|
-
function _interopRequireDefault(obj) {
|
|
1650
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1651
|
-
}
|
|
1652
|
-
var isPointNearLine$1 = function isPointNearLine2(point, start, end, distance) {
|
|
1653
|
-
return (0, _getDistanceFromLine.default)(point, start, end) < distance;
|
|
1654
|
-
};
|
|
1655
|
-
var _default = isPointNearLine$1;
|
|
1656
|
-
isPointNearLine.default = _default;
|
|
1657
|
-
return isPointNearLine;
|
|
1658
|
-
}
|
|
1659
|
-
var isPointWithinRadius = {};
|
|
1660
|
-
var hasRequiredIsPointWithinRadius;
|
|
1661
|
-
function requireIsPointWithinRadius() {
|
|
1662
|
-
if (hasRequiredIsPointWithinRadius) return isPointWithinRadius;
|
|
1663
|
-
hasRequiredIsPointWithinRadius = 1;
|
|
1664
|
-
Object.defineProperty(isPointWithinRadius, "__esModule", { value: true });
|
|
1665
|
-
isPointWithinRadius.default = void 0;
|
|
1666
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1667
|
-
function _interopRequireDefault(obj) {
|
|
1668
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1669
|
-
}
|
|
1670
|
-
var isPointWithinRadius$1 = function isPointWithinRadius2(point, center, radius) {
|
|
1671
|
-
var accuracy = 0.01;
|
|
1672
|
-
return (0, _getDistance.default)(point, center, accuracy) < radius;
|
|
1673
|
-
};
|
|
1674
|
-
var _default = isPointWithinRadius$1;
|
|
1675
|
-
isPointWithinRadius.default = _default;
|
|
1676
|
-
return isPointWithinRadius;
|
|
1677
|
-
}
|
|
1678
|
-
var wktToPolygon = {};
|
|
1679
|
-
var hasRequiredWktToPolygon;
|
|
1680
|
-
function requireWktToPolygon() {
|
|
1681
|
-
if (hasRequiredWktToPolygon) return wktToPolygon;
|
|
1682
|
-
hasRequiredWktToPolygon = 1;
|
|
1683
|
-
Object.defineProperty(wktToPolygon, "__esModule", { value: true });
|
|
1684
|
-
wktToPolygon.default = void 0;
|
|
1685
|
-
function _slicedToArray(arr, i) {
|
|
1686
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1687
|
-
}
|
|
1688
|
-
function _nonIterableRest() {
|
|
1689
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1690
|
-
}
|
|
1691
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1692
|
-
if (!o) return;
|
|
1693
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1694
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1695
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1696
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1697
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1698
|
-
}
|
|
1699
|
-
function _arrayLikeToArray(arr, len) {
|
|
1700
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1701
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1702
|
-
arr2[i] = arr[i];
|
|
1703
|
-
}
|
|
1704
|
-
return arr2;
|
|
1705
|
-
}
|
|
1706
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1707
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
1708
|
-
var _arr = [];
|
|
1709
|
-
var _n = true;
|
|
1710
|
-
var _d = false;
|
|
1711
|
-
var _e = void 0;
|
|
1712
|
-
try {
|
|
1713
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
1714
|
-
_arr.push(_s.value);
|
|
1715
|
-
if (i && _arr.length === i) break;
|
|
1716
|
-
}
|
|
1717
|
-
} catch (err) {
|
|
1718
|
-
_d = true;
|
|
1719
|
-
_e = err;
|
|
1720
|
-
} finally {
|
|
1721
|
-
try {
|
|
1722
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1723
|
-
} finally {
|
|
1724
|
-
if (_d) throw _e;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
return _arr;
|
|
1728
|
-
}
|
|
1729
|
-
function _arrayWithHoles(arr) {
|
|
1730
|
-
if (Array.isArray(arr)) return arr;
|
|
1731
|
-
}
|
|
1732
|
-
var wktToPolygon$1 = function wktToPolygon2(wkt) {
|
|
1733
|
-
if (!wkt.startsWith("POLYGON")) {
|
|
1734
|
-
throw new Error("Invalid wkt.");
|
|
1735
|
-
}
|
|
1736
|
-
var coordsText = wkt.slice(wkt.indexOf("(") + 2, wkt.indexOf(")")).split(", ");
|
|
1737
|
-
var polygon = coordsText.map(function(coordText) {
|
|
1738
|
-
var _coordText$split = coordText.split(" "), _coordText$split2 = _slicedToArray(_coordText$split, 2), longitude = _coordText$split2[0], latitude = _coordText$split2[1];
|
|
1739
|
-
return { longitude: parseFloat(longitude), latitude: parseFloat(latitude) };
|
|
1740
|
-
});
|
|
1741
|
-
return polygon;
|
|
1742
|
-
};
|
|
1743
|
-
var _default = wktToPolygon$1;
|
|
1744
|
-
wktToPolygon.default = _default;
|
|
1745
|
-
return wktToPolygon;
|
|
1746
|
-
}
|
|
1747
|
-
var hasRequiredEs;
|
|
1748
|
-
function requireEs() {
|
|
1749
|
-
if (hasRequiredEs) return es;
|
|
1750
|
-
hasRequiredEs = 1;
|
|
1751
|
-
(function(exports$1) {
|
|
1752
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1753
|
-
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 };
|
|
1754
|
-
Object.defineProperty(exports$1, "computeDestinationPoint", { enumerable: true, get: function get() {
|
|
1755
|
-
return _computeDestinationPoint.default;
|
|
1756
|
-
} });
|
|
1757
|
-
Object.defineProperty(exports$1, "convertArea", { enumerable: true, get: function get() {
|
|
1758
|
-
return _convertArea.default;
|
|
1759
|
-
} });
|
|
1760
|
-
Object.defineProperty(exports$1, "convertDistance", { enumerable: true, get: function get() {
|
|
1761
|
-
return _convertDistance.default;
|
|
1762
|
-
} });
|
|
1763
|
-
Object.defineProperty(exports$1, "convertSpeed", { enumerable: true, get: function get() {
|
|
1764
|
-
return _convertSpeed.default;
|
|
1765
|
-
} });
|
|
1766
|
-
Object.defineProperty(exports$1, "decimalToSexagesimal", { enumerable: true, get: function get() {
|
|
1767
|
-
return _decimalToSexagesimal.default;
|
|
1768
|
-
} });
|
|
1769
|
-
Object.defineProperty(exports$1, "findNearest", { enumerable: true, get: function get() {
|
|
1770
|
-
return _findNearest.default;
|
|
1771
|
-
} });
|
|
1772
|
-
Object.defineProperty(exports$1, "getAreaOfPolygon", { enumerable: true, get: function get() {
|
|
1773
|
-
return _getAreaOfPolygon.default;
|
|
1774
|
-
} });
|
|
1775
|
-
Object.defineProperty(exports$1, "getBounds", { enumerable: true, get: function get() {
|
|
1776
|
-
return _getBounds.default;
|
|
1777
|
-
} });
|
|
1778
|
-
Object.defineProperty(exports$1, "getBoundsOfDistance", { enumerable: true, get: function get() {
|
|
1779
|
-
return _getBoundsOfDistance.default;
|
|
1780
|
-
} });
|
|
1781
|
-
Object.defineProperty(exports$1, "getCenter", { enumerable: true, get: function get() {
|
|
1782
|
-
return _getCenter.default;
|
|
1783
|
-
} });
|
|
1784
|
-
Object.defineProperty(exports$1, "getCenterOfBounds", { enumerable: true, get: function get() {
|
|
1785
|
-
return _getCenterOfBounds.default;
|
|
1786
|
-
} });
|
|
1787
|
-
Object.defineProperty(exports$1, "getCompassDirection", { enumerable: true, get: function get() {
|
|
1788
|
-
return _getCompassDirection.default;
|
|
1789
|
-
} });
|
|
1790
|
-
Object.defineProperty(exports$1, "getCoordinateKey", { enumerable: true, get: function get() {
|
|
1791
|
-
return _getCoordinateKey.default;
|
|
1792
|
-
} });
|
|
1793
|
-
Object.defineProperty(exports$1, "getCoordinateKeys", { enumerable: true, get: function get() {
|
|
1794
|
-
return _getCoordinateKeys.default;
|
|
1795
|
-
} });
|
|
1796
|
-
Object.defineProperty(exports$1, "getDistance", { enumerable: true, get: function get() {
|
|
1797
|
-
return _getDistance.default;
|
|
1798
|
-
} });
|
|
1799
|
-
Object.defineProperty(exports$1, "getDistanceFromLine", { enumerable: true, get: function get() {
|
|
1800
|
-
return _getDistanceFromLine.default;
|
|
1801
|
-
} });
|
|
1802
|
-
Object.defineProperty(exports$1, "getGreatCircleBearing", { enumerable: true, get: function get() {
|
|
1803
|
-
return _getGreatCircleBearing.default;
|
|
1804
|
-
} });
|
|
1805
|
-
Object.defineProperty(exports$1, "getLatitude", { enumerable: true, get: function get() {
|
|
1806
|
-
return _getLatitude.default;
|
|
1807
|
-
} });
|
|
1808
|
-
Object.defineProperty(exports$1, "getLongitude", { enumerable: true, get: function get() {
|
|
1809
|
-
return _getLongitude.default;
|
|
1810
|
-
} });
|
|
1811
|
-
Object.defineProperty(exports$1, "getPathLength", { enumerable: true, get: function get() {
|
|
1812
|
-
return _getPathLength.default;
|
|
1813
|
-
} });
|
|
1814
|
-
Object.defineProperty(exports$1, "getPreciseDistance", { enumerable: true, get: function get() {
|
|
1815
|
-
return _getPreciseDistance.default;
|
|
1816
|
-
} });
|
|
1817
|
-
Object.defineProperty(exports$1, "getRhumbLineBearing", { enumerable: true, get: function get() {
|
|
1818
|
-
return _getRhumbLineBearing.default;
|
|
1819
|
-
} });
|
|
1820
|
-
Object.defineProperty(exports$1, "getRoughCompassDirection", { enumerable: true, get: function get() {
|
|
1821
|
-
return _getRoughCompassDirection.default;
|
|
1822
|
-
} });
|
|
1823
|
-
Object.defineProperty(exports$1, "getSpeed", { enumerable: true, get: function get() {
|
|
1824
|
-
return _getSpeed.default;
|
|
1825
|
-
} });
|
|
1826
|
-
Object.defineProperty(exports$1, "isDecimal", { enumerable: true, get: function get() {
|
|
1827
|
-
return _isDecimal.default;
|
|
1828
|
-
} });
|
|
1829
|
-
Object.defineProperty(exports$1, "isPointInLine", { enumerable: true, get: function get() {
|
|
1830
|
-
return _isPointInLine.default;
|
|
1831
|
-
} });
|
|
1832
|
-
Object.defineProperty(exports$1, "isPointInPolygon", { enumerable: true, get: function get() {
|
|
1833
|
-
return _isPointInPolygon.default;
|
|
1834
|
-
} });
|
|
1835
|
-
Object.defineProperty(exports$1, "isPointNearLine", { enumerable: true, get: function get() {
|
|
1836
|
-
return _isPointNearLine.default;
|
|
1837
|
-
} });
|
|
1838
|
-
Object.defineProperty(exports$1, "isPointWithinRadius", { enumerable: true, get: function get() {
|
|
1839
|
-
return _isPointWithinRadius.default;
|
|
1840
|
-
} });
|
|
1841
|
-
Object.defineProperty(exports$1, "isSexagesimal", { enumerable: true, get: function get() {
|
|
1842
|
-
return _isSexagesimal.default;
|
|
1843
|
-
} });
|
|
1844
|
-
Object.defineProperty(exports$1, "isValidCoordinate", { enumerable: true, get: function get() {
|
|
1845
|
-
return _isValidCoordinate.default;
|
|
1846
|
-
} });
|
|
1847
|
-
Object.defineProperty(exports$1, "isValidLatitude", { enumerable: true, get: function get() {
|
|
1848
|
-
return _isValidLatitude.default;
|
|
1849
|
-
} });
|
|
1850
|
-
Object.defineProperty(exports$1, "isValidLongitude", { enumerable: true, get: function get() {
|
|
1851
|
-
return _isValidLongitude.default;
|
|
1852
|
-
} });
|
|
1853
|
-
Object.defineProperty(exports$1, "orderByDistance", { enumerable: true, get: function get() {
|
|
1854
|
-
return _orderByDistance.default;
|
|
1855
|
-
} });
|
|
1856
|
-
Object.defineProperty(exports$1, "sexagesimalToDecimal", { enumerable: true, get: function get() {
|
|
1857
|
-
return _sexagesimalToDecimal.default;
|
|
1858
|
-
} });
|
|
1859
|
-
Object.defineProperty(exports$1, "toDecimal", { enumerable: true, get: function get() {
|
|
1860
|
-
return _toDecimal.default;
|
|
1861
|
-
} });
|
|
1862
|
-
Object.defineProperty(exports$1, "toRad", { enumerable: true, get: function get() {
|
|
1863
|
-
return _toRad.default;
|
|
1864
|
-
} });
|
|
1865
|
-
Object.defineProperty(exports$1, "toDeg", { enumerable: true, get: function get() {
|
|
1866
|
-
return _toDeg.default;
|
|
1867
|
-
} });
|
|
1868
|
-
Object.defineProperty(exports$1, "wktToPolygon", { enumerable: true, get: function get() {
|
|
1869
|
-
return _wktToPolygon.default;
|
|
1870
|
-
} });
|
|
1871
|
-
var _computeDestinationPoint = _interopRequireDefault(requireComputeDestinationPoint());
|
|
1872
|
-
var _convertArea = _interopRequireDefault(requireConvertArea());
|
|
1873
|
-
var _convertDistance = _interopRequireDefault(requireConvertDistance());
|
|
1874
|
-
var _convertSpeed = _interopRequireDefault(requireConvertSpeed());
|
|
1875
|
-
var _decimalToSexagesimal = _interopRequireDefault(requireDecimalToSexagesimal());
|
|
1876
|
-
var _findNearest = _interopRequireDefault(requireFindNearest());
|
|
1877
|
-
var _getAreaOfPolygon = _interopRequireDefault(requireGetAreaOfPolygon());
|
|
1878
|
-
var _getBounds = _interopRequireDefault(requireGetBounds());
|
|
1879
|
-
var _getBoundsOfDistance = _interopRequireDefault(requireGetBoundsOfDistance());
|
|
1880
|
-
var _getCenter = _interopRequireDefault(requireGetCenter());
|
|
1881
|
-
var _getCenterOfBounds = _interopRequireDefault(requireGetCenterOfBounds());
|
|
1882
|
-
var _getCompassDirection = _interopRequireDefault(requireGetCompassDirection());
|
|
1883
|
-
var _getCoordinateKey = _interopRequireDefault(requireGetCoordinateKey());
|
|
1884
|
-
var _getCoordinateKeys = _interopRequireDefault(requireGetCoordinateKeys());
|
|
1885
|
-
var _getDistance = _interopRequireDefault(requireGetDistance());
|
|
1886
|
-
var _getDistanceFromLine = _interopRequireDefault(requireGetDistanceFromLine());
|
|
1887
|
-
var _getGreatCircleBearing = _interopRequireDefault(requireGetGreatCircleBearing());
|
|
1888
|
-
var _getLatitude = _interopRequireDefault(requireGetLatitude());
|
|
1889
|
-
var _getLongitude = _interopRequireDefault(requireGetLongitude());
|
|
1890
|
-
var _getPathLength = _interopRequireDefault(requireGetPathLength());
|
|
1891
|
-
var _getPreciseDistance = _interopRequireDefault(requireGetPreciseDistance());
|
|
1892
|
-
var _getRhumbLineBearing = _interopRequireDefault(requireGetRhumbLineBearing());
|
|
1893
|
-
var _getRoughCompassDirection = _interopRequireDefault(requireGetRoughCompassDirection());
|
|
1894
|
-
var _getSpeed = _interopRequireDefault(requireGetSpeed());
|
|
1895
|
-
var _isDecimal = _interopRequireDefault(requireIsDecimal());
|
|
1896
|
-
var _isPointInLine = _interopRequireDefault(requireIsPointInLine());
|
|
1897
|
-
var _isPointInPolygon = _interopRequireDefault(requireIsPointInPolygon());
|
|
1898
|
-
var _isPointNearLine = _interopRequireDefault(requireIsPointNearLine());
|
|
1899
|
-
var _isPointWithinRadius = _interopRequireDefault(requireIsPointWithinRadius());
|
|
1900
|
-
var _isSexagesimal = _interopRequireDefault(requireIsSexagesimal());
|
|
1901
|
-
var _isValidCoordinate = _interopRequireDefault(requireIsValidCoordinate());
|
|
1902
|
-
var _isValidLatitude = _interopRequireDefault(requireIsValidLatitude());
|
|
1903
|
-
var _isValidLongitude = _interopRequireDefault(requireIsValidLongitude());
|
|
1904
|
-
var _orderByDistance = _interopRequireDefault(requireOrderByDistance());
|
|
1905
|
-
var _sexagesimalToDecimal = _interopRequireDefault(requireSexagesimalToDecimal());
|
|
1906
|
-
var _toDecimal = _interopRequireDefault(requireToDecimal());
|
|
1907
|
-
var _toRad = _interopRequireDefault(requireToRad());
|
|
1908
|
-
var _toDeg = _interopRequireDefault(requireToDeg());
|
|
1909
|
-
var _wktToPolygon = _interopRequireDefault(requireWktToPolygon());
|
|
1910
|
-
var _constants = requireConstants();
|
|
1911
|
-
Object.keys(_constants).forEach(function(key) {
|
|
1912
|
-
if (key === "default" || key === "__esModule") return;
|
|
1913
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
1914
|
-
Object.defineProperty(exports$1, key, { enumerable: true, get: function get() {
|
|
1915
|
-
return _constants[key];
|
|
1916
|
-
} });
|
|
1917
|
-
});
|
|
1918
|
-
function _interopRequireDefault(obj) {
|
|
1919
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
1920
|
-
}
|
|
1921
|
-
})(es);
|
|
1922
|
-
return es;
|
|
1923
|
-
}
|
|
1924
|
-
var esExports = requireEs();
|
|
32
|
+
const fs = '#version 300 es\n#define SHADER_NAME "arrow-layer-fragment-shader"\nprecision highp float;\n\n/**\n * Copyright (c) 2022, RTE (http://www.rte-france.com)\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n\nflat in vec4 vFillColor;\nflat in float shouldDiscard;\nout vec4 fragmentColor;\n\nvoid main(void ) {\n if (shouldDiscard > 0.0) {\n discard;\n }\n fragmentColor = vFillColor;\n}\n';
|
|
1925
33
|
const vs = `#version 300 es
|
|
1926
34
|
#define SHADER_NAME "arrow-layer-vertex-shader"
|
|
1927
35
|
|
|
@@ -1949,17 +57,8 @@ in vec3 instanceLineAngles;
|
|
|
1949
57
|
in vec2 instanceProximityFactors;
|
|
1950
58
|
in float instanceDistanceBetweenLines;
|
|
1951
59
|
|
|
1952
|
-
uniform float sizeMinPixels;
|
|
1953
|
-
uniform float sizeMaxPixels;
|
|
1954
|
-
uniform float timestamp;
|
|
1955
60
|
uniform sampler2D linePositionsTexture;
|
|
1956
61
|
uniform sampler2D lineDistancesTexture;
|
|
1957
|
-
uniform float maxParallelOffset;
|
|
1958
|
-
uniform float minParallelOffset;
|
|
1959
|
-
uniform float opacity;
|
|
1960
|
-
uniform ivec2 linePositionsTextureSize;
|
|
1961
|
-
|
|
1962
|
-
uniform ivec2 lineDistancesTextureSize;
|
|
1963
62
|
|
|
1964
63
|
flat out vec4 vFillColor;
|
|
1965
64
|
flat out float shouldDiscard;
|
|
@@ -1976,7 +75,7 @@ ivec2 calculateTextureIndex(int flatIndex, ivec2 textureSize) {
|
|
|
1976
75
|
*/
|
|
1977
76
|
vec3 fetchLinePosition(int point) {
|
|
1978
77
|
int flatIndex = instanceLinePositionsTextureOffset + point;
|
|
1979
|
-
ivec2 textureIndex = calculateTextureIndex(flatIndex, linePositionsTextureSize);
|
|
78
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, arrow.linePositionsTextureSize);
|
|
1980
79
|
return vec3(texelFetch(linePositionsTexture, textureIndex, 0).xy, 0);
|
|
1981
80
|
}
|
|
1982
81
|
|
|
@@ -1985,7 +84,7 @@ vec3 fetchLinePosition(int point) {
|
|
|
1985
84
|
*/
|
|
1986
85
|
float fetchLineDistance(int point) {
|
|
1987
86
|
int flatIndex = instanceLineDistancesTextureOffset + point;
|
|
1988
|
-
ivec2 textureIndex = calculateTextureIndex(flatIndex, lineDistancesTextureSize);
|
|
87
|
+
ivec2 textureIndex = calculateTextureIndex(flatIndex, arrow.lineDistancesTextureSize);
|
|
1989
88
|
return texelFetch(lineDistancesTexture, textureIndex, 0).x;
|
|
1990
89
|
}
|
|
1991
90
|
|
|
@@ -2054,9 +153,9 @@ float project_size_at_latitude_low_zoom(float lat) {
|
|
|
2054
153
|
* (see: https://github.com/visgl/deck.gl/blob/401d624c0529faaa62125714c376b3ba3b8f379f/dev-docs/RFCs/v6.1/improved-lnglat-projection-rfc.md?plain=1#L29)
|
|
2055
154
|
*/
|
|
2056
155
|
float project_size_all_zoom_levels(float meters, float lat) {
|
|
2057
|
-
// We use
|
|
2058
|
-
if (
|
|
2059
|
-
return meters *
|
|
156
|
+
// We use project.scale = 4096 (2^12) which corresponds to zoom = 12
|
|
157
|
+
if (project.scale < 4096.0) {
|
|
158
|
+
return meters * project.commonUnitsPerMeter.z * project_size_at_latitude_low_zoom(lat);
|
|
2060
159
|
}
|
|
2061
160
|
return project_size(meters);
|
|
2062
161
|
}
|
|
@@ -2070,7 +169,7 @@ void main(void ) {
|
|
|
2070
169
|
// instanceArrowDistance: a float in interval [0,1] describing the initial position of the arrow along the full path between two substations (0: begin, 1.0 end)
|
|
2071
170
|
float distanceAlong =
|
|
2072
171
|
instanceLineDistance * instanceArrowDistance +
|
|
2073
|
-
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * timestamp * instanceSpeedFactor;
|
|
172
|
+
(instanceArrowDirection < 2.0 ? 1.0 : -1.0) * arrow.timestamp * instanceSpeedFactor;
|
|
2074
173
|
float arrowDistance = mod(distanceAlong, instanceLineDistance);
|
|
2075
174
|
if (arrowDistance < 0.0) {
|
|
2076
175
|
arrowDistance += instanceLineDistance;
|
|
@@ -2092,7 +191,7 @@ void main(void ) {
|
|
|
2092
191
|
vec3 linePosition2 = fetchLinePosition(linePoint);
|
|
2093
192
|
|
|
2094
193
|
// clamp to arrow size limits
|
|
2095
|
-
float sizePixels = clamp(project_size_to_pixel(instanceSize), sizeMinPixels, sizeMaxPixels);
|
|
194
|
+
float sizePixels = clamp(project_size_to_pixel(instanceSize), arrow.sizeMinPixels, arrow.sizeMaxPixels);
|
|
2096
195
|
|
|
2097
196
|
// project the 2 line points position to common space
|
|
2098
197
|
vec3 position64Low = vec3(0, 0, 0);
|
|
@@ -2105,8 +204,8 @@ void main(void ) {
|
|
|
2105
204
|
vec3 arrowPositionWorldSpace = mix(linePosition1, linePosition2, interpolationValue);
|
|
2106
205
|
float offsetCommonSpace = clamp(
|
|
2107
206
|
project_size_all_zoom_levels(instanceDistanceBetweenLines, arrowPositionWorldSpace.y),
|
|
2108
|
-
project_pixel_size(minParallelOffset),
|
|
2109
|
-
project_pixel_size(maxParallelOffset)
|
|
207
|
+
project_pixel_size(arrow.minParallelOffset),
|
|
208
|
+
project_pixel_size(arrow.maxParallelOffset)
|
|
2110
209
|
);
|
|
2111
210
|
|
|
2112
211
|
// calculate translation for the parallels lines, use the angle calculated from origin/destination
|
|
@@ -2147,12 +246,35 @@ void main(void ) {
|
|
|
2147
246
|
gl_Position = vertexPosition;
|
|
2148
247
|
|
|
2149
248
|
// arrow fill color for fragment shader
|
|
2150
|
-
vFillColor = vec4(instanceColor.rgb, opacity);
|
|
249
|
+
vFillColor = vec4(instanceColor.rgb, layer.opacity);
|
|
2151
250
|
shouldDiscard = 0.0;
|
|
2152
251
|
}
|
|
2153
252
|
}
|
|
2154
253
|
`;
|
|
2155
|
-
const
|
|
254
|
+
const arrowUniformBlock = `uniform arrowUniforms {
|
|
255
|
+
float sizeMinPixels;
|
|
256
|
+
float sizeMaxPixels;
|
|
257
|
+
float timestamp;
|
|
258
|
+
float maxParallelOffset;
|
|
259
|
+
float minParallelOffset;
|
|
260
|
+
highp ivec2 linePositionsTextureSize;
|
|
261
|
+
highp ivec2 lineDistancesTextureSize;
|
|
262
|
+
} arrow;
|
|
263
|
+
`;
|
|
264
|
+
const arrowUniforms = {
|
|
265
|
+
name: "arrow",
|
|
266
|
+
vs: arrowUniformBlock,
|
|
267
|
+
fs: arrowUniformBlock,
|
|
268
|
+
uniformTypes: {
|
|
269
|
+
sizeMinPixels: "f32",
|
|
270
|
+
sizeMaxPixels: "f32",
|
|
271
|
+
timestamp: "f32",
|
|
272
|
+
maxParallelOffset: "f32",
|
|
273
|
+
minParallelOffset: "f32",
|
|
274
|
+
linePositionsTextureSize: "vec2<i32>",
|
|
275
|
+
lineDistancesTextureSize: "vec2<i32>"
|
|
276
|
+
}
|
|
277
|
+
};
|
|
2156
278
|
const DEFAULT_COLOR = [0, 0, 0, 255];
|
|
2157
279
|
const MAX_LINE_POINT_COUNT = 2 ** 15;
|
|
2158
280
|
var ArrowDirection = /* @__PURE__ */ ((ArrowDirection2) => {
|
|
@@ -2184,29 +306,31 @@ const defaultProps$3 = {
|
|
|
2184
306
|
minParallelOffset: { type: "number", value: 3 }
|
|
2185
307
|
// opacity prop is handled at the layer level for visually proportional perception https://deck.gl/docs/api-reference/core/layer#opacity
|
|
2186
308
|
};
|
|
2187
|
-
|
|
309
|
+
class ArrowLayer extends core.Layer {
|
|
310
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
311
|
+
static layerName = "ArrowLayer";
|
|
312
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
313
|
+
static defaultProps = defaultProps$3;
|
|
2188
314
|
getShaders() {
|
|
2189
|
-
return super.getShaders({ vs, fs, modules: [core.project32, core.picking] });
|
|
315
|
+
return super.getShaders({ vs, fs, modules: [core.project32, core.picking, arrowUniforms] });
|
|
2190
316
|
}
|
|
2191
317
|
getArrowLineAttributes(arrow) {
|
|
2192
|
-
var _a;
|
|
2193
318
|
const line = this.props.getLine(arrow);
|
|
2194
319
|
if (!line) {
|
|
2195
320
|
throw new Error("Invalid line");
|
|
2196
321
|
}
|
|
2197
|
-
const attributes =
|
|
322
|
+
const attributes = this.state.lineAttributes?.get(line);
|
|
2198
323
|
if (!attributes) {
|
|
2199
324
|
throw new Error(`Line ${line.id} not found`);
|
|
2200
325
|
}
|
|
2201
326
|
return attributes;
|
|
2202
327
|
}
|
|
2203
328
|
initializeState({ device }) {
|
|
2204
|
-
var _a;
|
|
2205
329
|
const maxTextureSize = device.limits.maxTextureDimension2D;
|
|
2206
330
|
this.state = {
|
|
2207
331
|
maxTextureSize
|
|
2208
332
|
};
|
|
2209
|
-
|
|
333
|
+
this.getAttributeManager()?.addInstanced({
|
|
2210
334
|
instanceSize: {
|
|
2211
335
|
size: 1,
|
|
2212
336
|
type: "float32",
|
|
@@ -2329,13 +453,13 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2329
453
|
width,
|
|
2330
454
|
height,
|
|
2331
455
|
format,
|
|
2332
|
-
type: constants
|
|
456
|
+
type: constants.GL.FLOAT,
|
|
2333
457
|
data: new Float32Array(data),
|
|
2334
458
|
parameters: {
|
|
2335
|
-
[constants
|
|
2336
|
-
[constants
|
|
2337
|
-
[constants
|
|
2338
|
-
[constants
|
|
459
|
+
[constants.GL.TEXTURE_MAG_FILTER]: constants.GL.NEAREST,
|
|
460
|
+
[constants.GL.TEXTURE_MIN_FILTER]: constants.GL.NEAREST,
|
|
461
|
+
[constants.GL.TEXTURE_WRAP_S]: constants.GL.CLAMP_TO_EDGE,
|
|
462
|
+
[constants.GL.TEXTURE_WRAP_T]: constants.GL.CLAMP_TO_EDGE
|
|
2339
463
|
},
|
|
2340
464
|
mipmaps: false
|
|
2341
465
|
});
|
|
@@ -2362,8 +486,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2362
486
|
let linePointCount = 0;
|
|
2363
487
|
if (positions.length > 0) {
|
|
2364
488
|
positions.forEach((position) => {
|
|
2365
|
-
linePositionsTextureData.push(position[0]);
|
|
2366
|
-
linePositionsTextureData.push(position[1]);
|
|
489
|
+
linePositionsTextureData.push(position[0], position[1]);
|
|
2367
490
|
linePointCount++;
|
|
2368
491
|
});
|
|
2369
492
|
lineDistancesTextureData.push(...line.cumulativeDistances ?? []);
|
|
@@ -2388,7 +511,6 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2388
511
|
};
|
|
2389
512
|
}
|
|
2390
513
|
updateGeometry({ props, changeFlags }) {
|
|
2391
|
-
var _a;
|
|
2392
514
|
const geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getLinePositions);
|
|
2393
515
|
if (geometryChanged) {
|
|
2394
516
|
const { device } = this.context;
|
|
@@ -2413,12 +535,11 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2413
535
|
lineAttributes
|
|
2414
536
|
});
|
|
2415
537
|
if (!changeFlags.dataChanged) {
|
|
2416
|
-
|
|
538
|
+
this.getAttributeManager()?.invalidateAll();
|
|
2417
539
|
}
|
|
2418
540
|
}
|
|
2419
541
|
}
|
|
2420
542
|
updateModel({ changeFlags }) {
|
|
2421
|
-
var _a;
|
|
2422
543
|
if (changeFlags.somethingChanged) {
|
|
2423
544
|
const { device } = this.context;
|
|
2424
545
|
const { model } = this.state;
|
|
@@ -2428,7 +549,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2428
549
|
this.setState({
|
|
2429
550
|
model: this._getModel(device)
|
|
2430
551
|
});
|
|
2431
|
-
|
|
552
|
+
this.getAttributeManager()?.invalidateAll();
|
|
2432
553
|
}
|
|
2433
554
|
}
|
|
2434
555
|
updateState(updateParams) {
|
|
@@ -2456,9 +577,9 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2456
577
|
this.startAnimation();
|
|
2457
578
|
}
|
|
2458
579
|
startAnimation() {
|
|
2459
|
-
|
|
580
|
+
globalThis.requestAnimationFrame((timestamp) => this.animate(timestamp));
|
|
2460
581
|
}
|
|
2461
|
-
draw({
|
|
582
|
+
draw({ renderPass }) {
|
|
2462
583
|
const { sizeMinPixels, sizeMaxPixels } = this.props;
|
|
2463
584
|
const {
|
|
2464
585
|
model,
|
|
@@ -2473,20 +594,16 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2473
594
|
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2474
595
|
lineDistancesTexture
|
|
2475
596
|
});
|
|
2476
|
-
|
|
2477
|
-
...uniforms,
|
|
597
|
+
const arrow = {
|
|
2478
598
|
sizeMinPixels,
|
|
2479
599
|
sizeMaxPixels,
|
|
2480
|
-
|
|
2481
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2482
|
-
linePositionsTextureSize: [linePositionsTexture.width, linePositionsTexture.height],
|
|
2483
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2484
|
-
lineDistancesTextureSize: [lineDistancesTexture.width, lineDistancesTexture.height],
|
|
2485
|
-
// @ts-expect-error TODO TS2339: Properties width and height does not exists on type Texture2D
|
|
2486
|
-
timestamp,
|
|
600
|
+
timestamp: timestamp || 0,
|
|
2487
601
|
maxParallelOffset: this.props.maxParallelOffset,
|
|
2488
|
-
minParallelOffset: this.props.minParallelOffset
|
|
2489
|
-
|
|
602
|
+
minParallelOffset: this.props.minParallelOffset,
|
|
603
|
+
linePositionsTextureSize: [linePositionsTexture.width, linePositionsTexture.height],
|
|
604
|
+
lineDistancesTextureSize: [lineDistancesTexture.width, lineDistancesTexture.height]
|
|
605
|
+
};
|
|
606
|
+
model.shaderInputs.setProps({ arrow });
|
|
2490
607
|
model.draw(renderPass);
|
|
2491
608
|
}
|
|
2492
609
|
_getModel(device) {
|
|
@@ -2510,10 +627,7 @@ const _ArrowLayer = class _ArrowLayer extends core.Layer {
|
|
|
2510
627
|
})
|
|
2511
628
|
);
|
|
2512
629
|
}
|
|
2513
|
-
}
|
|
2514
|
-
_ArrowLayer.layerName = "ArrowLayer";
|
|
2515
|
-
_ArrowLayer.defaultProps = defaultProps$3;
|
|
2516
|
-
let ArrowLayer = _ArrowLayer;
|
|
630
|
+
}
|
|
2517
631
|
const substationPositionByIdIndexer = (map, substation) => {
|
|
2518
632
|
map.set(substation.id, substation.coordinate);
|
|
2519
633
|
return map;
|
|
@@ -2523,14 +637,17 @@ const linePositionByIdIndexer = (map, line) => {
|
|
|
2523
637
|
return map;
|
|
2524
638
|
};
|
|
2525
639
|
class GeoData {
|
|
640
|
+
substationPositionsById = /* @__PURE__ */ new Map();
|
|
641
|
+
linePositionsById = /* @__PURE__ */ new Map();
|
|
2526
642
|
constructor(substationPositionsById, linePositionsById) {
|
|
2527
|
-
this.substationPositionsById = /* @__PURE__ */ new Map();
|
|
2528
|
-
this.linePositionsById = /* @__PURE__ */ new Map();
|
|
2529
643
|
this.substationPositionsById = substationPositionsById;
|
|
2530
644
|
this.linePositionsById = linePositionsById;
|
|
2531
645
|
}
|
|
2532
646
|
setSubstationPositions(positions) {
|
|
2533
|
-
this.substationPositionsById = positions.reduce(
|
|
647
|
+
this.substationPositionsById = positions.reduce(
|
|
648
|
+
(map, substation) => substationPositionByIdIndexer(map, substation),
|
|
649
|
+
/* @__PURE__ */ new Map()
|
|
650
|
+
);
|
|
2534
651
|
}
|
|
2535
652
|
updateSubstationPositions(substationIdsToUpdate, fetchedPositions) {
|
|
2536
653
|
fetchedPositions.forEach((pos) => this.substationPositionsById.set(pos.id, pos.coordinate));
|
|
@@ -2545,7 +662,7 @@ class GeoData {
|
|
|
2545
662
|
return [position.lon, position.lat];
|
|
2546
663
|
}
|
|
2547
664
|
setLinePositions(positions) {
|
|
2548
|
-
this.linePositionsById = positions.reduce(linePositionByIdIndexer, /* @__PURE__ */ new Map());
|
|
665
|
+
this.linePositionsById = positions.reduce((map, line) => linePositionByIdIndexer(map, line), /* @__PURE__ */ new Map());
|
|
2549
666
|
}
|
|
2550
667
|
updateLinePositions(lineIdsToUpdate, fetchedPositions) {
|
|
2551
668
|
fetchedPositions.forEach((pos) => {
|
|
@@ -2629,10 +746,13 @@ class GeoData {
|
|
|
2629
746
|
if (arrowPosition > 1 || arrowPosition < 0) {
|
|
2630
747
|
throw new Error("Proportional position value incorrect: " + arrowPosition);
|
|
2631
748
|
}
|
|
2632
|
-
if (cumulativeDistances === null || cumulativeDistances.length < 2 || cumulativeDistances
|
|
749
|
+
if (cumulativeDistances === null || cumulativeDistances.length < 2 || cumulativeDistances.at(-1) === 0) {
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
const lineDistance = cumulativeDistances.at(-1);
|
|
753
|
+
if (lineDistance === void 0) {
|
|
2633
754
|
return null;
|
|
2634
755
|
}
|
|
2635
|
-
const lineDistance = cumulativeDistances[cumulativeDistances.length - 1];
|
|
2636
756
|
let wantedDistance = lineDistance * arrowPosition;
|
|
2637
757
|
if (cumulativeDistances.length === 2) {
|
|
2638
758
|
wantedDistance = wantedDistance - 2 * distanceBetweenLines * arrowPosition * proximityFactor;
|
|
@@ -2656,17 +776,17 @@ class GeoData {
|
|
|
2656
776
|
const angle = this.getMapAngle(goodSegment.segment[0], goodSegment.segment[1]);
|
|
2657
777
|
const neededOffset = this.getLabelOffset(angle, 20, arrowDirection);
|
|
2658
778
|
const position = {
|
|
2659
|
-
position:
|
|
779
|
+
position: geolib.computeDestinationPoint(goodSegment.segment[0], remainingDistance, angle),
|
|
2660
780
|
angle,
|
|
2661
781
|
offset: neededOffset
|
|
2662
782
|
};
|
|
2663
|
-
position.position =
|
|
783
|
+
position.position = geolib.computeDestinationPoint(
|
|
2664
784
|
position.position,
|
|
2665
785
|
distanceBetweenLines * lineParallelIndex,
|
|
2666
786
|
lineAngle + 90
|
|
2667
787
|
);
|
|
2668
788
|
if (cumulativeDistances.length === 2) {
|
|
2669
|
-
position.position =
|
|
789
|
+
position.position = geolib.computeDestinationPoint(
|
|
2670
790
|
position.position,
|
|
2671
791
|
-distanceBetweenLines * proximityFactor,
|
|
2672
792
|
lineAngle
|
|
@@ -2681,7 +801,7 @@ class GeoData {
|
|
|
2681
801
|
labelDistanceInSegment = remainingDistance;
|
|
2682
802
|
}
|
|
2683
803
|
const labelPercentage = labelDistanceInSegment / segmentDistance;
|
|
2684
|
-
position.position =
|
|
804
|
+
position.position = geolib.computeDestinationPoint(
|
|
2685
805
|
position.position,
|
|
2686
806
|
distanceBetweenLines * labelPercentage,
|
|
2687
807
|
proximityAngle
|
|
@@ -2700,7 +820,6 @@ class GeoData {
|
|
|
2700
820
|
direction = -1;
|
|
2701
821
|
break;
|
|
2702
822
|
case ArrowDirection.NONE:
|
|
2703
|
-
direction = 0;
|
|
2704
823
|
break;
|
|
2705
824
|
default:
|
|
2706
825
|
throw new Error("impossible");
|
|
@@ -2712,8 +831,8 @@ class GeoData {
|
|
|
2712
831
|
}
|
|
2713
832
|
//returns the angle between point1 and point2 in degrees [0-360)
|
|
2714
833
|
getMapAngle(point1, point2) {
|
|
2715
|
-
let angle =
|
|
2716
|
-
const angle2 =
|
|
834
|
+
let angle = geolib.getRhumbLineBearing(point1, point2);
|
|
835
|
+
const angle2 = geolib.getGreatCircleBearing(point1, point2);
|
|
2717
836
|
const coeff = 0.1;
|
|
2718
837
|
angle = coeff * angle + (1 - coeff) * angle2;
|
|
2719
838
|
return angle;
|
|
@@ -2742,6 +861,28 @@ const INVALID_FLOW_OPACITY = 0.2;
|
|
|
2742
861
|
const SUBSTATION_RADIUS = 500;
|
|
2743
862
|
const SUBSTATION_RADIUS_MAX_PIXEL = 5;
|
|
2744
863
|
const SUBSTATION_RADIUS_MIN_PIXEL = 1;
|
|
864
|
+
const forkLineUniformBlock = `uniform forkLineUniforms {
|
|
865
|
+
float distanceBetweenLines;
|
|
866
|
+
float maxParallelOffset;
|
|
867
|
+
float minParallelOffset;
|
|
868
|
+
float substationRadius;
|
|
869
|
+
float substationMaxPixel;
|
|
870
|
+
float minSubstationRadiusPixel;
|
|
871
|
+
} forkLine;
|
|
872
|
+
`;
|
|
873
|
+
const forkLineUniforms = {
|
|
874
|
+
name: "forkLine",
|
|
875
|
+
vs: forkLineUniformBlock,
|
|
876
|
+
fs: forkLineUniformBlock,
|
|
877
|
+
uniformTypes: {
|
|
878
|
+
distanceBetweenLines: "f32",
|
|
879
|
+
maxParallelOffset: "f32",
|
|
880
|
+
minParallelOffset: "f32",
|
|
881
|
+
substationRadius: "f32",
|
|
882
|
+
substationMaxPixel: "f32",
|
|
883
|
+
minSubstationRadiusPixel: "f32"
|
|
884
|
+
}
|
|
885
|
+
};
|
|
2745
886
|
const defaultProps$2 = {
|
|
2746
887
|
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2747
888
|
getLineAngle: { type: "accessor", value: 0 },
|
|
@@ -2752,7 +893,11 @@ const defaultProps$2 = {
|
|
|
2752
893
|
substationMaxPixel: { type: "number", value: 5 },
|
|
2753
894
|
minSubstationRadiusPixel: { type: "number", value: 1 }
|
|
2754
895
|
};
|
|
2755
|
-
|
|
896
|
+
class ForkLineLayer extends layers.LineLayer {
|
|
897
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
898
|
+
static layerName = "ForkLineLayer";
|
|
899
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
900
|
+
static defaultProps = defaultProps$2;
|
|
2756
901
|
getShaders() {
|
|
2757
902
|
const shaders = super.getShaders();
|
|
2758
903
|
shaders.inject = {
|
|
@@ -2761,39 +906,44 @@ in float instanceLineParallelIndex;
|
|
|
2761
906
|
in float instanceLineAngle;
|
|
2762
907
|
in float instanceOffsetStart;
|
|
2763
908
|
in float instanceProximityFactor;
|
|
2764
|
-
uniform float distanceBetweenLines;
|
|
2765
|
-
uniform float maxParallelOffset;
|
|
2766
|
-
uniform float minParallelOffset;
|
|
2767
|
-
uniform float substationRadius;
|
|
2768
|
-
uniform float substationMaxPixel;
|
|
2769
|
-
uniform float minSubstationRadiusPixel;
|
|
2770
909
|
`,
|
|
2771
910
|
"float segmentIndex = positions.x": `;
|
|
2772
|
-
target = source
|
|
2773
|
-
|
|
911
|
+
target = source;
|
|
912
|
+
target_commonspace = source_commonspace;
|
|
913
|
+
|
|
914
|
+
float offsetPixels = clamp(project_size_to_pixel(forkLine.distanceBetweenLines), forkLine.minParallelOffset, forkLine.maxParallelOffset);
|
|
2774
915
|
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2775
916
|
|
|
2776
|
-
float offsetSubstation = clamp(
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
917
|
+
float offsetSubstation = clamp(
|
|
918
|
+
project_size_to_pixel(forkLine.substationRadius * instanceOffsetStart),
|
|
919
|
+
forkLine.minSubstationRadiusPixel,
|
|
920
|
+
forkLine.substationMaxPixel * instanceOffsetStart
|
|
921
|
+
);
|
|
922
|
+
float offsetSubstationCommonSpace = project_pixel_size(offsetSubstation);
|
|
2780
923
|
|
|
2781
|
-
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle
|
|
924
|
+
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle), 0.0, 0.0) * instanceLineParallelIndex;
|
|
2782
925
|
|
|
2783
926
|
trans.x -= sin(instanceLineAngle) * instanceProximityFactor;
|
|
2784
927
|
trans.y -= cos(instanceLineAngle) * instanceProximityFactor;
|
|
2785
928
|
|
|
2786
|
-
|
|
2787
|
-
|
|
929
|
+
float transLen = max(1e-6, length(trans.xy));
|
|
930
|
+
vec4 transTargetCommon = trans * offsetCommonSpace;
|
|
931
|
+
vec4 transSourceCommon = trans * (offsetSubstationCommonSpace / transLen);
|
|
932
|
+
|
|
933
|
+
source_commonspace += transSourceCommon;
|
|
934
|
+
target_commonspace += transTargetCommon;
|
|
935
|
+
|
|
936
|
+
source += project_common_position_to_clipspace(transSourceCommon) - project.center;
|
|
937
|
+
target += project_common_position_to_clipspace(transTargetCommon) - project.center;
|
|
2788
938
|
|
|
2789
939
|
`
|
|
2790
940
|
};
|
|
941
|
+
shaders.modules.push(forkLineUniforms);
|
|
2791
942
|
return shaders;
|
|
2792
943
|
}
|
|
2793
944
|
initializeState() {
|
|
2794
|
-
var _a;
|
|
2795
945
|
super.initializeState();
|
|
2796
|
-
|
|
946
|
+
this.getAttributeManager()?.addInstanced({
|
|
2797
947
|
instanceLineParallelIndex: {
|
|
2798
948
|
size: 1,
|
|
2799
949
|
type: "float32",
|
|
@@ -2818,22 +968,35 @@ uniform float minSubstationRadiusPixel;
|
|
|
2818
968
|
}
|
|
2819
969
|
// TODO find the full type for record values
|
|
2820
970
|
draw({ uniforms }) {
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
});
|
|
971
|
+
const model = this.state.model;
|
|
972
|
+
const forkLine = {
|
|
973
|
+
distanceBetweenLines: this.props.getDistanceBetweenLines,
|
|
974
|
+
maxParallelOffset: this.props.getMaxParallelOffset,
|
|
975
|
+
minParallelOffset: this.props.getMinParallelOffset,
|
|
976
|
+
substationRadius: this.props.getSubstationRadius,
|
|
977
|
+
substationMaxPixel: this.props.getSubstationMaxPixel,
|
|
978
|
+
minSubstationRadiusPixel: this.props.getMinSubstationRadiusPixel
|
|
979
|
+
};
|
|
980
|
+
model.shaderInputs.setProps({ forkLine });
|
|
981
|
+
super.draw({ uniforms });
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
const parallelPathUniformBlock = `uniform parallelPathUniforms {
|
|
985
|
+
float distanceBetweenLines;
|
|
986
|
+
float maxParallelOffset;
|
|
987
|
+
float minParallelOffset;
|
|
988
|
+
} parallelPath;
|
|
989
|
+
`;
|
|
990
|
+
const parallelPathUniforms = {
|
|
991
|
+
name: "parallelPath",
|
|
992
|
+
vs: parallelPathUniformBlock,
|
|
993
|
+
fs: parallelPathUniformBlock,
|
|
994
|
+
uniformTypes: {
|
|
995
|
+
distanceBetweenLines: "f32",
|
|
996
|
+
maxParallelOffset: "f32",
|
|
997
|
+
minParallelOffset: "f32"
|
|
2832
998
|
}
|
|
2833
999
|
};
|
|
2834
|
-
_ForkLineLayer.layerName = "ForkLineLayer";
|
|
2835
|
-
_ForkLineLayer.defaultProps = defaultProps$2;
|
|
2836
|
-
let ForkLineLayer = _ForkLineLayer;
|
|
2837
1000
|
const defaultProps$1 = {
|
|
2838
1001
|
getLineParallelIndex: { type: "accessor", value: 0 },
|
|
2839
1002
|
getLineAngle: { type: "accessor", value: 0 },
|
|
@@ -2841,11 +1004,16 @@ const defaultProps$1 = {
|
|
|
2841
1004
|
maxParallelOffset: { type: "number", value: 100 },
|
|
2842
1005
|
minParallelOffset: { type: "number", value: 3 }
|
|
2843
1006
|
};
|
|
2844
|
-
|
|
1007
|
+
class ParallelPathLayer extends layers.PathLayer {
|
|
1008
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1009
|
+
static layerName = "ParallelPathLayer";
|
|
1010
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1011
|
+
static defaultProps = defaultProps$1;
|
|
2845
1012
|
getShaders() {
|
|
2846
1013
|
const shaders = super.getShaders();
|
|
2847
|
-
shaders.inject =
|
|
2848
|
-
|
|
1014
|
+
shaders.inject = {
|
|
1015
|
+
...shaders.inject,
|
|
1016
|
+
"vs:#decl": `//Note: with the following attribute, we have reached the limit (16 on most platforms) of the number of attributes.
|
|
2849
1017
|
// with webgl2, this might be raised in the future to 32 on most platforms...
|
|
2850
1018
|
// The PathLayer that this class extends already uses 13 attributes (and 15 with the dash extension).
|
|
2851
1019
|
// we have packed all our attributes together in a single attribute to
|
|
@@ -2868,11 +1036,8 @@ const _ParallelPathLayer = class _ParallelPathLayer extends layers.PathLayer {
|
|
|
2868
1036
|
// only its buffer, so it hurts performance a bit in this case.
|
|
2869
1037
|
// But this is a rare case for us (changing parameters) so it doesn't matter much.
|
|
2870
1038
|
in vec4 instanceExtraAttributes;
|
|
2871
|
-
uniform float distanceBetweenLines;
|
|
2872
|
-
uniform float maxParallelOffset;
|
|
2873
|
-
uniform float minParallelOffset;
|
|
2874
1039
|
`,
|
|
2875
|
-
"vs:#main-end":
|
|
1040
|
+
"vs:#main-end": `
|
|
2876
1041
|
bool isSegmentEnd = isEnd > EPSILON;
|
|
2877
1042
|
bool isFirstSegment = (instanceTypes == 1.0 || instanceTypes == 3.0);
|
|
2878
1043
|
bool isLastSegment = (instanceTypes == 2.0 || instanceTypes == 3.0);
|
|
@@ -2886,7 +1051,7 @@ else if ( isSegmentEnd && isLastSegment){
|
|
|
2886
1051
|
}
|
|
2887
1052
|
float instanceLineParallelIndex = (mod(instanceExtraAttributes[3], 64.0) - 31.0) / 2.0;
|
|
2888
1053
|
|
|
2889
|
-
float offsetPixels = clamp(project_size_to_pixel(distanceBetweenLines), minParallelOffset, maxParallelOffset);
|
|
1054
|
+
float offsetPixels = clamp(project_size_to_pixel(parallelPath.distanceBetweenLines), parallelPath.minParallelOffset, parallelPath.maxParallelOffset);
|
|
2890
1055
|
float offsetCommonSpace = project_pixel_size(offsetPixels);
|
|
2891
1056
|
vec4 trans = vec4(cos(instanceLineAngle), -sin(instanceLineAngle), 0, 0.) * instanceLineParallelIndex;
|
|
2892
1057
|
|
|
@@ -2903,15 +1068,16 @@ else if (!isSegmentEnd && isFirstSegment)
|
|
|
2903
1068
|
}
|
|
2904
1069
|
|
|
2905
1070
|
trans = trans * offsetCommonSpace;
|
|
2906
|
-
|
|
1071
|
+
geometry.position += trans;
|
|
1072
|
+
gl_Position += project_common_position_to_clipspace(trans) - project.center;
|
|
2907
1073
|
`
|
|
2908
|
-
}
|
|
1074
|
+
};
|
|
1075
|
+
shaders.modules.push(parallelPathUniforms);
|
|
2909
1076
|
return shaders;
|
|
2910
1077
|
}
|
|
2911
1078
|
initializeState() {
|
|
2912
|
-
var _a;
|
|
2913
1079
|
super.initializeState();
|
|
2914
|
-
|
|
1080
|
+
this.getAttributeManager()?.addInstanced({
|
|
2915
1081
|
// too much instances variables need to compact some...
|
|
2916
1082
|
instanceExtraAttributes: {
|
|
2917
1083
|
size: 4,
|
|
@@ -2921,19 +1087,16 @@ gl_Position += project_common_position_to_clipspace(trans) - project_uCenter;
|
|
|
2921
1087
|
});
|
|
2922
1088
|
}
|
|
2923
1089
|
draw({ uniforms }) {
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
});
|
|
1090
|
+
const model = this.state.model;
|
|
1091
|
+
const parallelPath = {
|
|
1092
|
+
distanceBetweenLines: this.props.distanceBetweenLines,
|
|
1093
|
+
maxParallelOffset: this.props.maxParallelOffset,
|
|
1094
|
+
minParallelOffset: this.props.minParallelOffset
|
|
1095
|
+
};
|
|
1096
|
+
model.shaderInputs.setProps({ parallelPath });
|
|
1097
|
+
super.draw({ uniforms });
|
|
2932
1098
|
}
|
|
2933
|
-
}
|
|
2934
|
-
_ParallelPathLayer.layerName = "ParallelPathLayer";
|
|
2935
|
-
_ParallelPathLayer.defaultProps = defaultProps$1;
|
|
2936
|
-
let ParallelPathLayer = _ParallelPathLayer;
|
|
1099
|
+
}
|
|
2937
1100
|
const DISTANCE_BETWEEN_ARROWS = 1e4;
|
|
2938
1101
|
const START_ARROW_POSITION = 0.1;
|
|
2939
1102
|
const END_ARROW_POSITION = 0.9;
|
|
@@ -2978,9 +1141,8 @@ function getLineLoadingZoneOfSide(limit, intensity, lineFlowAlertThreshold) {
|
|
|
2978
1141
|
}
|
|
2979
1142
|
}
|
|
2980
1143
|
function getLineLoadingZone(line, lineFlowAlertThreshold) {
|
|
2981
|
-
|
|
2982
|
-
const
|
|
2983
|
-
const zone2 = getLineLoadingZoneOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2, lineFlowAlertThreshold);
|
|
1144
|
+
const zone1 = getLineLoadingZoneOfSide(line.currentLimits1?.permanentLimit, line.i1, lineFlowAlertThreshold);
|
|
1145
|
+
const zone2 = getLineLoadingZoneOfSide(line.currentLimits2?.permanentLimit, line.i2, lineFlowAlertThreshold);
|
|
2984
1146
|
return Math.max(zone1, zone2);
|
|
2985
1147
|
}
|
|
2986
1148
|
function getLineLoadingZoneColor(zone) {
|
|
@@ -3010,9 +1172,12 @@ function getLineColor(line, nominalVoltageColor, props, lineConnection) {
|
|
|
3010
1172
|
return nominalVoltageColor;
|
|
3011
1173
|
}
|
|
3012
1174
|
}
|
|
1175
|
+
function getIconFromLineStatus(lineStatus) {
|
|
1176
|
+
return STATUS_ICONS[lineStatus] ?? "";
|
|
1177
|
+
}
|
|
3013
1178
|
function getLineIcon(lineStatus) {
|
|
3014
1179
|
return {
|
|
3015
|
-
url: lineStatus
|
|
1180
|
+
url: getIconFromLineStatus(lineStatus),
|
|
3016
1181
|
height: 24,
|
|
3017
1182
|
width: 24,
|
|
3018
1183
|
mask: true
|
|
@@ -3021,22 +1186,19 @@ function getLineIcon(lineStatus) {
|
|
|
3021
1186
|
function getArrowSpeedOfSide(limit, intensity) {
|
|
3022
1187
|
if (limit === void 0 || intensity === void 0 || intensity === 0) {
|
|
3023
1188
|
return 0;
|
|
1189
|
+
} else if (intensity > 0 && intensity < limit / 3) {
|
|
1190
|
+
return 1;
|
|
1191
|
+
} else if (intensity >= limit / 3 && intensity < limit * 2 / 3) {
|
|
1192
|
+
return 2;
|
|
1193
|
+
} else if (intensity >= limit * 2 / 3 && intensity < limit) {
|
|
1194
|
+
return 3;
|
|
3024
1195
|
} else {
|
|
3025
|
-
|
|
3026
|
-
return 1;
|
|
3027
|
-
} else if (intensity >= limit / 3 && intensity < limit * 2 / 3) {
|
|
3028
|
-
return 2;
|
|
3029
|
-
} else if (intensity >= limit * 2 / 3 && intensity < limit) {
|
|
3030
|
-
return 3;
|
|
3031
|
-
} else {
|
|
3032
|
-
return 4;
|
|
3033
|
-
}
|
|
1196
|
+
return 4;
|
|
3034
1197
|
}
|
|
3035
1198
|
}
|
|
3036
1199
|
function getArrowSpeed(line) {
|
|
3037
|
-
|
|
3038
|
-
const
|
|
3039
|
-
const speed2 = getArrowSpeedOfSide((_b = line.currentLimits2) == null ? void 0 : _b.permanentLimit, line.i2);
|
|
1200
|
+
const speed1 = getArrowSpeedOfSide(line.currentLimits1?.permanentLimit, line.i1);
|
|
1201
|
+
const speed2 = getArrowSpeedOfSide(line.currentLimits2?.permanentLimit, line.i2);
|
|
3040
1202
|
return Math.max(speed1, speed2);
|
|
3041
1203
|
}
|
|
3042
1204
|
function getArrowSpeedFactor(speed) {
|
|
@@ -3055,7 +1217,53 @@ function getArrowSpeedFactor(speed) {
|
|
|
3055
1217
|
throw new Error("Unknown arrow speed: " + speed);
|
|
3056
1218
|
}
|
|
3057
1219
|
}
|
|
3058
|
-
const
|
|
1220
|
+
const STATUS_ICONS = {
|
|
1221
|
+
[
|
|
1222
|
+
"PLANNED_OUTAGE"
|
|
1223
|
+
/* PLANNED_OUTAGE */
|
|
1224
|
+
]: PadlockIcon,
|
|
1225
|
+
[
|
|
1226
|
+
"FORCED_OUTAGE"
|
|
1227
|
+
/* FORCED_OUTAGE */
|
|
1228
|
+
]: BoltIcon,
|
|
1229
|
+
[
|
|
1230
|
+
"IN_OPERATION"
|
|
1231
|
+
/* IN_OPERATION */
|
|
1232
|
+
]: ""
|
|
1233
|
+
};
|
|
1234
|
+
class LineLayer extends core.CompositeLayer {
|
|
1235
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1236
|
+
static layerName = "LineLayer";
|
|
1237
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
1238
|
+
static defaultProps = {
|
|
1239
|
+
network: void 0,
|
|
1240
|
+
geoData: void 0,
|
|
1241
|
+
getNominalVoltageColor: {
|
|
1242
|
+
type: "accessor",
|
|
1243
|
+
value: () => [255, 255, 255]
|
|
1244
|
+
/*getNominalVoltageColor*/
|
|
1245
|
+
},
|
|
1246
|
+
disconnectedLineColor: { type: "color", value: [255, 255, 255] },
|
|
1247
|
+
filteredNominalVoltages: void 0,
|
|
1248
|
+
lineFlowMode: "feeders",
|
|
1249
|
+
lineFlowColorMode: "nominalVoltage",
|
|
1250
|
+
lineFlowAlertThreshold: 100,
|
|
1251
|
+
showLineFlow: true,
|
|
1252
|
+
lineFullPath: true,
|
|
1253
|
+
lineParallelPath: true,
|
|
1254
|
+
labelSize: 12,
|
|
1255
|
+
iconSize: 48,
|
|
1256
|
+
distanceBetweenLines: 1e3,
|
|
1257
|
+
maxParallelOffset: 100,
|
|
1258
|
+
minParallelOffset: 3,
|
|
1259
|
+
substationRadius: { type: "number", value: SUBSTATION_RADIUS },
|
|
1260
|
+
substationMaxPixel: { type: "number", value: SUBSTATION_RADIUS_MAX_PIXEL },
|
|
1261
|
+
minSubstationRadiusPixel: {
|
|
1262
|
+
type: "number",
|
|
1263
|
+
value: SUBSTATION_RADIUS_MIN_PIXEL
|
|
1264
|
+
},
|
|
1265
|
+
labelColor: [255, 255, 255]
|
|
1266
|
+
};
|
|
3059
1267
|
initializeState(context) {
|
|
3060
1268
|
super.initializeState(context);
|
|
3061
1269
|
this.state = {
|
|
@@ -3067,15 +1275,15 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3067
1275
|
getVoltageLevelIndex(voltageLevelId) {
|
|
3068
1276
|
const { network } = this.props;
|
|
3069
1277
|
const vl = network.getVoltageLevel(voltageLevelId);
|
|
3070
|
-
const substation = network.getSubstation(vl
|
|
1278
|
+
const substation = network.getSubstation(vl?.substationId);
|
|
3071
1279
|
return [
|
|
3072
1280
|
...new Set(
|
|
3073
|
-
substation
|
|
1281
|
+
substation?.voltageLevels.map((vl2) => vl2.nominalV)
|
|
3074
1282
|
// only one voltage level
|
|
3075
1283
|
)
|
|
3076
1284
|
].sort((a, b) => {
|
|
3077
1285
|
return a - b;
|
|
3078
|
-
}).indexOf(vl
|
|
1286
|
+
}).indexOf(vl?.nominalV) + 1;
|
|
3079
1287
|
}
|
|
3080
1288
|
//TODO this is a huge function, refactor
|
|
3081
1289
|
updateState({ props, oldProps, changeFlags }) {
|
|
@@ -3086,34 +1294,33 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3086
1294
|
compositeData = [];
|
|
3087
1295
|
linesConnection = /* @__PURE__ */ new Map();
|
|
3088
1296
|
linesStatus = /* @__PURE__ */ new Map();
|
|
3089
|
-
if (props.network
|
|
1297
|
+
if (props.network?.substations && props.data.length !== 0 && props.geoData != null) {
|
|
3090
1298
|
const lineNominalVoltageIndexer = (map, line) => {
|
|
3091
1299
|
const network = props.network;
|
|
3092
1300
|
const vl1 = network.getVoltageLevel(line.voltageLevelId1);
|
|
3093
1301
|
const vl2 = network.getVoltageLevel(line.voltageLevelId2);
|
|
3094
1302
|
const vl = vl1 || vl2;
|
|
3095
|
-
let list = map.get(vl
|
|
1303
|
+
let list = map.get(vl?.nominalV);
|
|
3096
1304
|
if (!list) {
|
|
3097
1305
|
list = [];
|
|
3098
|
-
map.set(vl
|
|
1306
|
+
map.set(vl?.nominalV, list);
|
|
3099
1307
|
}
|
|
3100
|
-
if (
|
|
1308
|
+
if (vl1?.substationId !== vl2?.substationId) {
|
|
3101
1309
|
list.push(line);
|
|
3102
1310
|
}
|
|
3103
1311
|
return map;
|
|
3104
1312
|
};
|
|
3105
1313
|
const linesByNominalVoltage = props.data.reduce(
|
|
3106
|
-
lineNominalVoltageIndexer,
|
|
1314
|
+
(map, line) => lineNominalVoltageIndexer(map, line),
|
|
3107
1315
|
/* @__PURE__ */ new Map()
|
|
3108
1316
|
);
|
|
3109
1317
|
compositeData = Array.from(linesByNominalVoltage.entries()).map((e) => {
|
|
3110
1318
|
return { nominalV: e[0], lines: e[1] };
|
|
3111
1319
|
}).sort((a, b) => b.nominalV - a.nominalV);
|
|
3112
1320
|
compositeData.forEach((compositeData2) => {
|
|
3113
|
-
var _a;
|
|
3114
1321
|
const mapOriginDestination = /* @__PURE__ */ new Map();
|
|
3115
1322
|
compositeData2.mapOriginDestination = mapOriginDestination;
|
|
3116
|
-
|
|
1323
|
+
compositeData2.lines?.forEach((line) => {
|
|
3117
1324
|
linesConnection.set(line.id, {
|
|
3118
1325
|
terminal1Connected: line.terminal1Connected,
|
|
3119
1326
|
terminal2Connected: line.terminal2Connected
|
|
@@ -3152,9 +1359,8 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3152
1359
|
}
|
|
3153
1360
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || oldProps.geoData !== props.geoData)) {
|
|
3154
1361
|
compositeData.forEach((compositeData2) => {
|
|
3155
|
-
var _a;
|
|
3156
1362
|
const lineMap = /* @__PURE__ */ new Map();
|
|
3157
|
-
|
|
1363
|
+
compositeData2.lines?.forEach((line) => {
|
|
3158
1364
|
const positions = props.geoData.getLinePositions(props.network, line, props.lineFullPath);
|
|
3159
1365
|
const cumulativeDistances = props.geoData.getLineDistances(positions);
|
|
3160
1366
|
lineMap.set(line.id, {
|
|
@@ -3172,16 +1378,14 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3172
1378
|
}
|
|
3173
1379
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
3174
1380
|
compositeData.forEach((compositeData2) => {
|
|
3175
|
-
var _a;
|
|
3176
1381
|
compositeData2.activePower = [];
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
const lineData = (_a2 = compositeData2.lineMap) == null ? void 0 : _a2.get(line.id);
|
|
1382
|
+
compositeData2.lines?.forEach((line) => {
|
|
1383
|
+
const lineData = compositeData2.lineMap?.get(line.id);
|
|
3180
1384
|
const arrowDirection = getArrowDirection(line.p1);
|
|
3181
1385
|
const coordinates1 = props.geoData.labelDisplayPosition(
|
|
3182
1386
|
// @ts-expect-error TODO: manage undefined case
|
|
3183
|
-
lineData
|
|
3184
|
-
lineData
|
|
1387
|
+
lineData?.positions,
|
|
1388
|
+
lineData?.cumulativeDistances,
|
|
3185
1389
|
START_ARROW_POSITION,
|
|
3186
1390
|
arrowDirection,
|
|
3187
1391
|
line.parallelIndex,
|
|
@@ -3194,8 +1398,8 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3194
1398
|
);
|
|
3195
1399
|
const coordinates2 = props.geoData.labelDisplayPosition(
|
|
3196
1400
|
// @ts-expect-error TODO: manage undefined case
|
|
3197
|
-
lineData
|
|
3198
|
-
lineData
|
|
1401
|
+
lineData?.positions,
|
|
1402
|
+
lineData?.cumulativeDistances,
|
|
3199
1403
|
END_ARROW_POSITION,
|
|
3200
1404
|
arrowDirection,
|
|
3201
1405
|
line.parallelIndex,
|
|
@@ -3207,35 +1411,35 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3207
1411
|
line.proximityFactorEnd
|
|
3208
1412
|
);
|
|
3209
1413
|
if (coordinates1 !== null && coordinates2 !== null) {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
1414
|
+
compositeData2.activePower?.push(
|
|
1415
|
+
{
|
|
1416
|
+
line,
|
|
1417
|
+
p: line.p1,
|
|
1418
|
+
printPosition: [coordinates1.position.longitude, coordinates1.position.latitude],
|
|
1419
|
+
offset: coordinates1.offset
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
line,
|
|
1423
|
+
p: line.p2,
|
|
1424
|
+
printPosition: [coordinates2.position.longitude, coordinates2.position.latitude],
|
|
1425
|
+
offset: coordinates2.offset
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
3222
1428
|
}
|
|
3223
1429
|
});
|
|
3224
1430
|
});
|
|
3225
1431
|
}
|
|
3226
1432
|
if (changeFlags.dataChanged || changeFlags.propsChanged && (props.updatedLines !== oldProps.updatedLines || oldProps.lineFullPath !== props.lineFullPath || props.lineParallelPath !== oldProps.lineParallelPath || props.geoData !== oldProps.geoData)) {
|
|
3227
1433
|
compositeData.forEach((compositeData2) => {
|
|
3228
|
-
var _a;
|
|
3229
1434
|
compositeData2.operatingStatus = [];
|
|
3230
|
-
|
|
3231
|
-
var _a2, _b;
|
|
1435
|
+
compositeData2.lines?.forEach((line) => {
|
|
3232
1436
|
const lineStatus = linesStatus.get(line.id);
|
|
3233
|
-
if (
|
|
3234
|
-
const lineData =
|
|
1437
|
+
if (lineStatus?.operatingStatus !== void 0 && lineStatus.operatingStatus !== "IN_OPERATION") {
|
|
1438
|
+
const lineData = compositeData2.lineMap?.get(line.id);
|
|
3235
1439
|
const coordinatesIcon = props.geoData.labelDisplayPosition(
|
|
3236
1440
|
// @ts-expect-error TODO: manage undefined case
|
|
3237
|
-
lineData
|
|
3238
|
-
lineData
|
|
1441
|
+
lineData?.positions,
|
|
1442
|
+
lineData?.cumulativeDistances,
|
|
3239
1443
|
0.5,
|
|
3240
1444
|
ArrowDirection.NONE,
|
|
3241
1445
|
line.parallelIndex,
|
|
@@ -3247,7 +1451,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3247
1451
|
line.proximityFactorEnd
|
|
3248
1452
|
);
|
|
3249
1453
|
if (coordinatesIcon !== null) {
|
|
3250
|
-
|
|
1454
|
+
compositeData2.operatingStatus?.push({
|
|
3251
1455
|
status: lineStatus.operatingStatus,
|
|
3252
1456
|
printPosition: [coordinatesIcon.position.longitude, coordinatesIcon.position.latitude],
|
|
3253
1457
|
offset: coordinatesIcon.offset
|
|
@@ -3261,12 +1465,11 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3261
1465
|
//because for LineFlowMode.STATIC_ARROWS and LineFlowMode.ANIMATED_ARROWS it's the same
|
|
3262
1466
|
props.lineFlowMode !== oldProps.lineFlowMode && (props.lineFlowMode === "feeders" || oldProps.lineFlowMode === "feeders"))) {
|
|
3263
1467
|
compositeData.forEach((compositeData2) => {
|
|
3264
|
-
var _a;
|
|
3265
1468
|
const lineMap = compositeData2.lineMap;
|
|
3266
|
-
compositeData2.arrows =
|
|
3267
|
-
const lineData = lineMap
|
|
3268
|
-
line.cumulativeDistances = lineData
|
|
3269
|
-
line.positions = lineData
|
|
1469
|
+
compositeData2.arrows = compositeData2.lines?.flatMap((line) => {
|
|
1470
|
+
const lineData = lineMap?.get(line.id);
|
|
1471
|
+
line.cumulativeDistances = lineData?.cumulativeDistances;
|
|
1472
|
+
line.positions = lineData?.positions;
|
|
3270
1473
|
if (props.lineFlowMode === "feeders") {
|
|
3271
1474
|
return [
|
|
3272
1475
|
{
|
|
@@ -3280,7 +1483,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3280
1483
|
];
|
|
3281
1484
|
}
|
|
3282
1485
|
const directLinePositions = props.geoData.getLinePositions(props.network, line, false);
|
|
3283
|
-
const directLineDistance =
|
|
1486
|
+
const directLineDistance = geolib.getDistance(
|
|
3284
1487
|
{
|
|
3285
1488
|
latitude: directLinePositions[0][1],
|
|
3286
1489
|
longitude: directLinePositions[0][0]
|
|
@@ -3312,7 +1515,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3312
1515
|
recomputeParallelLinesIndex(compositeData, props) {
|
|
3313
1516
|
compositeData.forEach((compositeData2) => {
|
|
3314
1517
|
const mapOriginDestination = compositeData2.mapOriginDestination;
|
|
3315
|
-
mapOriginDestination
|
|
1518
|
+
mapOriginDestination?.forEach((samePathLine, key) => {
|
|
3316
1519
|
let truncatedSize = samePathLine.size;
|
|
3317
1520
|
if (truncatedSize > 32) {
|
|
3318
1521
|
console.warn(
|
|
@@ -3334,24 +1537,23 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3334
1537
|
const mapMinProximityFactor = /* @__PURE__ */ new Map();
|
|
3335
1538
|
compositeData.forEach((compositeData2) => {
|
|
3336
1539
|
compositeData2.lines.forEach((line) => {
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
1540
|
+
const positions = compositeData2.lineMap?.get(line.id)?.positions;
|
|
1541
|
+
if (!positions || positions.length < 2) {
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
const first = positions[0];
|
|
1545
|
+
const last = positions.at(-1);
|
|
1546
|
+
const second = positions[1];
|
|
1547
|
+
const secondToLast = positions.at(-2);
|
|
1548
|
+
line.origin = first;
|
|
1549
|
+
line.end = last;
|
|
3341
1550
|
line.substationIndexStart = this.getVoltageLevelIndex(line.voltageLevelId1);
|
|
3342
1551
|
line.substationIndexEnd = this.getVoltageLevelIndex(line.voltageLevelId2);
|
|
3343
|
-
line.angle = this.computeAngle(props,
|
|
3344
|
-
line.angleStart = this.computeAngle(props,
|
|
3345
|
-
line.angleEnd = this.computeAngle(
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
positions[positions.length - 1]
|
|
3349
|
-
);
|
|
3350
|
-
line.proximityFactorStart = this.getProximityFactor(positions[0], positions[1]);
|
|
3351
|
-
line.proximityFactorEnd = this.getProximityFactor(
|
|
3352
|
-
positions[positions.length - 2],
|
|
3353
|
-
positions[positions.length - 1]
|
|
3354
|
-
);
|
|
1552
|
+
line.angle = this.computeAngle(props, first, last);
|
|
1553
|
+
line.angleStart = this.computeAngle(props, first, second);
|
|
1554
|
+
line.angleEnd = this.computeAngle(props, secondToLast, last);
|
|
1555
|
+
line.proximityFactorStart = this.getProximityFactor(first, second);
|
|
1556
|
+
line.proximityFactorEnd = this.getProximityFactor(secondToLast, last);
|
|
3355
1557
|
const key = this.genLineKey(line);
|
|
3356
1558
|
const val = mapMinProximityFactor.get(key);
|
|
3357
1559
|
if (val == null) {
|
|
@@ -3376,13 +1578,24 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3376
1578
|
);
|
|
3377
1579
|
}
|
|
3378
1580
|
getProximityFactor(firstPosition, secondPosition) {
|
|
3379
|
-
let
|
|
1581
|
+
let dist;
|
|
1582
|
+
if (this.props.coordinateSystem === core.COORDINATE_SYSTEM.CARTESIAN) {
|
|
1583
|
+
dist = Math.hypot(secondPosition[0] - firstPosition[0], secondPosition[1] - firstPosition[1]);
|
|
1584
|
+
} else {
|
|
1585
|
+
dist = geolib.getDistance(firstPosition, secondPosition);
|
|
1586
|
+
}
|
|
1587
|
+
let factor = dist / (3 * this.props.distanceBetweenLines);
|
|
3380
1588
|
if (factor > 1) {
|
|
3381
1589
|
factor = 1;
|
|
3382
1590
|
}
|
|
3383
1591
|
return factor;
|
|
3384
1592
|
}
|
|
3385
1593
|
computeAngle(props, position1, position2) {
|
|
1594
|
+
if (props.coordinateSystem === core.COORDINATE_SYSTEM.CARTESIAN) {
|
|
1595
|
+
const [x1, y1] = position1;
|
|
1596
|
+
const [x2, y2] = position2;
|
|
1597
|
+
return 3 * Math.PI / 2 - Math.atan2(y2 - y1, x2 - x1);
|
|
1598
|
+
}
|
|
3386
1599
|
let angle = props.geoData.getMapAngle(position1, position2);
|
|
3387
1600
|
angle = angle * Math.PI / 180 + Math.PI;
|
|
3388
1601
|
if (angle < 0) {
|
|
@@ -3601,7 +1814,7 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3601
1814
|
this.getSubLayerProps({
|
|
3602
1815
|
id: "ActivePower" + compositeData.nominalV,
|
|
3603
1816
|
data: compositeData.activePower,
|
|
3604
|
-
getText: (activePower) => activePower.p
|
|
1817
|
+
getText: (activePower) => activePower.p === void 0 ? "" : Math.round(activePower.p).toString(),
|
|
3605
1818
|
// The position passed to this layer causes a bug when zooming and maxParallelOffset is reached:
|
|
3606
1819
|
// the label is not correctly positioned on the lines, they are slightly off.
|
|
3607
1820
|
// In the custom layers, we clamp the distanceBetweenLines. This is not done in the deck.gl TextLayer
|
|
@@ -3649,52 +1862,21 @@ const _LineLayer = class _LineLayer extends core.CompositeLayer {
|
|
|
3649
1862
|
});
|
|
3650
1863
|
return layers$1;
|
|
3651
1864
|
}
|
|
3652
|
-
}
|
|
3653
|
-
_LineLayer.layerName = "LineLayer";
|
|
3654
|
-
_LineLayer.defaultProps = {
|
|
3655
|
-
network: void 0,
|
|
3656
|
-
geoData: void 0,
|
|
3657
|
-
getNominalVoltageColor: {
|
|
3658
|
-
type: "accessor",
|
|
3659
|
-
value: () => [255, 255, 255]
|
|
3660
|
-
/*getNominalVoltageColor*/
|
|
3661
|
-
},
|
|
3662
|
-
disconnectedLineColor: { type: "color", value: [255, 255, 255] },
|
|
3663
|
-
filteredNominalVoltages: void 0,
|
|
3664
|
-
lineFlowMode: "feeders",
|
|
3665
|
-
lineFlowColorMode: "nominalVoltage",
|
|
3666
|
-
lineFlowAlertThreshold: 100,
|
|
3667
|
-
showLineFlow: true,
|
|
3668
|
-
lineFullPath: true,
|
|
3669
|
-
lineParallelPath: true,
|
|
3670
|
-
labelSize: 12,
|
|
3671
|
-
iconSize: 48,
|
|
3672
|
-
distanceBetweenLines: 1e3,
|
|
3673
|
-
maxParallelOffset: 100,
|
|
3674
|
-
minParallelOffset: 3,
|
|
3675
|
-
substationRadius: { type: "number", value: SUBSTATION_RADIUS },
|
|
3676
|
-
substationMaxPixel: { type: "number", value: SUBSTATION_RADIUS_MAX_PIXEL },
|
|
3677
|
-
minSubstationRadiusPixel: {
|
|
3678
|
-
type: "number",
|
|
3679
|
-
value: SUBSTATION_RADIUS_MIN_PIXEL
|
|
3680
|
-
},
|
|
3681
|
-
labelColor: [255, 255, 255]
|
|
3682
|
-
};
|
|
3683
|
-
let LineLayer = _LineLayer;
|
|
1865
|
+
}
|
|
3684
1866
|
const elementIdIndexer = (map, element) => map.set(element.id, element);
|
|
3685
1867
|
class MapEquipments {
|
|
1868
|
+
substations = [];
|
|
1869
|
+
substationsById = /* @__PURE__ */ new Map();
|
|
1870
|
+
lines = [];
|
|
1871
|
+
linesById = /* @__PURE__ */ new Map();
|
|
1872
|
+
tieLines = [];
|
|
1873
|
+
tieLinesById = /* @__PURE__ */ new Map();
|
|
1874
|
+
hvdcLines = [];
|
|
1875
|
+
hvdcLinesById = /* @__PURE__ */ new Map();
|
|
1876
|
+
voltageLevels = [];
|
|
1877
|
+
voltageLevelsById = /* @__PURE__ */ new Map();
|
|
1878
|
+
nominalVoltages = [];
|
|
3686
1879
|
constructor() {
|
|
3687
|
-
this.substations = [];
|
|
3688
|
-
this.substationsById = /* @__PURE__ */ new Map();
|
|
3689
|
-
this.lines = [];
|
|
3690
|
-
this.linesById = /* @__PURE__ */ new Map();
|
|
3691
|
-
this.tieLines = [];
|
|
3692
|
-
this.tieLinesById = /* @__PURE__ */ new Map();
|
|
3693
|
-
this.hvdcLines = [];
|
|
3694
|
-
this.hvdcLinesById = /* @__PURE__ */ new Map();
|
|
3695
|
-
this.voltageLevels = [];
|
|
3696
|
-
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3697
|
-
this.nominalVoltages = [];
|
|
3698
1880
|
}
|
|
3699
1881
|
newMapEquipmentForUpdate() {
|
|
3700
1882
|
return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
|
|
@@ -3704,13 +1886,13 @@ class MapEquipments {
|
|
|
3704
1886
|
}
|
|
3705
1887
|
completeSubstationsInfos(equipmentsToIndex) {
|
|
3706
1888
|
const nominalVoltagesSet = new Set(this.nominalVoltages);
|
|
3707
|
-
if (
|
|
1889
|
+
if (equipmentsToIndex?.length === 0) {
|
|
3708
1890
|
this.substationsById = /* @__PURE__ */ new Map();
|
|
3709
1891
|
this.voltageLevelsById = /* @__PURE__ */ new Map();
|
|
3710
1892
|
}
|
|
3711
|
-
const substations =
|
|
1893
|
+
const substations = equipmentsToIndex?.length > 0 ? equipmentsToIndex : this.substations;
|
|
3712
1894
|
substations.forEach((substation) => {
|
|
3713
|
-
substation.voltageLevels
|
|
1895
|
+
substation.voltageLevels.sort(
|
|
3714
1896
|
(voltageLevel1, voltageLevel2) => voltageLevel1.nominalV - voltageLevel2.nominalV
|
|
3715
1897
|
);
|
|
3716
1898
|
this.substationsById.set(substation.id, substation);
|
|
@@ -3766,23 +1948,21 @@ class MapEquipments {
|
|
|
3766
1948
|
this.completeSubstationsInfos(fullReload ? [] : substations);
|
|
3767
1949
|
}
|
|
3768
1950
|
completeLinesInfos(equipmentsToIndex) {
|
|
3769
|
-
if (
|
|
1951
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3770
1952
|
equipmentsToIndex.forEach((line) => {
|
|
3771
|
-
|
|
3772
|
-
(_a = this.linesById) == null ? void 0 : _a.set(line.id, line);
|
|
1953
|
+
this.linesById?.set(line.id, line);
|
|
3773
1954
|
});
|
|
3774
1955
|
} else {
|
|
3775
|
-
this.linesById = this.lines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1956
|
+
this.linesById = this.lines.reduce((map, line) => elementIdIndexer(map, line), /* @__PURE__ */ new Map());
|
|
3776
1957
|
}
|
|
3777
1958
|
}
|
|
3778
1959
|
completeTieLinesInfos(equipmentsToIndex) {
|
|
3779
|
-
if (
|
|
1960
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3780
1961
|
equipmentsToIndex.forEach((tieLine) => {
|
|
3781
|
-
|
|
3782
|
-
(_a = this.tieLinesById) == null ? void 0 : _a.set(tieLine.id, tieLine);
|
|
1962
|
+
this.tieLinesById?.set(tieLine.id, tieLine);
|
|
3783
1963
|
});
|
|
3784
1964
|
} else {
|
|
3785
|
-
this.tieLinesById = this.tieLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1965
|
+
this.tieLinesById = this.tieLines.reduce((map, tieLine) => elementIdIndexer(map, tieLine), /* @__PURE__ */ new Map());
|
|
3786
1966
|
}
|
|
3787
1967
|
}
|
|
3788
1968
|
updateLines(lines, fullReload) {
|
|
@@ -3807,13 +1987,12 @@ class MapEquipments {
|
|
|
3807
1987
|
this.completeHvdcLinesInfos(fullReload ? [] : hvdcLines);
|
|
3808
1988
|
}
|
|
3809
1989
|
completeHvdcLinesInfos(equipmentsToIndex) {
|
|
3810
|
-
if (
|
|
1990
|
+
if (equipmentsToIndex?.length > 0) {
|
|
3811
1991
|
equipmentsToIndex.forEach((hvdcLine) => {
|
|
3812
|
-
|
|
3813
|
-
(_a = this.hvdcLinesById) == null ? void 0 : _a.set(hvdcLine.id, hvdcLine);
|
|
1992
|
+
this.hvdcLinesById?.set(hvdcLine.id, hvdcLine);
|
|
3814
1993
|
});
|
|
3815
1994
|
} else {
|
|
3816
|
-
this.hvdcLinesById = this.hvdcLines.reduce(elementIdIndexer, /* @__PURE__ */ new Map());
|
|
1995
|
+
this.hvdcLinesById = this.hvdcLines.reduce((map, hvdcLine) => elementIdIndexer(map, hvdcLine), /* @__PURE__ */ new Map());
|
|
3817
1996
|
}
|
|
3818
1997
|
}
|
|
3819
1998
|
removeBranchesOfVoltageLevel(branchesList, voltageLevelId) {
|
|
@@ -3824,7 +2003,6 @@ class MapEquipments {
|
|
|
3824
2003
|
return remainingLines;
|
|
3825
2004
|
}
|
|
3826
2005
|
removeEquipment(equipmentType, equipmentId) {
|
|
3827
|
-
var _a, _b;
|
|
3828
2006
|
switch (equipmentType) {
|
|
3829
2007
|
case EQUIPMENT_TYPES.LINE: {
|
|
3830
2008
|
this.lines = this.lines.filter((l) => l.id !== equipmentId);
|
|
@@ -3832,9 +2010,9 @@ class MapEquipments {
|
|
|
3832
2010
|
break;
|
|
3833
2011
|
}
|
|
3834
2012
|
case EQUIPMENT_TYPES.VOLTAGE_LEVEL: {
|
|
3835
|
-
const substationId =
|
|
3836
|
-
let voltageLevelsOfSubstation =
|
|
3837
|
-
voltageLevelsOfSubstation = voltageLevelsOfSubstation
|
|
2013
|
+
const substationId = this.voltageLevelsById.get(equipmentId)?.substationId;
|
|
2014
|
+
let voltageLevelsOfSubstation = this.substationsById.get(substationId)?.voltageLevels;
|
|
2015
|
+
voltageLevelsOfSubstation = voltageLevelsOfSubstation?.filter((l) => l.id !== equipmentId);
|
|
3838
2016
|
const substation = this.substationsById.get(substationId);
|
|
3839
2017
|
if (substation !== void 0) {
|
|
3840
2018
|
substation.voltageLevels = voltageLevelsOfSubstation;
|
|
@@ -3846,7 +2024,7 @@ class MapEquipments {
|
|
|
3846
2024
|
case EQUIPMENT_TYPES.SUBSTATION: {
|
|
3847
2025
|
this.substations = this.substations.filter((l) => l.id !== equipmentId);
|
|
3848
2026
|
const substation = this.substationsById.get(equipmentId);
|
|
3849
|
-
substation
|
|
2027
|
+
substation?.voltageLevels.forEach((vl) => this.removeEquipment(EQUIPMENT_TYPES.VOLTAGE_LEVEL, vl.id));
|
|
3850
2028
|
this.completeSubstationsInfos([substation]);
|
|
3851
2029
|
break;
|
|
3852
2030
|
}
|
|
@@ -3889,22 +2067,26 @@ class MapEquipments {
|
|
|
3889
2067
|
const defaultProps = {
|
|
3890
2068
|
getRadiusMaxPixels: { type: "accessor", value: 1 }
|
|
3891
2069
|
};
|
|
3892
|
-
|
|
2070
|
+
class ScatterplotLayerExt extends layers.ScatterplotLayer {
|
|
2071
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2072
|
+
static layerName = "ScatterplotLayerExt";
|
|
2073
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2074
|
+
static defaultProps = defaultProps;
|
|
3893
2075
|
getShaders() {
|
|
3894
2076
|
const shaders = super.getShaders();
|
|
3895
|
-
return
|
|
3896
|
-
|
|
2077
|
+
return {
|
|
2078
|
+
...shaders,
|
|
2079
|
+
vs: shaders.vs.replace(", scatterplot.radiusMaxPixels", ", instanceRadiusMaxPixels"),
|
|
3897
2080
|
// hack to replace the uniform variable to corresponding attribute
|
|
3898
2081
|
inject: {
|
|
3899
2082
|
"vs:#decl": `in float instanceRadiusMaxPixels;
|
|
3900
2083
|
`
|
|
3901
2084
|
}
|
|
3902
|
-
}
|
|
2085
|
+
};
|
|
3903
2086
|
}
|
|
3904
2087
|
initializeState() {
|
|
3905
|
-
var _a;
|
|
3906
2088
|
super.initializeState();
|
|
3907
|
-
|
|
2089
|
+
this.getAttributeManager()?.addInstanced({
|
|
3908
2090
|
instanceRadiusMaxPixels: {
|
|
3909
2091
|
size: 1,
|
|
3910
2092
|
transition: true,
|
|
@@ -3914,10 +2096,7 @@ const _ScatterplotLayerExt = class _ScatterplotLayerExt extends layers.Scatterpl
|
|
|
3914
2096
|
}
|
|
3915
2097
|
});
|
|
3916
2098
|
}
|
|
3917
|
-
}
|
|
3918
|
-
_ScatterplotLayerExt.layerName = "ScatterplotLayerExt";
|
|
3919
|
-
_ScatterplotLayerExt.defaultProps = defaultProps;
|
|
3920
|
-
let ScatterplotLayerExt = _ScatterplotLayerExt;
|
|
2099
|
+
}
|
|
3921
2100
|
function voltageLevelNominalVoltageIndexer(map, voltageLevel) {
|
|
3922
2101
|
let list = map.get(voltageLevel.nominalV);
|
|
3923
2102
|
if (!list) {
|
|
@@ -3927,7 +2106,19 @@ function voltageLevelNominalVoltageIndexer(map, voltageLevel) {
|
|
|
3927
2106
|
list.push(voltageLevel);
|
|
3928
2107
|
return map;
|
|
3929
2108
|
}
|
|
3930
|
-
|
|
2109
|
+
class SubstationLayer extends core.CompositeLayer {
|
|
2110
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2111
|
+
static layerName = "SubstationLayer";
|
|
2112
|
+
// noinspection JSUnusedGlobalSymbols -- it's dynamically get by deck.gl
|
|
2113
|
+
static defaultProps = {
|
|
2114
|
+
network: void 0,
|
|
2115
|
+
geoData: void 0,
|
|
2116
|
+
getNominalVoltageColor: { type: "accessor", value: () => [255, 255, 255] },
|
|
2117
|
+
filteredNominalVoltages: null,
|
|
2118
|
+
labelsVisible: false,
|
|
2119
|
+
labelColor: { type: "color", value: [255, 255, 255] },
|
|
2120
|
+
labelSize: 12
|
|
2121
|
+
};
|
|
3931
2122
|
initializeState(context) {
|
|
3932
2123
|
super.initializeState(context);
|
|
3933
2124
|
this.state = {
|
|
@@ -3942,7 +2133,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
3942
2133
|
if (props.network != null && props.geoData != null) {
|
|
3943
2134
|
props.data.forEach((substation) => {
|
|
3944
2135
|
const voltageLevelsByNominalVoltage = substation.voltageLevels.reduce(
|
|
3945
|
-
voltageLevelNominalVoltageIndexer,
|
|
2136
|
+
(map, voltageLevel) => voltageLevelNominalVoltageIndexer(map, voltageLevel),
|
|
3946
2137
|
/* @__PURE__ */ new Map()
|
|
3947
2138
|
);
|
|
3948
2139
|
const nominalVoltages = [
|
|
@@ -3970,10 +2161,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
3970
2161
|
let substationsLabels = props.data;
|
|
3971
2162
|
if (props.network != null && props.geoData != null && props.filteredNominalVoltages != null) {
|
|
3972
2163
|
substationsLabels = substationsLabels.filter(
|
|
3973
|
-
(substation) => substation.voltageLevels.
|
|
3974
|
-
var _a;
|
|
3975
|
-
return (_a = props.filteredNominalVoltages) == null ? void 0 : _a.includes(v.nominalV);
|
|
3976
|
-
}) !== void 0
|
|
2164
|
+
(substation) => substation.voltageLevels.some((v) => props.filteredNominalVoltages?.includes(v.nominalV))
|
|
3977
2165
|
);
|
|
3978
2166
|
}
|
|
3979
2167
|
this.setState({ substationsLabels });
|
|
@@ -4022,18 +2210,7 @@ const _SubstationLayer = class _SubstationLayer extends core.CompositeLayer {
|
|
|
4022
2210
|
layers$1.push(substationLabelsLayer);
|
|
4023
2211
|
return layers$1;
|
|
4024
2212
|
}
|
|
4025
|
-
}
|
|
4026
|
-
_SubstationLayer.layerName = "SubstationLayer";
|
|
4027
|
-
_SubstationLayer.defaultProps = {
|
|
4028
|
-
network: void 0,
|
|
4029
|
-
geoData: void 0,
|
|
4030
|
-
getNominalVoltageColor: { type: "accessor", value: () => [255, 255, 255] },
|
|
4031
|
-
filteredNominalVoltages: null,
|
|
4032
|
-
labelsVisible: false,
|
|
4033
|
-
labelColor: { type: "color", value: [255, 255, 255] },
|
|
4034
|
-
labelSize: 12
|
|
4035
|
-
};
|
|
4036
|
-
let SubstationLayer = _SubstationLayer;
|
|
2213
|
+
}
|
|
4037
2214
|
var Country = /* @__PURE__ */ ((Country2) => {
|
|
4038
2215
|
Country2["AF"] = "AFGHANISTAN";
|
|
4039
2216
|
Country2["AX"] = "ÅLAND ISLANDS";
|