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