@wemap/geo 11.0.0-alpha.2 → 11.0.0-alpha.20
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.js +1459 -475
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2823 -0
- package/dist/index.mjs.map +1 -0
- package/index.ts +9 -19
- package/package.json +12 -5
- package/src/Utils.ts +4 -4
- package/src/coordinates/Coordinates.ts +16 -7
- package/src/graph/GeoGraph.spec.ts +278 -0
- package/src/graph/GeoGraph.ts +170 -0
- package/src/graph/GeoGraphEdge.spec.ts +51 -0
- package/src/graph/GeoGraphEdge.ts +98 -0
- package/src/graph/GeoGraphItinerary.spec.ts +14 -0
- package/src/graph/GeoGraphItinerary.ts +61 -0
- package/src/graph/GeoGraphProjection.ts +24 -0
- package/src/graph/{MapMatching.spec.ts → GeoGraphProjectionHandler.spec.ts} +74 -73
- package/src/graph/{MapMatching.ts → GeoGraphProjectionHandler.ts} +39 -44
- package/src/graph/GeoGraphRouter.spec.ts +297 -0
- package/src/graph/GeoGraphRouter.ts +267 -0
- package/src/graph/GeoGraphVertex.spec.ts +54 -0
- package/src/graph/GeoGraphVertex.ts +139 -0
- package/src/{router → graph}/NoRouteFoundError.ts +9 -14
- package/src/types.ts +3 -3
- package/tests/CommonTest.ts +69 -73
- package/src/graph/GraphEdge.spec.ts +0 -74
- package/src/graph/GraphEdge.ts +0 -134
- package/src/graph/GraphNode.spec.ts +0 -200
- package/src/graph/GraphNode.ts +0 -174
- package/src/graph/GraphProjection.ts +0 -23
- package/src/graph/GraphUtils.ts +0 -21
- package/src/graph/Network.spec.ts +0 -145
- package/src/graph/Network.ts +0 -175
- package/src/router/GraphItinerary.spec.ts +0 -14
- package/src/router/GraphItinerary.ts +0 -80
- package/src/router/GraphRouter.spec.ts +0 -298
- package/src/router/GraphRouter.ts +0 -283
- package/src/router/GraphRouterOptions.ts +0 -14
package/dist/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
4
|
var __publicField = (obj, key, value) => {
|
|
4
5
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
6
|
return value;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
const maths = require("@wemap/maths");
|
|
10
|
+
const Logger = require("@wemap/logger");
|
|
11
|
+
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
12
|
+
const Logger__default = /* @__PURE__ */ _interopDefaultLegacy(Logger);
|
|
9
13
|
const R_MAJOR = 6378137;
|
|
10
14
|
const R_MINOR = 63567523142e-4;
|
|
11
15
|
const EARTH_GRAVITY = 9.80665;
|
|
@@ -327,7 +331,7 @@ class Coordinates {
|
|
|
327
331
|
}
|
|
328
332
|
wrap() {
|
|
329
333
|
if (this._lng <= -180 || this._lng > 180) {
|
|
330
|
-
this._lng = wrap(this._lng, -180, 180);
|
|
334
|
+
this._lng = maths.wrap(this._lng, -180, 180);
|
|
331
335
|
}
|
|
332
336
|
}
|
|
333
337
|
static equals(pos1, pos2, eps = EPS_DEG_MM, epsAlt = EPS_MM) {
|
|
@@ -351,8 +355,8 @@ class Coordinates {
|
|
|
351
355
|
const dR = distance / R_MAJOR;
|
|
352
356
|
const cosDr = Math.cos(dR);
|
|
353
357
|
const sinDr = Math.sin(dR);
|
|
354
|
-
const phi1 = deg2rad(this.lat);
|
|
355
|
-
const lambda1 = deg2rad(this.lng);
|
|
358
|
+
const phi1 = maths.deg2rad(this.lat);
|
|
359
|
+
const lambda1 = maths.deg2rad(this.lng);
|
|
356
360
|
const phi2 = Math.asin(
|
|
357
361
|
Math.sin(phi1) * cosDr + Math.cos(phi1) * sinDr * Math.cos(bearing)
|
|
358
362
|
);
|
|
@@ -360,8 +364,8 @@ class Coordinates {
|
|
|
360
364
|
Math.sin(bearing) * sinDr * Math.cos(phi1),
|
|
361
365
|
cosDr - Math.sin(phi1) * Math.sin(phi2)
|
|
362
366
|
);
|
|
363
|
-
this.lat = rad2deg(phi2);
|
|
364
|
-
this.lng = rad2deg(lambda2);
|
|
367
|
+
this.lat = maths.rad2deg(phi2);
|
|
368
|
+
this.lng = maths.rad2deg(lambda2);
|
|
365
369
|
if (elevation !== null) {
|
|
366
370
|
if (this.alt === null) {
|
|
367
371
|
throw new Error("Point altitude is not defined");
|
|
@@ -375,13 +379,13 @@ class Coordinates {
|
|
|
375
379
|
const lng1 = this.lng;
|
|
376
380
|
const lat2 = location2.lat;
|
|
377
381
|
const lng2 = location2.lng;
|
|
378
|
-
const dlat = deg2rad(lat2 - lat1);
|
|
379
|
-
const dlng = deg2rad(lng2 - lng1);
|
|
382
|
+
const dlat = maths.deg2rad(lat2 - lat1);
|
|
383
|
+
const dlng = maths.deg2rad(lng2 - lng1);
|
|
380
384
|
const dlngsin = Math.sin(dlng / 2);
|
|
381
385
|
const dlatsin = Math.sin(dlat / 2);
|
|
382
|
-
const lat1rad = deg2rad(lat1);
|
|
386
|
+
const lat1rad = maths.deg2rad(lat1);
|
|
383
387
|
const lat1cos = Math.cos(lat1rad);
|
|
384
|
-
const lat2rad = deg2rad(lat2);
|
|
388
|
+
const lat2rad = maths.deg2rad(lat2);
|
|
385
389
|
const lat2cos = Math.cos(lat2rad);
|
|
386
390
|
const angle = dlatsin * dlatsin + lat1cos * lat2cos * dlngsin * dlngsin;
|
|
387
391
|
const tangy = Math.sqrt(angle);
|
|
@@ -393,9 +397,9 @@ class Coordinates {
|
|
|
393
397
|
return point1.distanceTo(point2);
|
|
394
398
|
}
|
|
395
399
|
bearingTo(location2) {
|
|
396
|
-
const lat1 = deg2rad(this.lat);
|
|
397
|
-
const lat2 = deg2rad(location2.lat);
|
|
398
|
-
const diffLng = deg2rad(location2.lng - this.lng);
|
|
400
|
+
const lat1 = maths.deg2rad(this.lat);
|
|
401
|
+
const lat2 = maths.deg2rad(location2.lat);
|
|
402
|
+
const diffLng = maths.deg2rad(location2.lng - this.lng);
|
|
399
403
|
return Math.atan2(
|
|
400
404
|
Math.sin(diffLng) * Math.cos(lat2),
|
|
401
405
|
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(diffLng)
|
|
@@ -405,19 +409,19 @@ class Coordinates {
|
|
|
405
409
|
return point1.bearingTo(point2);
|
|
406
410
|
}
|
|
407
411
|
get enuToEcefRotation() {
|
|
408
|
-
const rot1 = Quaternion.fromAxisAngle([0, 0, 1], Math.PI / 2 + deg2rad(this.lng));
|
|
409
|
-
const rot2 = Quaternion.fromAxisAngle([1, 0, 0], Math.PI / 2 - deg2rad(this.lat));
|
|
410
|
-
return Quaternion.multiply(rot1, rot2);
|
|
412
|
+
const rot1 = maths.Quaternion.fromAxisAngle([0, 0, 1], Math.PI / 2 + maths.deg2rad(this.lng));
|
|
413
|
+
const rot2 = maths.Quaternion.fromAxisAngle([1, 0, 0], Math.PI / 2 - maths.deg2rad(this.lat));
|
|
414
|
+
return maths.Quaternion.multiply(rot1, rot2);
|
|
411
415
|
}
|
|
412
416
|
get ecefToEnuRotation() {
|
|
413
|
-
const rot1 = Quaternion.fromAxisAngle([1, 0, 0], deg2rad(this.lat) - Math.PI / 2);
|
|
414
|
-
const rot2 = Quaternion.fromAxisAngle([0, 0, 1], -deg2rad(this.lng) - Math.PI / 2);
|
|
415
|
-
return Quaternion.multiply(rot1, rot2);
|
|
417
|
+
const rot1 = maths.Quaternion.fromAxisAngle([1, 0, 0], maths.deg2rad(this.lat) - Math.PI / 2);
|
|
418
|
+
const rot2 = maths.Quaternion.fromAxisAngle([0, 0, 1], -maths.deg2rad(this.lng) - Math.PI / 2);
|
|
419
|
+
return maths.Quaternion.multiply(rot1, rot2);
|
|
416
420
|
}
|
|
417
421
|
get ecef() {
|
|
418
422
|
if (!this._ecef) {
|
|
419
|
-
const lat = deg2rad(this.lat);
|
|
420
|
-
const lng = deg2rad(this.lng);
|
|
423
|
+
const lat = maths.deg2rad(this.lat);
|
|
424
|
+
const lng = maths.deg2rad(this.lng);
|
|
421
425
|
const alt = this.alt || 0;
|
|
422
426
|
const x = (R_MAJOR + alt) * Math.cos(lat) * Math.cos(lng);
|
|
423
427
|
const y = (R_MAJOR + alt) * Math.cos(lat) * Math.sin(lng);
|
|
@@ -435,21 +439,21 @@ class Coordinates {
|
|
|
435
439
|
const lat = Math.atan2(z, p);
|
|
436
440
|
const alt = p / Math.cos(lat) - R_MAJOR;
|
|
437
441
|
lng = lng % (2 * Math.PI);
|
|
438
|
-
const newPoint = new Coordinates(rad2deg(lat), rad2deg(lng), alt);
|
|
442
|
+
const newPoint = new Coordinates(maths.rad2deg(lat), maths.rad2deg(lng), alt);
|
|
439
443
|
newPoint._ecef = ecef;
|
|
440
444
|
return newPoint;
|
|
441
445
|
}
|
|
442
446
|
getSegmentProjection(p1, p2) {
|
|
443
|
-
const a = Vector3.normalize(p1.ecef);
|
|
444
|
-
const b = Vector3.normalize(p2.ecef);
|
|
445
|
-
const c = Vector3.normalize(this.ecef);
|
|
446
|
-
const G = Vector3.cross(a, b);
|
|
447
|
-
if (Vector3.norm(G) === 0) {
|
|
447
|
+
const a = maths.Vector3.normalize(p1.ecef);
|
|
448
|
+
const b = maths.Vector3.normalize(p2.ecef);
|
|
449
|
+
const c = maths.Vector3.normalize(this.ecef);
|
|
450
|
+
const G = maths.Vector3.cross(a, b);
|
|
451
|
+
if (maths.Vector3.norm(G) === 0) {
|
|
448
452
|
return null;
|
|
449
453
|
}
|
|
450
|
-
const F = Vector3.cross(c, G);
|
|
451
|
-
const t = Vector3.normalize(Vector3.cross(G, F));
|
|
452
|
-
const posECEF = Vector3.multiplyScalar(t, R_MAJOR);
|
|
454
|
+
const F = maths.Vector3.cross(c, G);
|
|
455
|
+
const t = maths.Vector3.normalize(maths.Vector3.cross(G, F));
|
|
456
|
+
const posECEF = maths.Vector3.multiplyScalar(t, R_MAJOR);
|
|
453
457
|
const poseCoordinates = Coordinates.fromECEF(posECEF);
|
|
454
458
|
let alt;
|
|
455
459
|
if (p1.alt !== null && p2.alt !== null) {
|
|
@@ -479,9 +483,9 @@ class Coordinates {
|
|
|
479
483
|
}
|
|
480
484
|
toJson() {
|
|
481
485
|
return {
|
|
482
|
-
lat: this.lat,
|
|
483
|
-
lng: this.lng,
|
|
484
|
-
...this.alt !== null && { alt: this.alt },
|
|
486
|
+
lat: Number(this.lat.toFixed(8)),
|
|
487
|
+
lng: Number(this.lng.toFixed(8)),
|
|
488
|
+
...this.alt !== null && { alt: Number(this.alt.toFixed(3)) },
|
|
485
489
|
...this.level !== null && { level: this.level }
|
|
486
490
|
};
|
|
487
491
|
}
|
|
@@ -490,12 +494,21 @@ class Coordinates {
|
|
|
490
494
|
}
|
|
491
495
|
toCompressedJson() {
|
|
492
496
|
if (this.level !== null) {
|
|
493
|
-
return [
|
|
497
|
+
return [
|
|
498
|
+
Number(this.lat.toFixed(8)),
|
|
499
|
+
Number(this.lng.toFixed(8)),
|
|
500
|
+
this.alt === null ? null : Number(this.alt.toFixed(3)),
|
|
501
|
+
this.level
|
|
502
|
+
];
|
|
494
503
|
}
|
|
495
504
|
if (this.alt !== null) {
|
|
496
|
-
return [
|
|
505
|
+
return [
|
|
506
|
+
Number(this.lat.toFixed(8)),
|
|
507
|
+
Number(this.lng.toFixed(8)),
|
|
508
|
+
Number(this.alt.toFixed(3))
|
|
509
|
+
];
|
|
497
510
|
}
|
|
498
|
-
return [this.lat, this.lng];
|
|
511
|
+
return [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))];
|
|
499
512
|
}
|
|
500
513
|
static fromCompressedJson(json) {
|
|
501
514
|
const coords = new Coordinates(json[0], json[1]);
|
|
@@ -684,14 +697,14 @@ function trimRoute(route, startPosition = route[0], length = Number.MAX_VALUE) {
|
|
|
684
697
|
}
|
|
685
698
|
return newRoute;
|
|
686
699
|
}
|
|
687
|
-
function simplifyRoute(coords, precisionAngle = deg2rad(5)) {
|
|
700
|
+
function simplifyRoute(coords, precisionAngle = maths.deg2rad(5)) {
|
|
688
701
|
const isClosed = coords[0].equals(coords[coords.length - 1]);
|
|
689
702
|
let newRoute = coords.slice(0, coords.length - (isClosed ? 1 : 0));
|
|
690
703
|
const len = newRoute.length;
|
|
691
704
|
for (let i = isClosed ? 0 : 1; i < len; i++) {
|
|
692
|
-
const p0 = coords[positiveMod(i - 1, len)];
|
|
705
|
+
const p0 = coords[maths.positiveMod(i - 1, len)];
|
|
693
706
|
const p1 = coords[i];
|
|
694
|
-
const p2 = coords[positiveMod(i + 1, len)];
|
|
707
|
+
const p2 = coords[maths.positiveMod(i + 1, len)];
|
|
695
708
|
const seg1Dir = p0.bearingTo(p1);
|
|
696
709
|
const seg2Dir = p1.bearingTo(p2);
|
|
697
710
|
if (Math.abs(seg2Dir - seg1Dir) < precisionAngle) {
|
|
@@ -711,7 +724,7 @@ function geolocationPositionToUserPosition(geolocationPosition) {
|
|
|
711
724
|
const userPosition = new UserPosition(latitude, longitude);
|
|
712
725
|
userPosition.time = geolocationPosition.timestamp;
|
|
713
726
|
userPosition.accuracy = accuracy;
|
|
714
|
-
userPosition.bearing = heading ? deg2rad(heading) : null;
|
|
727
|
+
userPosition.bearing = heading ? maths.deg2rad(heading) : null;
|
|
715
728
|
return userPosition;
|
|
716
729
|
}
|
|
717
730
|
function calcDistance(coords) {
|
|
@@ -900,19 +913,19 @@ class GeoRef {
|
|
|
900
913
|
this.origin = origin;
|
|
901
914
|
}
|
|
902
915
|
localToWorld(localPosition) {
|
|
903
|
-
const enuTranslationScaled = Vector3.multiplyScalar(localPosition, this.scale);
|
|
904
|
-
const rotationOffset = Quaternion.fromAxisAngle([0, 0, 1], this.heading);
|
|
905
|
-
const enuToEcefRotationOrigin = Quaternion.multiply(rotationOffset, this.origin.enuToEcefRotation);
|
|
906
|
-
const ecefTranslation = Quaternion.rotate(enuToEcefRotationOrigin, enuTranslationScaled);
|
|
907
|
-
const ecef = Vector3.sum(this.origin.ecef, ecefTranslation);
|
|
916
|
+
const enuTranslationScaled = maths.Vector3.multiplyScalar(localPosition, this.scale);
|
|
917
|
+
const rotationOffset = maths.Quaternion.fromAxisAngle([0, 0, 1], this.heading);
|
|
918
|
+
const enuToEcefRotationOrigin = maths.Quaternion.multiply(rotationOffset, this.origin.enuToEcefRotation);
|
|
919
|
+
const ecefTranslation = maths.Quaternion.rotate(enuToEcefRotationOrigin, enuTranslationScaled);
|
|
920
|
+
const ecef = maths.Vector3.sum(this.origin.ecef, ecefTranslation);
|
|
908
921
|
return Coordinates.fromECEF(ecef);
|
|
909
922
|
}
|
|
910
923
|
worldToLocal(coords) {
|
|
911
|
-
const rotationOffset = Quaternion.fromAxisAngle([0, 0, 1], -this.heading);
|
|
912
|
-
const ecefToEnuRotationOrigin = Quaternion.multiply(this.origin.ecefToEnuRotation, rotationOffset);
|
|
913
|
-
const ecefTranslation = Vector3.subtract(coords.ecef, this.origin.ecef);
|
|
914
|
-
const ecefTranslationScaled = Vector3.multiplyScalar(ecefTranslation, 1 / this.scale);
|
|
915
|
-
return Quaternion.rotate(ecefToEnuRotationOrigin, ecefTranslationScaled);
|
|
924
|
+
const rotationOffset = maths.Quaternion.fromAxisAngle([0, 0, 1], -this.heading);
|
|
925
|
+
const ecefToEnuRotationOrigin = maths.Quaternion.multiply(this.origin.ecefToEnuRotation, rotationOffset);
|
|
926
|
+
const ecefTranslation = maths.Vector3.subtract(coords.ecef, this.origin.ecef);
|
|
927
|
+
const ecefTranslationScaled = maths.Vector3.multiplyScalar(ecefTranslation, 1 / this.scale);
|
|
928
|
+
return maths.Quaternion.rotate(ecefToEnuRotationOrigin, ecefTranslationScaled);
|
|
916
929
|
}
|
|
917
930
|
toJson() {
|
|
918
931
|
return {
|
|
@@ -946,7 +959,7 @@ class Attitude {
|
|
|
946
959
|
return this._quaternion;
|
|
947
960
|
}
|
|
948
961
|
set quaternion(quaternion) {
|
|
949
|
-
if (Math.abs(1 - Quaternion.norm(quaternion)) > 1e-4) {
|
|
962
|
+
if (Math.abs(1 - maths.Quaternion.norm(quaternion)) > 1e-4) {
|
|
950
963
|
throw new Error("quaternion is not a unit quaternion");
|
|
951
964
|
}
|
|
952
965
|
this._quaternion = quaternion;
|
|
@@ -970,25 +983,25 @@ class Attitude {
|
|
|
970
983
|
}
|
|
971
984
|
get eulerAngles() {
|
|
972
985
|
if (this._eulerAngles === null) {
|
|
973
|
-
this._eulerAngles = Rotations.quaternionToEulerZXY(this.quaternion);
|
|
986
|
+
this._eulerAngles = maths.Rotations.quaternionToEulerZXY(this.quaternion);
|
|
974
987
|
}
|
|
975
988
|
return this._eulerAngles;
|
|
976
989
|
}
|
|
977
990
|
get eulerAnglesDegrees() {
|
|
978
|
-
return this.eulerAngles.map((x) => rad2deg(x));
|
|
991
|
+
return this.eulerAngles.map((x) => maths.rad2deg(x));
|
|
979
992
|
}
|
|
980
993
|
get heading() {
|
|
981
994
|
if (this._heading === null) {
|
|
982
995
|
let offset = 0;
|
|
983
996
|
if (typeof window !== "undefined" && window && window.orientation) {
|
|
984
|
-
offset = deg2rad(window.orientation);
|
|
997
|
+
offset = maths.deg2rad(window.orientation);
|
|
985
998
|
}
|
|
986
|
-
this._heading = Rotations.getHeadingFromQuaternion(this.quaternion) + offset;
|
|
999
|
+
this._heading = maths.Rotations.getHeadingFromQuaternion(this.quaternion) + offset;
|
|
987
1000
|
}
|
|
988
1001
|
return this._heading;
|
|
989
1002
|
}
|
|
990
1003
|
get headingDegrees() {
|
|
991
|
-
return rad2deg(this.heading);
|
|
1004
|
+
return maths.rad2deg(this.heading);
|
|
992
1005
|
}
|
|
993
1006
|
static equals(att1, att2) {
|
|
994
1007
|
if (att1 === null && att1 === att2) {
|
|
@@ -1000,7 +1013,7 @@ class Attitude {
|
|
|
1000
1013
|
if (att1 === att2) {
|
|
1001
1014
|
return true;
|
|
1002
1015
|
}
|
|
1003
|
-
return Quaternion.equals(att1.quaternion, att2.quaternion);
|
|
1016
|
+
return maths.Quaternion.equals(att1.quaternion, att2.quaternion);
|
|
1004
1017
|
}
|
|
1005
1018
|
equals(other) {
|
|
1006
1019
|
return Attitude.equals(this, other);
|
|
@@ -1025,8 +1038,8 @@ class Attitude {
|
|
|
1025
1038
|
return new Attitude(this.quaternion.slice(0), this.time, this.accuracy);
|
|
1026
1039
|
}
|
|
1027
1040
|
static diff(attitudeStart, attitudeEnd) {
|
|
1028
|
-
const quaternionDiff = Quaternion.multiply(
|
|
1029
|
-
Quaternion.inverse(attitudeStart.quaternion),
|
|
1041
|
+
const quaternionDiff = maths.Quaternion.multiply(
|
|
1042
|
+
maths.Quaternion.inverse(attitudeStart.quaternion),
|
|
1030
1043
|
attitudeEnd.quaternion
|
|
1031
1044
|
);
|
|
1032
1045
|
let timeDiff = null;
|
|
@@ -1060,7 +1073,7 @@ class AbsoluteHeading {
|
|
|
1060
1073
|
}
|
|
1061
1074
|
toAttitude() {
|
|
1062
1075
|
return new Attitude(
|
|
1063
|
-
Quaternion.fromAxisAngle([0, 0, 1], -this.heading),
|
|
1076
|
+
maths.Quaternion.fromAxisAngle([0, 0, 1], -this.heading),
|
|
1064
1077
|
this.time,
|
|
1065
1078
|
this.accuracy
|
|
1066
1079
|
);
|
|
@@ -1091,158 +1104,1118 @@ class AbsoluteHeading {
|
|
|
1091
1104
|
return new AbsoluteHeading(this.heading, this.time, this.accuracy);
|
|
1092
1105
|
}
|
|
1093
1106
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
bearingTo(other) {
|
|
1107
|
-
return this.coords.bearingTo(other.coords);
|
|
1108
|
-
}
|
|
1109
|
-
equals(other) {
|
|
1110
|
-
return this.coords.equals(other.coords) && this.builtFrom === other.builtFrom;
|
|
1111
|
-
}
|
|
1112
|
-
clone() {
|
|
1113
|
-
const node = new GraphNode(this.coords, this.builtFrom);
|
|
1114
|
-
node.edges = this.edges.slice(0);
|
|
1115
|
-
node.io = this.io;
|
|
1116
|
-
return node;
|
|
1117
|
-
}
|
|
1118
|
-
toJson() {
|
|
1119
|
-
return this.coords.toCompressedJson();
|
|
1120
|
-
}
|
|
1121
|
-
static fromJson(json, builtFrom = null) {
|
|
1122
|
-
return new GraphNode(Coordinates.fromCompressedJson(json), builtFrom);
|
|
1123
|
-
}
|
|
1124
|
-
_generateLevelFromEdges() {
|
|
1125
|
-
let tmpLevel = null;
|
|
1126
|
-
for (let i = 0; i < this.edges.length; i++) {
|
|
1127
|
-
const edge = this.edges[i];
|
|
1128
|
-
if (edge.level !== null) {
|
|
1129
|
-
if (tmpLevel === null) {
|
|
1130
|
-
tmpLevel = Level.clone(edge.level);
|
|
1107
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1108
|
+
var uaParser = { exports: {} };
|
|
1109
|
+
(function(module2, exports2) {
|
|
1110
|
+
(function(window2, undefined$1) {
|
|
1111
|
+
var LIBVERSION = "1.0.33", EMPTY = "", UNKNOWN = "?", FUNC_TYPE = "function", UNDEF_TYPE = "undefined", OBJ_TYPE = "object", STR_TYPE = "string", MAJOR = "major", MODEL = "model", NAME = "name", TYPE = "type", VENDOR = "vendor", VERSION = "version", ARCHITECTURE = "architecture", CONSOLE = "console", MOBILE = "mobile", TABLET = "tablet", SMARTTV = "smarttv", WEARABLE = "wearable", EMBEDDED = "embedded", UA_MAX_LENGTH = 350;
|
|
1112
|
+
var AMAZON = "Amazon", APPLE = "Apple", ASUS = "ASUS", BLACKBERRY = "BlackBerry", BROWSER = "Browser", CHROME = "Chrome", EDGE = "Edge", FIREFOX = "Firefox", GOOGLE = "Google", HUAWEI = "Huawei", LG = "LG", MICROSOFT = "Microsoft", MOTOROLA = "Motorola", OPERA = "Opera", SAMSUNG = "Samsung", SHARP = "Sharp", SONY = "Sony", XIAOMI = "Xiaomi", ZEBRA = "Zebra", FACEBOOK = "Facebook";
|
|
1113
|
+
var extend = function(regexes2, extensions) {
|
|
1114
|
+
var mergedRegexes = {};
|
|
1115
|
+
for (var i in regexes2) {
|
|
1116
|
+
if (extensions[i] && extensions[i].length % 2 === 0) {
|
|
1117
|
+
mergedRegexes[i] = extensions[i].concat(regexes2[i]);
|
|
1131
1118
|
} else {
|
|
1132
|
-
|
|
1133
|
-
if (tmpLevel === null) {
|
|
1134
|
-
throw Error("Something bad happend during parsing: We cannot retrieve node level from adjacent ways: " + this.coords);
|
|
1135
|
-
}
|
|
1119
|
+
mergedRegexes[i] = regexes2[i];
|
|
1136
1120
|
}
|
|
1137
1121
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
if (level === null || !Level.isRange(level)) {
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
if (this.edges.length > 1) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
const lookForLevel = (node, visitedNodes) => {
|
|
1150
|
-
visitedNodes.push(node);
|
|
1151
|
-
if (node.coords.level === null) {
|
|
1152
|
-
return null;
|
|
1122
|
+
return mergedRegexes;
|
|
1123
|
+
}, enumerize = function(arr) {
|
|
1124
|
+
var enums = {};
|
|
1125
|
+
for (var i = 0; i < arr.length; i++) {
|
|
1126
|
+
enums[arr[i].toUpperCase()] = arr[i];
|
|
1153
1127
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1128
|
+
return enums;
|
|
1129
|
+
}, has = function(str1, str2) {
|
|
1130
|
+
return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
|
|
1131
|
+
}, lowerize = function(str) {
|
|
1132
|
+
return str.toLowerCase();
|
|
1133
|
+
}, majorize = function(version) {
|
|
1134
|
+
return typeof version === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split(".")[0] : undefined$1;
|
|
1135
|
+
}, trim = function(str, len) {
|
|
1136
|
+
if (typeof str === STR_TYPE) {
|
|
1137
|
+
str = str.replace(/^\s\s*/, EMPTY);
|
|
1138
|
+
return typeof len === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
|
|
1156
1139
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1140
|
+
};
|
|
1141
|
+
var rgxMapper = function(ua, arrays) {
|
|
1142
|
+
var i = 0, j, k, p, q, matches, match;
|
|
1143
|
+
while (i < arrays.length && !matches) {
|
|
1144
|
+
var regex = arrays[i], props = arrays[i + 1];
|
|
1145
|
+
j = k = 0;
|
|
1146
|
+
while (j < regex.length && !matches) {
|
|
1147
|
+
matches = regex[j++].exec(ua);
|
|
1148
|
+
if (!!matches) {
|
|
1149
|
+
for (p = 0; p < props.length; p++) {
|
|
1150
|
+
match = matches[++k];
|
|
1151
|
+
q = props[p];
|
|
1152
|
+
if (typeof q === OBJ_TYPE && q.length > 0) {
|
|
1153
|
+
if (q.length === 2) {
|
|
1154
|
+
if (typeof q[1] == FUNC_TYPE) {
|
|
1155
|
+
this[q[0]] = q[1].call(this, match);
|
|
1156
|
+
} else {
|
|
1157
|
+
this[q[0]] = q[1];
|
|
1158
|
+
}
|
|
1159
|
+
} else if (q.length === 3) {
|
|
1160
|
+
if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
|
|
1161
|
+
this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
|
|
1162
|
+
} else {
|
|
1163
|
+
this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
|
|
1164
|
+
}
|
|
1165
|
+
} else if (q.length === 4) {
|
|
1166
|
+
this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
|
|
1167
|
+
}
|
|
1168
|
+
} else {
|
|
1169
|
+
this[q] = match ? match : undefined$1;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1163
1173
|
}
|
|
1174
|
+
i += 2;
|
|
1164
1175
|
}
|
|
1165
|
-
|
|
1176
|
+
}, strMapper = function(str, map) {
|
|
1177
|
+
for (var i in map) {
|
|
1178
|
+
if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
|
|
1179
|
+
for (var j = 0; j < map[i].length; j++) {
|
|
1180
|
+
if (has(map[i][j], str)) {
|
|
1181
|
+
return i === UNKNOWN ? undefined$1 : i;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
} else if (has(map[i], str)) {
|
|
1185
|
+
return i === UNKNOWN ? undefined$1 : i;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return str;
|
|
1166
1189
|
};
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1190
|
+
var oldSafariMap = {
|
|
1191
|
+
"1.0": "/8",
|
|
1192
|
+
"1.2": "/1",
|
|
1193
|
+
"1.3": "/3",
|
|
1194
|
+
"2.0": "/412",
|
|
1195
|
+
"2.0.2": "/416",
|
|
1196
|
+
"2.0.3": "/417",
|
|
1197
|
+
"2.0.4": "/419",
|
|
1198
|
+
"?": "/"
|
|
1199
|
+
}, windowsVersionMap = {
|
|
1200
|
+
"ME": "4.90",
|
|
1201
|
+
"NT 3.11": "NT3.51",
|
|
1202
|
+
"NT 4.0": "NT4.0",
|
|
1203
|
+
"2000": "NT 5.0",
|
|
1204
|
+
"XP": ["NT 5.1", "NT 5.2"],
|
|
1205
|
+
"Vista": "NT 6.0",
|
|
1206
|
+
"7": "NT 6.1",
|
|
1207
|
+
"8": "NT 6.2",
|
|
1208
|
+
"8.1": "NT 6.3",
|
|
1209
|
+
"10": ["NT 6.4", "NT 10.0"],
|
|
1210
|
+
"RT": "ARM"
|
|
1211
|
+
};
|
|
1212
|
+
var regexes = {
|
|
1213
|
+
browser: [
|
|
1214
|
+
[
|
|
1215
|
+
/\b(?:crmo|crios)\/([\w\.]+)/i
|
|
1216
|
+
],
|
|
1217
|
+
[VERSION, [NAME, "Chrome"]],
|
|
1218
|
+
[
|
|
1219
|
+
/edg(?:e|ios|a)?\/([\w\.]+)/i
|
|
1220
|
+
],
|
|
1221
|
+
[VERSION, [NAME, "Edge"]],
|
|
1222
|
+
[
|
|
1223
|
+
/(opera mini)\/([-\w\.]+)/i,
|
|
1224
|
+
/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,
|
|
1225
|
+
/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i
|
|
1226
|
+
],
|
|
1227
|
+
[NAME, VERSION],
|
|
1228
|
+
[
|
|
1229
|
+
/opios[\/ ]+([\w\.]+)/i
|
|
1230
|
+
],
|
|
1231
|
+
[VERSION, [NAME, OPERA + " Mini"]],
|
|
1232
|
+
[
|
|
1233
|
+
/\bopr\/([\w\.]+)/i
|
|
1234
|
+
],
|
|
1235
|
+
[VERSION, [NAME, OPERA]],
|
|
1236
|
+
[
|
|
1237
|
+
/(kindle)\/([\w\.]+)/i,
|
|
1238
|
+
/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,
|
|
1239
|
+
/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,
|
|
1240
|
+
/(ba?idubrowser)[\/ ]?([\w\.]+)/i,
|
|
1241
|
+
/(?:ms|\()(ie) ([\w\.]+)/i,
|
|
1242
|
+
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
|
|
1243
|
+
/(weibo)__([\d\.]+)/i
|
|
1244
|
+
],
|
|
1245
|
+
[NAME, VERSION],
|
|
1246
|
+
[
|
|
1247
|
+
/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i
|
|
1248
|
+
],
|
|
1249
|
+
[VERSION, [NAME, "UC" + BROWSER]],
|
|
1250
|
+
[
|
|
1251
|
+
/microm.+\bqbcore\/([\w\.]+)/i,
|
|
1252
|
+
/\bqbcore\/([\w\.]+).+microm/i
|
|
1253
|
+
],
|
|
1254
|
+
[VERSION, [NAME, "WeChat(Win) Desktop"]],
|
|
1255
|
+
[
|
|
1256
|
+
/micromessenger\/([\w\.]+)/i
|
|
1257
|
+
],
|
|
1258
|
+
[VERSION, [NAME, "WeChat"]],
|
|
1259
|
+
[
|
|
1260
|
+
/konqueror\/([\w\.]+)/i
|
|
1261
|
+
],
|
|
1262
|
+
[VERSION, [NAME, "Konqueror"]],
|
|
1263
|
+
[
|
|
1264
|
+
/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i
|
|
1265
|
+
],
|
|
1266
|
+
[VERSION, [NAME, "IE"]],
|
|
1267
|
+
[
|
|
1268
|
+
/yabrowser\/([\w\.]+)/i
|
|
1269
|
+
],
|
|
1270
|
+
[VERSION, [NAME, "Yandex"]],
|
|
1271
|
+
[
|
|
1272
|
+
/(avast|avg)\/([\w\.]+)/i
|
|
1273
|
+
],
|
|
1274
|
+
[[NAME, /(.+)/, "$1 Secure " + BROWSER], VERSION],
|
|
1275
|
+
[
|
|
1276
|
+
/\bfocus\/([\w\.]+)/i
|
|
1277
|
+
],
|
|
1278
|
+
[VERSION, [NAME, FIREFOX + " Focus"]],
|
|
1279
|
+
[
|
|
1280
|
+
/\bopt\/([\w\.]+)/i
|
|
1281
|
+
],
|
|
1282
|
+
[VERSION, [NAME, OPERA + " Touch"]],
|
|
1283
|
+
[
|
|
1284
|
+
/coc_coc\w+\/([\w\.]+)/i
|
|
1285
|
+
],
|
|
1286
|
+
[VERSION, [NAME, "Coc Coc"]],
|
|
1287
|
+
[
|
|
1288
|
+
/dolfin\/([\w\.]+)/i
|
|
1289
|
+
],
|
|
1290
|
+
[VERSION, [NAME, "Dolphin"]],
|
|
1291
|
+
[
|
|
1292
|
+
/coast\/([\w\.]+)/i
|
|
1293
|
+
],
|
|
1294
|
+
[VERSION, [NAME, OPERA + " Coast"]],
|
|
1295
|
+
[
|
|
1296
|
+
/miuibrowser\/([\w\.]+)/i
|
|
1297
|
+
],
|
|
1298
|
+
[VERSION, [NAME, "MIUI " + BROWSER]],
|
|
1299
|
+
[
|
|
1300
|
+
/fxios\/([-\w\.]+)/i
|
|
1301
|
+
],
|
|
1302
|
+
[VERSION, [NAME, FIREFOX]],
|
|
1303
|
+
[
|
|
1304
|
+
/\bqihu|(qi?ho?o?|360)browser/i
|
|
1305
|
+
],
|
|
1306
|
+
[[NAME, "360 " + BROWSER]],
|
|
1307
|
+
[
|
|
1308
|
+
/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i
|
|
1309
|
+
],
|
|
1310
|
+
[[NAME, /(.+)/, "$1 " + BROWSER], VERSION],
|
|
1311
|
+
[
|
|
1312
|
+
/(comodo_dragon)\/([\w\.]+)/i
|
|
1313
|
+
],
|
|
1314
|
+
[[NAME, /_/g, " "], VERSION],
|
|
1315
|
+
[
|
|
1316
|
+
/(electron)\/([\w\.]+) safari/i,
|
|
1317
|
+
/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,
|
|
1318
|
+
/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i
|
|
1319
|
+
],
|
|
1320
|
+
[NAME, VERSION],
|
|
1321
|
+
[
|
|
1322
|
+
/(metasr)[\/ ]?([\w\.]+)/i,
|
|
1323
|
+
/(lbbrowser)/i,
|
|
1324
|
+
/\[(linkedin)app\]/i
|
|
1325
|
+
],
|
|
1326
|
+
[NAME],
|
|
1327
|
+
[
|
|
1328
|
+
/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i
|
|
1329
|
+
],
|
|
1330
|
+
[[NAME, FACEBOOK], VERSION],
|
|
1331
|
+
[
|
|
1332
|
+
/safari (line)\/([\w\.]+)/i,
|
|
1333
|
+
/\b(line)\/([\w\.]+)\/iab/i,
|
|
1334
|
+
/(chromium|instagram)[\/ ]([-\w\.]+)/i
|
|
1335
|
+
],
|
|
1336
|
+
[NAME, VERSION],
|
|
1337
|
+
[
|
|
1338
|
+
/\bgsa\/([\w\.]+) .*safari\//i
|
|
1339
|
+
],
|
|
1340
|
+
[VERSION, [NAME, "GSA"]],
|
|
1341
|
+
[
|
|
1342
|
+
/headlesschrome(?:\/([\w\.]+)| )/i
|
|
1343
|
+
],
|
|
1344
|
+
[VERSION, [NAME, CHROME + " Headless"]],
|
|
1345
|
+
[
|
|
1346
|
+
/ wv\).+(chrome)\/([\w\.]+)/i
|
|
1347
|
+
],
|
|
1348
|
+
[[NAME, CHROME + " WebView"], VERSION],
|
|
1349
|
+
[
|
|
1350
|
+
/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i
|
|
1351
|
+
],
|
|
1352
|
+
[VERSION, [NAME, "Android " + BROWSER]],
|
|
1353
|
+
[
|
|
1354
|
+
/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i
|
|
1355
|
+
],
|
|
1356
|
+
[NAME, VERSION],
|
|
1357
|
+
[
|
|
1358
|
+
/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i
|
|
1359
|
+
],
|
|
1360
|
+
[VERSION, [NAME, "Mobile Safari"]],
|
|
1361
|
+
[
|
|
1362
|
+
/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i
|
|
1363
|
+
],
|
|
1364
|
+
[VERSION, NAME],
|
|
1365
|
+
[
|
|
1366
|
+
/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i
|
|
1367
|
+
],
|
|
1368
|
+
[NAME, [VERSION, strMapper, oldSafariMap]],
|
|
1369
|
+
[
|
|
1370
|
+
/(webkit|khtml)\/([\w\.]+)/i
|
|
1371
|
+
],
|
|
1372
|
+
[NAME, VERSION],
|
|
1373
|
+
[
|
|
1374
|
+
/(navigator|netscape\d?)\/([-\w\.]+)/i
|
|
1375
|
+
],
|
|
1376
|
+
[[NAME, "Netscape"], VERSION],
|
|
1377
|
+
[
|
|
1378
|
+
/mobile vr; rv:([\w\.]+)\).+firefox/i
|
|
1379
|
+
],
|
|
1380
|
+
[VERSION, [NAME, FIREFOX + " Reality"]],
|
|
1381
|
+
[
|
|
1382
|
+
/ekiohf.+(flow)\/([\w\.]+)/i,
|
|
1383
|
+
/(swiftfox)/i,
|
|
1384
|
+
/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
|
|
1385
|
+
/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
|
|
1386
|
+
/(firefox)\/([\w\.]+)/i,
|
|
1387
|
+
/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,
|
|
1388
|
+
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
|
|
1389
|
+
/(links) \(([\w\.]+)/i
|
|
1390
|
+
],
|
|
1391
|
+
[NAME, VERSION],
|
|
1392
|
+
[
|
|
1393
|
+
/(cobalt)\/([\w\.]+)/i
|
|
1394
|
+
],
|
|
1395
|
+
[NAME, [VERSION, /master.|lts./, ""]]
|
|
1396
|
+
],
|
|
1397
|
+
cpu: [
|
|
1398
|
+
[
|
|
1399
|
+
/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i
|
|
1400
|
+
],
|
|
1401
|
+
[[ARCHITECTURE, "amd64"]],
|
|
1402
|
+
[
|
|
1403
|
+
/(ia32(?=;))/i
|
|
1404
|
+
],
|
|
1405
|
+
[[ARCHITECTURE, lowerize]],
|
|
1406
|
+
[
|
|
1407
|
+
/((?:i[346]|x)86)[;\)]/i
|
|
1408
|
+
],
|
|
1409
|
+
[[ARCHITECTURE, "ia32"]],
|
|
1410
|
+
[
|
|
1411
|
+
/\b(aarch64|arm(v?8e?l?|_?64))\b/i
|
|
1412
|
+
],
|
|
1413
|
+
[[ARCHITECTURE, "arm64"]],
|
|
1414
|
+
[
|
|
1415
|
+
/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i
|
|
1416
|
+
],
|
|
1417
|
+
[[ARCHITECTURE, "armhf"]],
|
|
1418
|
+
[
|
|
1419
|
+
/windows (ce|mobile); ppc;/i
|
|
1420
|
+
],
|
|
1421
|
+
[[ARCHITECTURE, "arm"]],
|
|
1422
|
+
[
|
|
1423
|
+
/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i
|
|
1424
|
+
],
|
|
1425
|
+
[[ARCHITECTURE, /ower/, EMPTY, lowerize]],
|
|
1426
|
+
[
|
|
1427
|
+
/(sun4\w)[;\)]/i
|
|
1428
|
+
],
|
|
1429
|
+
[[ARCHITECTURE, "sparc"]],
|
|
1430
|
+
[
|
|
1431
|
+
/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
|
|
1432
|
+
],
|
|
1433
|
+
[[ARCHITECTURE, lowerize]]
|
|
1434
|
+
],
|
|
1435
|
+
device: [
|
|
1436
|
+
[
|
|
1437
|
+
/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
|
|
1438
|
+
],
|
|
1439
|
+
[MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]],
|
|
1440
|
+
[
|
|
1441
|
+
/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,
|
|
1442
|
+
/samsung[- ]([-\w]+)/i,
|
|
1443
|
+
/sec-(sgh\w+)/i
|
|
1444
|
+
],
|
|
1445
|
+
[MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]],
|
|
1446
|
+
[
|
|
1447
|
+
/\((ip(?:hone|od)[\w ]*);/i
|
|
1448
|
+
],
|
|
1449
|
+
[MODEL, [VENDOR, APPLE], [TYPE, MOBILE]],
|
|
1450
|
+
[
|
|
1451
|
+
/\((ipad);[-\w\),; ]+apple/i,
|
|
1452
|
+
/applecoremedia\/[\w\.]+ \((ipad)/i,
|
|
1453
|
+
/\b(ipad)\d\d?,\d\d?[;\]].+ios/i
|
|
1454
|
+
],
|
|
1455
|
+
[MODEL, [VENDOR, APPLE], [TYPE, TABLET]],
|
|
1456
|
+
[
|
|
1457
|
+
/(macintosh);/i
|
|
1458
|
+
],
|
|
1459
|
+
[MODEL, [VENDOR, APPLE]],
|
|
1460
|
+
[
|
|
1461
|
+
/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
|
|
1462
|
+
],
|
|
1463
|
+
[MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]],
|
|
1464
|
+
[
|
|
1465
|
+
/(?:huawei|honor)([-\w ]+)[;\)]/i,
|
|
1466
|
+
/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
|
|
1467
|
+
],
|
|
1468
|
+
[MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]],
|
|
1469
|
+
[
|
|
1470
|
+
/\b(poco[\w ]+)(?: bui|\))/i,
|
|
1471
|
+
/\b; (\w+) build\/hm\1/i,
|
|
1472
|
+
/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,
|
|
1473
|
+
/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,
|
|
1474
|
+
/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i
|
|
1475
|
+
],
|
|
1476
|
+
[[MODEL, /_/g, " "], [VENDOR, XIAOMI], [TYPE, MOBILE]],
|
|
1477
|
+
[
|
|
1478
|
+
/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i
|
|
1479
|
+
],
|
|
1480
|
+
[[MODEL, /_/g, " "], [VENDOR, XIAOMI], [TYPE, TABLET]],
|
|
1481
|
+
[
|
|
1482
|
+
/; (\w+) bui.+ oppo/i,
|
|
1483
|
+
/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
|
|
1484
|
+
],
|
|
1485
|
+
[MODEL, [VENDOR, "OPPO"], [TYPE, MOBILE]],
|
|
1486
|
+
[
|
|
1487
|
+
/vivo (\w+)(?: bui|\))/i,
|
|
1488
|
+
/\b(v[12]\d{3}\w?[at])(?: bui|;)/i
|
|
1489
|
+
],
|
|
1490
|
+
[MODEL, [VENDOR, "Vivo"], [TYPE, MOBILE]],
|
|
1491
|
+
[
|
|
1492
|
+
/\b(rmx[12]\d{3})(?: bui|;|\))/i
|
|
1493
|
+
],
|
|
1494
|
+
[MODEL, [VENDOR, "Realme"], [TYPE, MOBILE]],
|
|
1495
|
+
[
|
|
1496
|
+
/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
|
|
1497
|
+
/\bmot(?:orola)?[- ](\w*)/i,
|
|
1498
|
+
/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
|
|
1499
|
+
],
|
|
1500
|
+
[MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]],
|
|
1501
|
+
[
|
|
1502
|
+
/\b(mz60\d|xoom[2 ]{0,2}) build\//i
|
|
1503
|
+
],
|
|
1504
|
+
[MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]],
|
|
1505
|
+
[
|
|
1506
|
+
/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
|
|
1507
|
+
],
|
|
1508
|
+
[MODEL, [VENDOR, LG], [TYPE, TABLET]],
|
|
1509
|
+
[
|
|
1510
|
+
/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
|
|
1511
|
+
/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
|
|
1512
|
+
/\blg-?([\d\w]+) bui/i
|
|
1513
|
+
],
|
|
1514
|
+
[MODEL, [VENDOR, LG], [TYPE, MOBILE]],
|
|
1515
|
+
[
|
|
1516
|
+
/(ideatab[-\w ]+)/i,
|
|
1517
|
+
/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
|
|
1518
|
+
],
|
|
1519
|
+
[MODEL, [VENDOR, "Lenovo"], [TYPE, TABLET]],
|
|
1520
|
+
[
|
|
1521
|
+
/(?:maemo|nokia).*(n900|lumia \d+)/i,
|
|
1522
|
+
/nokia[-_ ]?([-\w\.]*)/i
|
|
1523
|
+
],
|
|
1524
|
+
[[MODEL, /_/g, " "], [VENDOR, "Nokia"], [TYPE, MOBILE]],
|
|
1525
|
+
[
|
|
1526
|
+
/(pixel c)\b/i
|
|
1527
|
+
],
|
|
1528
|
+
[MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]],
|
|
1529
|
+
[
|
|
1530
|
+
/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i
|
|
1531
|
+
],
|
|
1532
|
+
[MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]],
|
|
1533
|
+
[
|
|
1534
|
+
/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
|
|
1535
|
+
],
|
|
1536
|
+
[MODEL, [VENDOR, SONY], [TYPE, MOBILE]],
|
|
1537
|
+
[
|
|
1538
|
+
/sony tablet [ps]/i,
|
|
1539
|
+
/\b(?:sony)?sgp\w+(?: bui|\))/i
|
|
1540
|
+
],
|
|
1541
|
+
[[MODEL, "Xperia Tablet"], [VENDOR, SONY], [TYPE, TABLET]],
|
|
1542
|
+
[
|
|
1543
|
+
/ (kb2005|in20[12]5|be20[12][59])\b/i,
|
|
1544
|
+
/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
|
|
1545
|
+
],
|
|
1546
|
+
[MODEL, [VENDOR, "OnePlus"], [TYPE, MOBILE]],
|
|
1547
|
+
[
|
|
1548
|
+
/(alexa)webm/i,
|
|
1549
|
+
/(kf[a-z]{2}wi)( bui|\))/i,
|
|
1550
|
+
/(kf[a-z]+)( bui|\)).+silk\//i
|
|
1551
|
+
],
|
|
1552
|
+
[MODEL, [VENDOR, AMAZON], [TYPE, TABLET]],
|
|
1553
|
+
[
|
|
1554
|
+
/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i
|
|
1555
|
+
],
|
|
1556
|
+
[[MODEL, /(.+)/g, "Fire Phone $1"], [VENDOR, AMAZON], [TYPE, MOBILE]],
|
|
1557
|
+
[
|
|
1558
|
+
/(playbook);[-\w\),; ]+(rim)/i
|
|
1559
|
+
],
|
|
1560
|
+
[MODEL, VENDOR, [TYPE, TABLET]],
|
|
1561
|
+
[
|
|
1562
|
+
/\b((?:bb[a-f]|st[hv])100-\d)/i,
|
|
1563
|
+
/\(bb10; (\w+)/i
|
|
1564
|
+
],
|
|
1565
|
+
[MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]],
|
|
1566
|
+
[
|
|
1567
|
+
/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
|
|
1568
|
+
],
|
|
1569
|
+
[MODEL, [VENDOR, ASUS], [TYPE, TABLET]],
|
|
1570
|
+
[
|
|
1571
|
+
/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
|
|
1572
|
+
],
|
|
1573
|
+
[MODEL, [VENDOR, ASUS], [TYPE, MOBILE]],
|
|
1574
|
+
[
|
|
1575
|
+
/(nexus 9)/i
|
|
1576
|
+
],
|
|
1577
|
+
[MODEL, [VENDOR, "HTC"], [TYPE, TABLET]],
|
|
1578
|
+
[
|
|
1579
|
+
/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,
|
|
1580
|
+
/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
|
|
1581
|
+
/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i
|
|
1582
|
+
],
|
|
1583
|
+
[VENDOR, [MODEL, /_/g, " "], [TYPE, MOBILE]],
|
|
1584
|
+
[
|
|
1585
|
+
/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
|
|
1586
|
+
],
|
|
1587
|
+
[MODEL, [VENDOR, "Acer"], [TYPE, TABLET]],
|
|
1588
|
+
[
|
|
1589
|
+
/droid.+; (m[1-5] note) bui/i,
|
|
1590
|
+
/\bmz-([-\w]{2,})/i
|
|
1591
|
+
],
|
|
1592
|
+
[MODEL, [VENDOR, "Meizu"], [TYPE, MOBILE]],
|
|
1593
|
+
[
|
|
1594
|
+
/\b(sh-?[altvz]?\d\d[a-ekm]?)/i
|
|
1595
|
+
],
|
|
1596
|
+
[MODEL, [VENDOR, SHARP], [TYPE, MOBILE]],
|
|
1597
|
+
[
|
|
1598
|
+
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
|
|
1599
|
+
/(hp) ([\w ]+\w)/i,
|
|
1600
|
+
/(asus)-?(\w+)/i,
|
|
1601
|
+
/(microsoft); (lumia[\w ]+)/i,
|
|
1602
|
+
/(lenovo)[-_ ]?([-\w]+)/i,
|
|
1603
|
+
/(jolla)/i,
|
|
1604
|
+
/(oppo) ?([\w ]+) bui/i
|
|
1605
|
+
],
|
|
1606
|
+
[VENDOR, MODEL, [TYPE, MOBILE]],
|
|
1607
|
+
[
|
|
1608
|
+
/(archos) (gamepad2?)/i,
|
|
1609
|
+
/(hp).+(touchpad(?!.+tablet)|tablet)/i,
|
|
1610
|
+
/(kindle)\/([\w\.]+)/i,
|
|
1611
|
+
/(nook)[\w ]+build\/(\w+)/i,
|
|
1612
|
+
/(dell) (strea[kpr\d ]*[\dko])/i,
|
|
1613
|
+
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,
|
|
1614
|
+
/(trinity)[- ]*(t\d{3}) bui/i,
|
|
1615
|
+
/(gigaset)[- ]+(q\w{1,9}) bui/i,
|
|
1616
|
+
/(vodafone) ([\w ]+)(?:\)| bui)/i
|
|
1617
|
+
],
|
|
1618
|
+
[VENDOR, MODEL, [TYPE, TABLET]],
|
|
1619
|
+
[
|
|
1620
|
+
/(surface duo)/i
|
|
1621
|
+
],
|
|
1622
|
+
[MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]],
|
|
1623
|
+
[
|
|
1624
|
+
/droid [\d\.]+; (fp\du?)(?: b|\))/i
|
|
1625
|
+
],
|
|
1626
|
+
[MODEL, [VENDOR, "Fairphone"], [TYPE, MOBILE]],
|
|
1627
|
+
[
|
|
1628
|
+
/(u304aa)/i
|
|
1629
|
+
],
|
|
1630
|
+
[MODEL, [VENDOR, "AT&T"], [TYPE, MOBILE]],
|
|
1631
|
+
[
|
|
1632
|
+
/\bsie-(\w*)/i
|
|
1633
|
+
],
|
|
1634
|
+
[MODEL, [VENDOR, "Siemens"], [TYPE, MOBILE]],
|
|
1635
|
+
[
|
|
1636
|
+
/\b(rct\w+) b/i
|
|
1637
|
+
],
|
|
1638
|
+
[MODEL, [VENDOR, "RCA"], [TYPE, TABLET]],
|
|
1639
|
+
[
|
|
1640
|
+
/\b(venue[\d ]{2,7}) b/i
|
|
1641
|
+
],
|
|
1642
|
+
[MODEL, [VENDOR, "Dell"], [TYPE, TABLET]],
|
|
1643
|
+
[
|
|
1644
|
+
/\b(q(?:mv|ta)\w+) b/i
|
|
1645
|
+
],
|
|
1646
|
+
[MODEL, [VENDOR, "Verizon"], [TYPE, TABLET]],
|
|
1647
|
+
[
|
|
1648
|
+
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i
|
|
1649
|
+
],
|
|
1650
|
+
[MODEL, [VENDOR, "Barnes & Noble"], [TYPE, TABLET]],
|
|
1651
|
+
[
|
|
1652
|
+
/\b(tm\d{3}\w+) b/i
|
|
1653
|
+
],
|
|
1654
|
+
[MODEL, [VENDOR, "NuVision"], [TYPE, TABLET]],
|
|
1655
|
+
[
|
|
1656
|
+
/\b(k88) b/i
|
|
1657
|
+
],
|
|
1658
|
+
[MODEL, [VENDOR, "ZTE"], [TYPE, TABLET]],
|
|
1659
|
+
[
|
|
1660
|
+
/\b(nx\d{3}j) b/i
|
|
1661
|
+
],
|
|
1662
|
+
[MODEL, [VENDOR, "ZTE"], [TYPE, MOBILE]],
|
|
1663
|
+
[
|
|
1664
|
+
/\b(gen\d{3}) b.+49h/i
|
|
1665
|
+
],
|
|
1666
|
+
[MODEL, [VENDOR, "Swiss"], [TYPE, MOBILE]],
|
|
1667
|
+
[
|
|
1668
|
+
/\b(zur\d{3}) b/i
|
|
1669
|
+
],
|
|
1670
|
+
[MODEL, [VENDOR, "Swiss"], [TYPE, TABLET]],
|
|
1671
|
+
[
|
|
1672
|
+
/\b((zeki)?tb.*\b) b/i
|
|
1673
|
+
],
|
|
1674
|
+
[MODEL, [VENDOR, "Zeki"], [TYPE, TABLET]],
|
|
1675
|
+
[
|
|
1676
|
+
/\b([yr]\d{2}) b/i,
|
|
1677
|
+
/\b(dragon[- ]+touch |dt)(\w{5}) b/i
|
|
1678
|
+
],
|
|
1679
|
+
[[VENDOR, "Dragon Touch"], MODEL, [TYPE, TABLET]],
|
|
1680
|
+
[
|
|
1681
|
+
/\b(ns-?\w{0,9}) b/i
|
|
1682
|
+
],
|
|
1683
|
+
[MODEL, [VENDOR, "Insignia"], [TYPE, TABLET]],
|
|
1684
|
+
[
|
|
1685
|
+
/\b((nxa|next)-?\w{0,9}) b/i
|
|
1686
|
+
],
|
|
1687
|
+
[MODEL, [VENDOR, "NextBook"], [TYPE, TABLET]],
|
|
1688
|
+
[
|
|
1689
|
+
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i
|
|
1690
|
+
],
|
|
1691
|
+
[[VENDOR, "Voice"], MODEL, [TYPE, MOBILE]],
|
|
1692
|
+
[
|
|
1693
|
+
/\b(lvtel\-)?(v1[12]) b/i
|
|
1694
|
+
],
|
|
1695
|
+
[[VENDOR, "LvTel"], MODEL, [TYPE, MOBILE]],
|
|
1696
|
+
[
|
|
1697
|
+
/\b(ph-1) /i
|
|
1698
|
+
],
|
|
1699
|
+
[MODEL, [VENDOR, "Essential"], [TYPE, MOBILE]],
|
|
1700
|
+
[
|
|
1701
|
+
/\b(v(100md|700na|7011|917g).*\b) b/i
|
|
1702
|
+
],
|
|
1703
|
+
[MODEL, [VENDOR, "Envizen"], [TYPE, TABLET]],
|
|
1704
|
+
[
|
|
1705
|
+
/\b(trio[-\w\. ]+) b/i
|
|
1706
|
+
],
|
|
1707
|
+
[MODEL, [VENDOR, "MachSpeed"], [TYPE, TABLET]],
|
|
1708
|
+
[
|
|
1709
|
+
/\btu_(1491) b/i
|
|
1710
|
+
],
|
|
1711
|
+
[MODEL, [VENDOR, "Rotor"], [TYPE, TABLET]],
|
|
1712
|
+
[
|
|
1713
|
+
/(shield[\w ]+) b/i
|
|
1714
|
+
],
|
|
1715
|
+
[MODEL, [VENDOR, "Nvidia"], [TYPE, TABLET]],
|
|
1716
|
+
[
|
|
1717
|
+
/(sprint) (\w+)/i
|
|
1718
|
+
],
|
|
1719
|
+
[VENDOR, MODEL, [TYPE, MOBILE]],
|
|
1720
|
+
[
|
|
1721
|
+
/(kin\.[onetw]{3})/i
|
|
1722
|
+
],
|
|
1723
|
+
[[MODEL, /\./g, " "], [VENDOR, MICROSOFT], [TYPE, MOBILE]],
|
|
1724
|
+
[
|
|
1725
|
+
/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i
|
|
1726
|
+
],
|
|
1727
|
+
[MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]],
|
|
1728
|
+
[
|
|
1729
|
+
/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
|
|
1730
|
+
],
|
|
1731
|
+
[MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]],
|
|
1732
|
+
[
|
|
1733
|
+
/(ouya)/i,
|
|
1734
|
+
/(nintendo) ([wids3utch]+)/i
|
|
1735
|
+
],
|
|
1736
|
+
[VENDOR, MODEL, [TYPE, CONSOLE]],
|
|
1737
|
+
[
|
|
1738
|
+
/droid.+; (shield) bui/i
|
|
1739
|
+
],
|
|
1740
|
+
[MODEL, [VENDOR, "Nvidia"], [TYPE, CONSOLE]],
|
|
1741
|
+
[
|
|
1742
|
+
/(playstation [345portablevi]+)/i
|
|
1743
|
+
],
|
|
1744
|
+
[MODEL, [VENDOR, SONY], [TYPE, CONSOLE]],
|
|
1745
|
+
[
|
|
1746
|
+
/\b(xbox(?: one)?(?!; xbox))[\); ]/i
|
|
1747
|
+
],
|
|
1748
|
+
[MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]],
|
|
1749
|
+
[
|
|
1750
|
+
/smart-tv.+(samsung)/i
|
|
1751
|
+
],
|
|
1752
|
+
[VENDOR, [TYPE, SMARTTV]],
|
|
1753
|
+
[
|
|
1754
|
+
/hbbtv.+maple;(\d+)/i
|
|
1755
|
+
],
|
|
1756
|
+
[[MODEL, /^/, "SmartTV"], [VENDOR, SAMSUNG], [TYPE, SMARTTV]],
|
|
1757
|
+
[
|
|
1758
|
+
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i
|
|
1759
|
+
],
|
|
1760
|
+
[[VENDOR, LG], [TYPE, SMARTTV]],
|
|
1761
|
+
[
|
|
1762
|
+
/(apple) ?tv/i
|
|
1763
|
+
],
|
|
1764
|
+
[VENDOR, [MODEL, APPLE + " TV"], [TYPE, SMARTTV]],
|
|
1765
|
+
[
|
|
1766
|
+
/crkey/i
|
|
1767
|
+
],
|
|
1768
|
+
[[MODEL, CHROME + "cast"], [VENDOR, GOOGLE], [TYPE, SMARTTV]],
|
|
1769
|
+
[
|
|
1770
|
+
/droid.+aft(\w)( bui|\))/i
|
|
1771
|
+
],
|
|
1772
|
+
[MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]],
|
|
1773
|
+
[
|
|
1774
|
+
/\(dtv[\);].+(aquos)/i,
|
|
1775
|
+
/(aquos-tv[\w ]+)\)/i
|
|
1776
|
+
],
|
|
1777
|
+
[MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],
|
|
1778
|
+
[
|
|
1779
|
+
/(bravia[\w ]+)( bui|\))/i
|
|
1780
|
+
],
|
|
1781
|
+
[MODEL, [VENDOR, SONY], [TYPE, SMARTTV]],
|
|
1782
|
+
[
|
|
1783
|
+
/(mitv-\w{5}) bui/i
|
|
1784
|
+
],
|
|
1785
|
+
[MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]],
|
|
1786
|
+
[
|
|
1787
|
+
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,
|
|
1788
|
+
/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i
|
|
1789
|
+
],
|
|
1790
|
+
[[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]],
|
|
1791
|
+
[
|
|
1792
|
+
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i
|
|
1793
|
+
],
|
|
1794
|
+
[[TYPE, SMARTTV]],
|
|
1795
|
+
[
|
|
1796
|
+
/((pebble))app/i
|
|
1797
|
+
],
|
|
1798
|
+
[VENDOR, MODEL, [TYPE, WEARABLE]],
|
|
1799
|
+
[
|
|
1800
|
+
/droid.+; (glass) \d/i
|
|
1801
|
+
],
|
|
1802
|
+
[MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]],
|
|
1803
|
+
[
|
|
1804
|
+
/droid.+; (wt63?0{2,3})\)/i
|
|
1805
|
+
],
|
|
1806
|
+
[MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]],
|
|
1807
|
+
[
|
|
1808
|
+
/(quest( 2)?)/i
|
|
1809
|
+
],
|
|
1810
|
+
[MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]],
|
|
1811
|
+
[
|
|
1812
|
+
/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i
|
|
1813
|
+
],
|
|
1814
|
+
[VENDOR, [TYPE, EMBEDDED]],
|
|
1815
|
+
[
|
|
1816
|
+
/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i
|
|
1817
|
+
],
|
|
1818
|
+
[MODEL, [TYPE, MOBILE]],
|
|
1819
|
+
[
|
|
1820
|
+
/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i
|
|
1821
|
+
],
|
|
1822
|
+
[MODEL, [TYPE, TABLET]],
|
|
1823
|
+
[
|
|
1824
|
+
/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i
|
|
1825
|
+
],
|
|
1826
|
+
[[TYPE, TABLET]],
|
|
1827
|
+
[
|
|
1828
|
+
/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i
|
|
1829
|
+
],
|
|
1830
|
+
[[TYPE, MOBILE]],
|
|
1831
|
+
[
|
|
1832
|
+
/(android[-\w\. ]{0,9});.+buil/i
|
|
1833
|
+
],
|
|
1834
|
+
[MODEL, [VENDOR, "Generic"]]
|
|
1835
|
+
],
|
|
1836
|
+
engine: [
|
|
1837
|
+
[
|
|
1838
|
+
/windows.+ edge\/([\w\.]+)/i
|
|
1839
|
+
],
|
|
1840
|
+
[VERSION, [NAME, EDGE + "HTML"]],
|
|
1841
|
+
[
|
|
1842
|
+
/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i
|
|
1843
|
+
],
|
|
1844
|
+
[VERSION, [NAME, "Blink"]],
|
|
1845
|
+
[
|
|
1846
|
+
/(presto)\/([\w\.]+)/i,
|
|
1847
|
+
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
|
|
1848
|
+
/ekioh(flow)\/([\w\.]+)/i,
|
|
1849
|
+
/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,
|
|
1850
|
+
/(icab)[\/ ]([23]\.[\d\.]+)/i
|
|
1851
|
+
],
|
|
1852
|
+
[NAME, VERSION],
|
|
1853
|
+
[
|
|
1854
|
+
/rv\:([\w\.]{1,9})\b.+(gecko)/i
|
|
1855
|
+
],
|
|
1856
|
+
[VERSION, NAME]
|
|
1857
|
+
],
|
|
1858
|
+
os: [
|
|
1859
|
+
[
|
|
1860
|
+
/microsoft (windows) (vista|xp)/i
|
|
1861
|
+
],
|
|
1862
|
+
[NAME, VERSION],
|
|
1863
|
+
[
|
|
1864
|
+
/(windows) nt 6\.2; (arm)/i,
|
|
1865
|
+
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,
|
|
1866
|
+
/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
|
|
1867
|
+
],
|
|
1868
|
+
[NAME, [VERSION, strMapper, windowsVersionMap]],
|
|
1869
|
+
[
|
|
1870
|
+
/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
|
|
1871
|
+
],
|
|
1872
|
+
[[NAME, "Windows"], [VERSION, strMapper, windowsVersionMap]],
|
|
1873
|
+
[
|
|
1874
|
+
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,
|
|
1875
|
+
/cfnetwork\/.+darwin/i
|
|
1876
|
+
],
|
|
1877
|
+
[[VERSION, /_/g, "."], [NAME, "iOS"]],
|
|
1878
|
+
[
|
|
1879
|
+
/(mac os x) ?([\w\. ]*)/i,
|
|
1880
|
+
/(macintosh|mac_powerpc\b)(?!.+haiku)/i
|
|
1881
|
+
],
|
|
1882
|
+
[[NAME, "Mac OS"], [VERSION, /_/g, "."]],
|
|
1883
|
+
[
|
|
1884
|
+
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i
|
|
1885
|
+
],
|
|
1886
|
+
[VERSION, NAME],
|
|
1887
|
+
[
|
|
1888
|
+
/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
|
|
1889
|
+
/(blackberry)\w*\/([\w\.]*)/i,
|
|
1890
|
+
/(tizen|kaios)[\/ ]([\w\.]+)/i,
|
|
1891
|
+
/\((series40);/i
|
|
1892
|
+
],
|
|
1893
|
+
[NAME, VERSION],
|
|
1894
|
+
[
|
|
1895
|
+
/\(bb(10);/i
|
|
1896
|
+
],
|
|
1897
|
+
[VERSION, [NAME, BLACKBERRY]],
|
|
1898
|
+
[
|
|
1899
|
+
/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i
|
|
1900
|
+
],
|
|
1901
|
+
[VERSION, [NAME, "Symbian"]],
|
|
1902
|
+
[
|
|
1903
|
+
/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i
|
|
1904
|
+
],
|
|
1905
|
+
[VERSION, [NAME, FIREFOX + " OS"]],
|
|
1906
|
+
[
|
|
1907
|
+
/web0s;.+rt(tv)/i,
|
|
1908
|
+
/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i
|
|
1909
|
+
],
|
|
1910
|
+
[VERSION, [NAME, "webOS"]],
|
|
1911
|
+
[
|
|
1912
|
+
/crkey\/([\d\.]+)/i
|
|
1913
|
+
],
|
|
1914
|
+
[VERSION, [NAME, CHROME + "cast"]],
|
|
1915
|
+
[
|
|
1916
|
+
/(cros) [\w]+ ([\w\.]+\w)/i
|
|
1917
|
+
],
|
|
1918
|
+
[[NAME, "Chromium OS"], VERSION],
|
|
1919
|
+
[
|
|
1920
|
+
/(nintendo|playstation) ([wids345portablevuch]+)/i,
|
|
1921
|
+
/(xbox); +xbox ([^\);]+)/i,
|
|
1922
|
+
/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,
|
|
1923
|
+
/(mint)[\/\(\) ]?(\w*)/i,
|
|
1924
|
+
/(mageia|vectorlinux)[; ]/i,
|
|
1925
|
+
/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
|
|
1926
|
+
/(hurd|linux) ?([\w\.]*)/i,
|
|
1927
|
+
/(gnu) ?([\w\.]*)/i,
|
|
1928
|
+
/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,
|
|
1929
|
+
/(haiku) (\w+)/i
|
|
1930
|
+
],
|
|
1931
|
+
[NAME, VERSION],
|
|
1932
|
+
[
|
|
1933
|
+
/(sunos) ?([\w\.\d]*)/i
|
|
1934
|
+
],
|
|
1935
|
+
[[NAME, "Solaris"], VERSION],
|
|
1936
|
+
[
|
|
1937
|
+
/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,
|
|
1938
|
+
/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,
|
|
1939
|
+
/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,
|
|
1940
|
+
/(unix) ?([\w\.]*)/i
|
|
1941
|
+
],
|
|
1942
|
+
[NAME, VERSION]
|
|
1943
|
+
]
|
|
1944
|
+
};
|
|
1945
|
+
var UAParser = function(ua, extensions) {
|
|
1946
|
+
if (typeof ua === OBJ_TYPE) {
|
|
1947
|
+
extensions = ua;
|
|
1948
|
+
ua = undefined$1;
|
|
1949
|
+
}
|
|
1950
|
+
if (!(this instanceof UAParser)) {
|
|
1951
|
+
return new UAParser(ua, extensions).getResult();
|
|
1952
|
+
}
|
|
1953
|
+
var _ua = ua || (typeof window2 !== UNDEF_TYPE && window2.navigator && window2.navigator.userAgent ? window2.navigator.userAgent : EMPTY);
|
|
1954
|
+
var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
|
|
1955
|
+
this.getBrowser = function() {
|
|
1956
|
+
var _browser = {};
|
|
1957
|
+
_browser[NAME] = undefined$1;
|
|
1958
|
+
_browser[VERSION] = undefined$1;
|
|
1959
|
+
rgxMapper.call(_browser, _ua, _rgxmap.browser);
|
|
1960
|
+
_browser.major = majorize(_browser.version);
|
|
1961
|
+
return _browser;
|
|
1962
|
+
};
|
|
1963
|
+
this.getCPU = function() {
|
|
1964
|
+
var _cpu = {};
|
|
1965
|
+
_cpu[ARCHITECTURE] = undefined$1;
|
|
1966
|
+
rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
|
|
1967
|
+
return _cpu;
|
|
1968
|
+
};
|
|
1969
|
+
this.getDevice = function() {
|
|
1970
|
+
var _device = {};
|
|
1971
|
+
_device[VENDOR] = undefined$1;
|
|
1972
|
+
_device[MODEL] = undefined$1;
|
|
1973
|
+
_device[TYPE] = undefined$1;
|
|
1974
|
+
rgxMapper.call(_device, _ua, _rgxmap.device);
|
|
1975
|
+
return _device;
|
|
1976
|
+
};
|
|
1977
|
+
this.getEngine = function() {
|
|
1978
|
+
var _engine = {};
|
|
1979
|
+
_engine[NAME] = undefined$1;
|
|
1980
|
+
_engine[VERSION] = undefined$1;
|
|
1981
|
+
rgxMapper.call(_engine, _ua, _rgxmap.engine);
|
|
1982
|
+
return _engine;
|
|
1983
|
+
};
|
|
1984
|
+
this.getOS = function() {
|
|
1985
|
+
var _os = {};
|
|
1986
|
+
_os[NAME] = undefined$1;
|
|
1987
|
+
_os[VERSION] = undefined$1;
|
|
1988
|
+
rgxMapper.call(_os, _ua, _rgxmap.os);
|
|
1989
|
+
return _os;
|
|
1990
|
+
};
|
|
1991
|
+
this.getResult = function() {
|
|
1992
|
+
return {
|
|
1993
|
+
ua: this.getUA(),
|
|
1994
|
+
browser: this.getBrowser(),
|
|
1995
|
+
engine: this.getEngine(),
|
|
1996
|
+
os: this.getOS(),
|
|
1997
|
+
device: this.getDevice(),
|
|
1998
|
+
cpu: this.getCPU()
|
|
1999
|
+
};
|
|
2000
|
+
};
|
|
2001
|
+
this.getUA = function() {
|
|
2002
|
+
return _ua;
|
|
2003
|
+
};
|
|
2004
|
+
this.setUA = function(ua2) {
|
|
2005
|
+
_ua = typeof ua2 === STR_TYPE && ua2.length > UA_MAX_LENGTH ? trim(ua2, UA_MAX_LENGTH) : ua2;
|
|
2006
|
+
return this;
|
|
2007
|
+
};
|
|
2008
|
+
this.setUA(_ua);
|
|
2009
|
+
return this;
|
|
2010
|
+
};
|
|
2011
|
+
UAParser.VERSION = LIBVERSION;
|
|
2012
|
+
UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
|
|
2013
|
+
UAParser.CPU = enumerize([ARCHITECTURE]);
|
|
2014
|
+
UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
|
|
2015
|
+
UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
|
|
2016
|
+
{
|
|
2017
|
+
if (module2.exports) {
|
|
2018
|
+
exports2 = module2.exports = UAParser;
|
|
2019
|
+
}
|
|
2020
|
+
exports2.UAParser = UAParser;
|
|
2021
|
+
}
|
|
2022
|
+
var $ = typeof window2 !== UNDEF_TYPE && (window2.jQuery || window2.Zepto);
|
|
2023
|
+
if ($ && !$.ua) {
|
|
2024
|
+
var parser = new UAParser();
|
|
2025
|
+
$.ua = parser.getResult();
|
|
2026
|
+
$.ua.get = function() {
|
|
2027
|
+
return parser.getUA();
|
|
2028
|
+
};
|
|
2029
|
+
$.ua.set = function(ua) {
|
|
2030
|
+
parser.setUA(ua);
|
|
2031
|
+
var result = parser.getResult();
|
|
2032
|
+
for (var prop in result) {
|
|
2033
|
+
$.ua[prop] = result[prop];
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
})(typeof window === "object" ? window : commonjsGlobal);
|
|
2038
|
+
})(uaParser, uaParser.exports);
|
|
2039
|
+
var __defProp2 = Object.defineProperty;
|
|
2040
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2041
|
+
var __publicField2 = (obj, key, value) => {
|
|
2042
|
+
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2043
|
+
return value;
|
|
2044
|
+
};
|
|
2045
|
+
const Browser = {
|
|
2046
|
+
UNKNOWN: "Unknown",
|
|
2047
|
+
SAFARI: "Safari",
|
|
2048
|
+
FIREFOX: "Firefox",
|
|
2049
|
+
OPERA: "Opera",
|
|
2050
|
+
CHROME: "Chrome",
|
|
2051
|
+
IOS_WEBVIEW: "iOS-webview"
|
|
2052
|
+
};
|
|
2053
|
+
class BrowserUtils {
|
|
2054
|
+
static getName() {
|
|
2055
|
+
if (!this._name) {
|
|
2056
|
+
if (typeof navigator === "undefined" || !navigator) {
|
|
2057
|
+
this._name = Browser.UNKNOWN;
|
|
2058
|
+
} else {
|
|
2059
|
+
const { userAgent } = navigator;
|
|
2060
|
+
if (userAgent.match(/Firefox/i)) {
|
|
2061
|
+
this._name = Browser.FIREFOX;
|
|
2062
|
+
} else if (userAgent.match(/(Opera|OPR)/i)) {
|
|
2063
|
+
this._name = Browser.OPERA;
|
|
2064
|
+
} else if (userAgent.match(/Chrome/i)) {
|
|
2065
|
+
this._name = Browser.CHROME;
|
|
2066
|
+
} else if (userAgent.match(/Safari/i)) {
|
|
2067
|
+
this._name = Browser.SAFARI;
|
|
2068
|
+
} else if (userAgent.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i)) {
|
|
2069
|
+
this._name = Browser.IOS_WEBVIEW;
|
|
2070
|
+
} else {
|
|
2071
|
+
this._name = Browser.UNKNOWN;
|
|
2072
|
+
}
|
|
1172
2073
|
}
|
|
1173
|
-
throw Error("Level of: " + this.coords.toString() + " cannot be decided");
|
|
1174
2074
|
}
|
|
2075
|
+
return this._name;
|
|
1175
2076
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
2077
|
+
static get isMobile() {
|
|
2078
|
+
if (this._isMobile === null) {
|
|
2079
|
+
this._isMobile = false;
|
|
2080
|
+
if (typeof navigator !== "undefined" && navigator) {
|
|
2081
|
+
const userAgent = navigator.userAgent || navigator.vendor;
|
|
2082
|
+
if (userAgent && (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4)))) {
|
|
2083
|
+
this._isMobile = true;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
1180
2086
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
2087
|
+
return this._isMobile;
|
|
2088
|
+
}
|
|
2089
|
+
static clearCache() {
|
|
2090
|
+
this._name = null;
|
|
2091
|
+
this._isMobile = null;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
__publicField2(BrowserUtils, "_name", null);
|
|
2095
|
+
__publicField2(BrowserUtils, "_isMobile", null);
|
|
2096
|
+
const _GraphVertex = class {
|
|
2097
|
+
constructor(params = {}) {
|
|
2098
|
+
__publicField2(this, "name", null);
|
|
2099
|
+
__publicField2(this, "data", null);
|
|
2100
|
+
__publicField2(this, "id");
|
|
2101
|
+
__publicField2(this, "edges", []);
|
|
2102
|
+
Object.assign(this, params);
|
|
2103
|
+
if (typeof params.id === "number") {
|
|
2104
|
+
this.id = params.id;
|
|
2105
|
+
GraphEdge.currentUniqueId = Math.max(GraphEdge.currentUniqueId, params.id + 1);
|
|
2106
|
+
} else {
|
|
2107
|
+
this.id = _GraphVertex.currentUniqueId++;
|
|
1186
2108
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
let GraphVertex = _GraphVertex;
|
|
2112
|
+
__publicField2(GraphVertex, "currentUniqueId", 0);
|
|
2113
|
+
const _GraphEdge = class {
|
|
2114
|
+
constructor(vertex1, vertex2, params = {}) {
|
|
2115
|
+
__publicField2(this, "name", null);
|
|
2116
|
+
__publicField2(this, "data", null);
|
|
2117
|
+
__publicField2(this, "id");
|
|
2118
|
+
__publicField2(this, "_vertex1");
|
|
2119
|
+
__publicField2(this, "_vertex2");
|
|
2120
|
+
Object.assign(this, params);
|
|
2121
|
+
this.vertex1 = vertex1;
|
|
2122
|
+
this.vertex2 = vertex2;
|
|
2123
|
+
if (typeof params.id === "number") {
|
|
2124
|
+
this.id = params.id;
|
|
2125
|
+
_GraphEdge.currentUniqueId = Math.max(_GraphEdge.currentUniqueId, params.id + 1);
|
|
2126
|
+
} else {
|
|
2127
|
+
this.id = GraphVertex.currentUniqueId++;
|
|
1189
2128
|
}
|
|
1190
|
-
return true;
|
|
1191
2129
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return true;
|
|
2130
|
+
get vertex1() {
|
|
2131
|
+
return this._vertex1;
|
|
1195
2132
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
2133
|
+
set vertex1(vertex) {
|
|
2134
|
+
if (this._vertex1 && this._vertex2 !== this._vertex1) {
|
|
2135
|
+
this._vertex1.edges = this._vertex1.edges.filter((edge) => edge !== this);
|
|
2136
|
+
}
|
|
2137
|
+
vertex.edges.push(this);
|
|
2138
|
+
this._vertex1 = vertex;
|
|
2139
|
+
}
|
|
2140
|
+
get vertex2() {
|
|
2141
|
+
return this._vertex2;
|
|
2142
|
+
}
|
|
2143
|
+
set vertex2(vertex) {
|
|
2144
|
+
if (this._vertex2 && this._vertex2 !== this._vertex1) {
|
|
2145
|
+
this._vertex2.edges = this._vertex2.edges.filter((edge) => edge !== this);
|
|
2146
|
+
}
|
|
2147
|
+
vertex.edges.push(this);
|
|
2148
|
+
this._vertex2 = vertex;
|
|
2149
|
+
}
|
|
2150
|
+
static getEdgeByVertices(edges, vertex1, vertex2) {
|
|
2151
|
+
return edges.find(
|
|
2152
|
+
(edge) => vertex1 === edge.vertex1 && vertex2 === edge.vertex2 || vertex2 === edge.vertex1 && vertex1 === edge.vertex2
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
let GraphEdge = _GraphEdge;
|
|
2157
|
+
__publicField2(GraphEdge, "currentUniqueId", 0);
|
|
2158
|
+
class Graph {
|
|
2159
|
+
constructor(vertices, edges) {
|
|
2160
|
+
__publicField2(this, "vertices");
|
|
2161
|
+
__publicField2(this, "edges");
|
|
2162
|
+
this.vertices = Array.isArray(vertices) ? vertices : [];
|
|
2163
|
+
this.edges = Array.isArray(edges) ? edges : [];
|
|
2164
|
+
}
|
|
2165
|
+
getEdgeByVertices(vertex1, vertex2) {
|
|
2166
|
+
return GraphEdge.getEdgeByVertices(this.edges, vertex1, vertex2);
|
|
2167
|
+
}
|
|
2168
|
+
getVertexByName(name) {
|
|
2169
|
+
return this.vertices.find((vertex) => vertex.name === name);
|
|
2170
|
+
}
|
|
2171
|
+
getEdgeByName(name) {
|
|
2172
|
+
return this.edges.find((edge) => edge.name === name);
|
|
2173
|
+
}
|
|
2174
|
+
toDetailedString() {
|
|
2175
|
+
let output = `--- Network ---
|
|
2176
|
+
Vertices: ${this.vertices.length}
|
|
2177
|
+
Edges: ${this.edges.length}
|
|
2178
|
+
---
|
|
2179
|
+
Vertices
|
|
2180
|
+
`;
|
|
2181
|
+
this.vertices.forEach((vertex) => {
|
|
2182
|
+
output += `${vertex.id} [edges: ${vertex.edges.length}]
|
|
2183
|
+
`;
|
|
2184
|
+
});
|
|
2185
|
+
output += "---\nEdges\n";
|
|
2186
|
+
this.edges.forEach((edge) => {
|
|
2187
|
+
output += `${edge.id} `;
|
|
2188
|
+
output += `[${edge.vertex1.id} -- ${edge.vertex2.id}]
|
|
2189
|
+
`;
|
|
2190
|
+
});
|
|
2191
|
+
output += "---";
|
|
2192
|
+
return output;
|
|
1201
2193
|
}
|
|
1202
2194
|
}
|
|
1203
|
-
class GraphEdge {
|
|
1204
|
-
constructor(
|
|
1205
|
-
|
|
1206
|
-
__publicField(this, "_node2");
|
|
2195
|
+
class GeoGraphEdge extends GraphEdge {
|
|
2196
|
+
constructor(vertex1, vertex2, params) {
|
|
2197
|
+
super(vertex1, vertex2, params);
|
|
1207
2198
|
__publicField(this, "_level", null);
|
|
1208
2199
|
__publicField(this, "_bearing", null);
|
|
1209
2200
|
__publicField(this, "_length", null);
|
|
1210
2201
|
__publicField(this, "_computedSizeAndBearing", false);
|
|
1211
|
-
__publicField(this, "builtFrom");
|
|
1212
2202
|
__publicField(this, "isOneway", false);
|
|
1213
|
-
this
|
|
1214
|
-
this.node2 = node2;
|
|
1215
|
-
this.level = level;
|
|
1216
|
-
this.builtFrom = builtFrom;
|
|
1217
|
-
}
|
|
1218
|
-
get node1() {
|
|
1219
|
-
return this._node1;
|
|
2203
|
+
Object.assign(this, params);
|
|
1220
2204
|
}
|
|
1221
|
-
set
|
|
1222
|
-
|
|
1223
|
-
throw new TypeError("node1 is not a GraphNode");
|
|
1224
|
-
}
|
|
1225
|
-
if (this._node1 instanceof GraphNode && this._node2 !== this._node1) {
|
|
1226
|
-
this._node1.edges = this._node1.edges.filter((edge) => edge !== this);
|
|
1227
|
-
}
|
|
1228
|
-
node.edges.push(this);
|
|
1229
|
-
this._node1 = node;
|
|
2205
|
+
set vertex1(vertex) {
|
|
2206
|
+
super.vertex1 = vertex;
|
|
1230
2207
|
this._computedSizeAndBearing = false;
|
|
1231
2208
|
}
|
|
1232
|
-
get
|
|
1233
|
-
return this.
|
|
2209
|
+
get vertex1() {
|
|
2210
|
+
return this._vertex1;
|
|
1234
2211
|
}
|
|
1235
|
-
set
|
|
1236
|
-
|
|
1237
|
-
throw new TypeError("node2 is not a GraphNode");
|
|
1238
|
-
}
|
|
1239
|
-
if (this._node2 instanceof GraphNode && this._node2 !== this._node1) {
|
|
1240
|
-
this._node2.edges = this._node2.edges.filter((edge) => edge !== this);
|
|
1241
|
-
}
|
|
1242
|
-
node.edges.push(this);
|
|
1243
|
-
this._node2 = node;
|
|
2212
|
+
set vertex2(vertex) {
|
|
2213
|
+
super.vertex2 = vertex;
|
|
1244
2214
|
this._computedSizeAndBearing = false;
|
|
1245
2215
|
}
|
|
2216
|
+
get vertex2() {
|
|
2217
|
+
return this._vertex2;
|
|
2218
|
+
}
|
|
1246
2219
|
get level() {
|
|
1247
2220
|
return this._level;
|
|
1248
2221
|
}
|
|
@@ -1263,154 +2236,206 @@ class GraphEdge {
|
|
|
1263
2236
|
return this._length;
|
|
1264
2237
|
}
|
|
1265
2238
|
_computeSizeAndBearing() {
|
|
1266
|
-
this._length = this.
|
|
1267
|
-
this._bearing = this.
|
|
2239
|
+
this._length = this.vertex1.distanceTo(this.vertex2);
|
|
2240
|
+
this._bearing = this.vertex1.bearingTo(this.vertex2);
|
|
1268
2241
|
this._computedSizeAndBearing = true;
|
|
1269
2242
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
2243
|
+
static getEdgeByVertices(edges, vertex1, vertex2) {
|
|
2244
|
+
return super.getEdgeByVertices(edges, vertex1, vertex2);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
class GeoGraphVertex extends GraphVertex {
|
|
2248
|
+
constructor(coords, params) {
|
|
2249
|
+
super(params);
|
|
2250
|
+
__publicField(this, "coords");
|
|
2251
|
+
__publicField(this, "io", false);
|
|
2252
|
+
this.coords = coords;
|
|
2253
|
+
}
|
|
2254
|
+
distanceTo(other) {
|
|
2255
|
+
return this.coords.distanceTo(other.coords);
|
|
2256
|
+
}
|
|
2257
|
+
bearingTo(other) {
|
|
2258
|
+
return this.coords.bearingTo(other.coords);
|
|
2259
|
+
}
|
|
2260
|
+
toJson() {
|
|
2261
|
+
return this.coords.toCompressedJson();
|
|
2262
|
+
}
|
|
2263
|
+
static fromJson(json) {
|
|
2264
|
+
return new GeoGraphVertex(Coordinates.fromCompressedJson(json));
|
|
2265
|
+
}
|
|
2266
|
+
inferVertexLevelFromEdges() {
|
|
2267
|
+
let tmpLevel = null;
|
|
2268
|
+
for (let i = 0; i < this.edges.length; i++) {
|
|
2269
|
+
const edge = this.edges[i];
|
|
2270
|
+
if (edge.level !== null) {
|
|
2271
|
+
if (tmpLevel === null) {
|
|
2272
|
+
tmpLevel = Level.clone(edge.level);
|
|
2273
|
+
} else {
|
|
2274
|
+
tmpLevel = Level.intersection(tmpLevel, edge.level);
|
|
2275
|
+
if (tmpLevel === null) {
|
|
2276
|
+
throw Error("Something bad happend during parsing: We cannot retrieve vertex level from adjacent ways: " + this.coords);
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
this.coords.level = tmpLevel;
|
|
2282
|
+
}
|
|
2283
|
+
inferVertexLevelByNeighboors() {
|
|
2284
|
+
const { level } = this.coords;
|
|
2285
|
+
if (level === null || !Level.isRange(level)) {
|
|
1272
2286
|
return true;
|
|
1273
2287
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
2288
|
+
let tmpLevel = null;
|
|
2289
|
+
for (let i = 0; i < this.edges.length; i++) {
|
|
2290
|
+
const edge = this.edges[i];
|
|
2291
|
+
const otherVertex = edge.vertex1 === this ? edge.vertex2 : edge.vertex1;
|
|
2292
|
+
tmpLevel = Level.union(otherVertex.coords.level, tmpLevel);
|
|
1276
2293
|
}
|
|
1277
|
-
|
|
2294
|
+
if (tmpLevel === null || !Level.isRange(tmpLevel)) {
|
|
2295
|
+
this.coords.level = tmpLevel === level[0] ? level[1] : level[0];
|
|
2296
|
+
}
|
|
2297
|
+
return true;
|
|
1278
2298
|
}
|
|
1279
|
-
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
2299
|
+
inferVertexLevelByRecursion() {
|
|
2300
|
+
const { level } = this.coords;
|
|
2301
|
+
if (level === null || !Level.isRange(level)) {
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
if (this.edges.length > 1) {
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
const lookForLevel = (vertex, visitedVertices) => {
|
|
2308
|
+
visitedVertices.push(vertex);
|
|
2309
|
+
if (vertex.coords.level === null) {
|
|
2310
|
+
return null;
|
|
2311
|
+
}
|
|
2312
|
+
if (!Level.isRange(vertex.coords.level)) {
|
|
2313
|
+
return vertex.coords.level;
|
|
2314
|
+
}
|
|
2315
|
+
let tmpLevel = null;
|
|
2316
|
+
for (let i = 0; i < vertex.edges.length; i++) {
|
|
2317
|
+
const edge = vertex.edges[i];
|
|
2318
|
+
const otherVertex = edge.vertex1 === vertex ? edge.vertex2 : edge.vertex1;
|
|
2319
|
+
if (!visitedVertices.includes(otherVertex)) {
|
|
2320
|
+
tmpLevel = Level.union(lookForLevel(otherVertex, visitedVertices), tmpLevel);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
return tmpLevel;
|
|
2324
|
+
};
|
|
2325
|
+
const othersLevels = lookForLevel(this, []);
|
|
2326
|
+
if (othersLevels !== null) {
|
|
2327
|
+
if (!Level.isRange(othersLevels)) {
|
|
2328
|
+
this.coords.level = othersLevels === level[0] ? level[1] : level[0];
|
|
2329
|
+
return;
|
|
2330
|
+
}
|
|
2331
|
+
throw Error("Level of: " + this.coords.toString() + " cannot be decided");
|
|
2332
|
+
}
|
|
1283
2333
|
}
|
|
1284
2334
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
(
|
|
1288
|
-
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
getEdgeByNodes,
|
|
1296
|
-
getNodeByCoords
|
|
1297
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1298
|
-
class Network {
|
|
1299
|
-
constructor(nodes, edges) {
|
|
1300
|
-
__publicField(this, "nodes");
|
|
1301
|
-
__publicField(this, "edges");
|
|
1302
|
-
this.nodes = Array.isArray(nodes) ? nodes : [];
|
|
1303
|
-
this.edges = Array.isArray(edges) ? edges : [];
|
|
2335
|
+
class GeoGraph extends Graph {
|
|
2336
|
+
constructor(vertices, edges, generateVerticesLevels = false) {
|
|
2337
|
+
super(vertices, edges);
|
|
2338
|
+
generateVerticesLevels && this.generateVerticesLevels();
|
|
2339
|
+
}
|
|
2340
|
+
getVertexByCoords(coords) {
|
|
2341
|
+
return GeoGraph.getVertexByCoords(this.vertices, coords);
|
|
2342
|
+
}
|
|
2343
|
+
static getVertexByCoords(vertices, coords) {
|
|
2344
|
+
return vertices.find((vertex) => vertex.coords.equals(coords));
|
|
1304
2345
|
}
|
|
1305
|
-
|
|
1306
|
-
return
|
|
2346
|
+
getVertexByName(name) {
|
|
2347
|
+
return super.getVertexByName(name);
|
|
1307
2348
|
}
|
|
1308
|
-
|
|
1309
|
-
return
|
|
2349
|
+
getEdgeByName(name) {
|
|
2350
|
+
return super.getEdgeByName(name);
|
|
1310
2351
|
}
|
|
1311
2352
|
getBoundingBox(extendedMeasure) {
|
|
1312
|
-
if (!this.
|
|
2353
|
+
if (!this.vertices.length) {
|
|
1313
2354
|
return null;
|
|
1314
2355
|
}
|
|
1315
|
-
const boundingBox = BoundingBox.fromCoordinates(this.
|
|
2356
|
+
const boundingBox = BoundingBox.fromCoordinates(this.vertices.map((vertex) => vertex.coords));
|
|
1316
2357
|
if (extendedMeasure) {
|
|
1317
2358
|
boundingBox.extendsWithMeasure(extendedMeasure);
|
|
1318
2359
|
}
|
|
1319
2360
|
return boundingBox;
|
|
1320
2361
|
}
|
|
1321
|
-
toDetailedString(_nodeToStringFn, _edgeToStringFn) {
|
|
1322
|
-
let nodeToStringFn = _nodeToStringFn;
|
|
1323
|
-
if (!nodeToStringFn) {
|
|
1324
|
-
nodeToStringFn = (node) => `${node.builtFrom}`;
|
|
1325
|
-
}
|
|
1326
|
-
let edgeToStringFn = _edgeToStringFn;
|
|
1327
|
-
if (!_edgeToStringFn) {
|
|
1328
|
-
edgeToStringFn = (edge) => `${edge.builtFrom}`;
|
|
1329
|
-
}
|
|
1330
|
-
let output = `--- Network ---
|
|
1331
|
-
Nodes: ${this.nodes.length}
|
|
1332
|
-
Edges: ${this.edges.length}
|
|
1333
|
-
---
|
|
1334
|
-
Nodes
|
|
1335
|
-
`;
|
|
1336
|
-
this.nodes.forEach((node) => {
|
|
1337
|
-
output += `${nodeToStringFn(node)} [edges: ${node.edges.length}]
|
|
1338
|
-
`;
|
|
1339
|
-
});
|
|
1340
|
-
output += "---\nEdges\n";
|
|
1341
|
-
this.edges.forEach((edge) => {
|
|
1342
|
-
output += `${edgeToStringFn(edge)} `;
|
|
1343
|
-
output += `[${nodeToStringFn(edge.node1)} -- ${nodeToStringFn(edge.node2)}]
|
|
1344
|
-
`;
|
|
1345
|
-
});
|
|
1346
|
-
output += "---";
|
|
1347
|
-
return output;
|
|
1348
|
-
}
|
|
1349
2362
|
toCompressedJson() {
|
|
1350
2363
|
return {
|
|
1351
|
-
|
|
2364
|
+
vertices: this.vertices.map((vertex) => vertex.toJson()),
|
|
1352
2365
|
edges: this.edges.map((edge) => {
|
|
1353
|
-
const
|
|
1354
|
-
const
|
|
2366
|
+
const vertex1Idx = this.vertices.indexOf(edge.vertex1);
|
|
2367
|
+
const vertex2Idx = this.vertices.indexOf(edge.vertex2);
|
|
1355
2368
|
if (edge.isOneway) {
|
|
1356
|
-
return [
|
|
2369
|
+
return [vertex1Idx, vertex2Idx, edge.level, true];
|
|
1357
2370
|
}
|
|
1358
|
-
if (edge.level) {
|
|
1359
|
-
return [
|
|
2371
|
+
if (edge.level !== null) {
|
|
2372
|
+
return [vertex1Idx, vertex2Idx, edge.level];
|
|
1360
2373
|
}
|
|
1361
|
-
return [
|
|
2374
|
+
return [vertex1Idx, vertex2Idx];
|
|
1362
2375
|
})
|
|
1363
2376
|
};
|
|
1364
2377
|
}
|
|
1365
2378
|
static fromCompressedJson(json) {
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
const edge = new
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
jsonEdge[2]
|
|
1373
|
-
null
|
|
2379
|
+
const geograph = new GeoGraph();
|
|
2380
|
+
geograph.vertices = json.vertices.map((vertex) => GeoGraphVertex.fromJson(vertex));
|
|
2381
|
+
geograph.edges = json.edges.map((jsonEdge) => {
|
|
2382
|
+
const edge = new GeoGraphEdge(
|
|
2383
|
+
geograph.vertices[jsonEdge[0]],
|
|
2384
|
+
geograph.vertices[jsonEdge[1]],
|
|
2385
|
+
{ level: jsonEdge.length > 2 ? jsonEdge[2] : null }
|
|
1374
2386
|
);
|
|
1375
2387
|
if (jsonEdge.length > 3 && jsonEdge[3]) {
|
|
1376
2388
|
edge.isOneway = true;
|
|
1377
2389
|
}
|
|
1378
2390
|
return edge;
|
|
1379
2391
|
});
|
|
1380
|
-
return
|
|
2392
|
+
return geograph;
|
|
1381
2393
|
}
|
|
1382
2394
|
static fromCoordinates(segments) {
|
|
1383
|
-
const
|
|
1384
|
-
const
|
|
1385
|
-
const
|
|
1386
|
-
if (
|
|
1387
|
-
return
|
|
2395
|
+
const geograph = new GeoGraph();
|
|
2396
|
+
const getOrCreateVertex = (coords) => {
|
|
2397
|
+
const vertex = geograph.vertices.find((otherVertex) => otherVertex.coords.equals(coords));
|
|
2398
|
+
if (vertex) {
|
|
2399
|
+
return vertex;
|
|
1388
2400
|
}
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
return
|
|
2401
|
+
const newVertex = new GeoGraphVertex(coords);
|
|
2402
|
+
geograph.vertices.push(newVertex);
|
|
2403
|
+
return newVertex;
|
|
1392
2404
|
};
|
|
1393
|
-
const
|
|
2405
|
+
const createEdgeFromVertices = (vertex1, vertex2) => new GeoGraphEdge(
|
|
2406
|
+
vertex1,
|
|
2407
|
+
vertex2,
|
|
2408
|
+
{ level: Level.union(vertex1.coords.level, vertex2.coords.level) }
|
|
2409
|
+
);
|
|
1394
2410
|
for (const segment of segments) {
|
|
1395
|
-
let
|
|
2411
|
+
let previousVertex = null;
|
|
1396
2412
|
for (const coords of segment) {
|
|
1397
|
-
const
|
|
1398
|
-
if (
|
|
1399
|
-
const edge =
|
|
1400
|
-
|
|
2413
|
+
const currentVertex = getOrCreateVertex(coords);
|
|
2414
|
+
if (previousVertex) {
|
|
2415
|
+
const edge = createEdgeFromVertices(currentVertex, previousVertex);
|
|
2416
|
+
geograph.edges.push(edge);
|
|
1401
2417
|
}
|
|
1402
|
-
|
|
2418
|
+
previousVertex = currentVertex;
|
|
1403
2419
|
}
|
|
1404
2420
|
}
|
|
1405
|
-
return
|
|
2421
|
+
return geograph;
|
|
1406
2422
|
}
|
|
1407
2423
|
getEdgesAtLevel(targetLevel, useMultiLevelEdges = true) {
|
|
1408
2424
|
return this.edges.filter(
|
|
1409
2425
|
({ level }) => useMultiLevelEdges ? Level.intersect(targetLevel, level) : Level.contains(targetLevel, level)
|
|
1410
2426
|
);
|
|
1411
2427
|
}
|
|
2428
|
+
generateVerticesLevels() {
|
|
2429
|
+
const { vertices } = this;
|
|
2430
|
+
vertices.forEach((vertex) => vertex.inferVertexLevelFromEdges());
|
|
2431
|
+
vertices.forEach((vertex) => vertex.inferVertexLevelByNeighboors());
|
|
2432
|
+
vertices.forEach((vertex) => vertex.inferVertexLevelByRecursion());
|
|
2433
|
+
vertices.forEach((vertex) => {
|
|
2434
|
+
vertex.io = vertex.coords.level !== null && vertex.edges.some((edge) => edge.level === null);
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
1412
2437
|
}
|
|
1413
|
-
class
|
|
2438
|
+
class GeoGraphProjection {
|
|
1414
2439
|
constructor(origin, distanceFromNearestElement, coords, nearestElement) {
|
|
1415
2440
|
__publicField(this, "origin");
|
|
1416
2441
|
__publicField(this, "distanceFromNearestElement");
|
|
@@ -1422,12 +2447,12 @@ class GraphProjection {
|
|
|
1422
2447
|
this.nearestElement = nearestElement;
|
|
1423
2448
|
}
|
|
1424
2449
|
}
|
|
1425
|
-
const
|
|
1426
|
-
constructor(
|
|
1427
|
-
__publicField(this, "
|
|
2450
|
+
const _GeoGraphProjectionHandler = class {
|
|
2451
|
+
constructor(graph = null) {
|
|
2452
|
+
__publicField(this, "graph", null);
|
|
1428
2453
|
__publicField(this, "_maxDistance", Number.MAX_VALUE);
|
|
1429
2454
|
__publicField(this, "_maxAngleBearing", Math.PI);
|
|
1430
|
-
this.
|
|
2455
|
+
this.graph = graph;
|
|
1431
2456
|
}
|
|
1432
2457
|
set maxAngleBearing(maxAngleBearing) {
|
|
1433
2458
|
this._maxAngleBearing = maxAngleBearing;
|
|
@@ -1446,18 +2471,18 @@ const _MapMatching = class {
|
|
|
1446
2471
|
return [false, false, false];
|
|
1447
2472
|
}
|
|
1448
2473
|
let checkEdge = Level.intersect(location.level, edge.level);
|
|
1449
|
-
let checkNode1 = Level.intersect(location.level, edge.
|
|
1450
|
-
let checkNode2 = Level.intersect(location.level, edge.
|
|
1451
|
-
checkNode1 = checkNode1 || edge.
|
|
1452
|
-
checkNode2 = checkNode2 || edge.
|
|
2474
|
+
let checkNode1 = Level.intersect(location.level, edge.vertex1.coords.level);
|
|
2475
|
+
let checkNode2 = Level.intersect(location.level, edge.vertex2.coords.level);
|
|
2476
|
+
checkNode1 = checkNode1 || edge.vertex1.io && location.level === null;
|
|
2477
|
+
checkNode2 = checkNode2 || edge.vertex2.io && location.level === null;
|
|
1453
2478
|
if (!useMultiLevelSegments) {
|
|
1454
2479
|
checkEdge = checkEdge && !Level.isRange(edge.level);
|
|
1455
|
-
checkNode1 = checkNode1 && !Level.isRange(edge.
|
|
1456
|
-
checkNode2 = checkNode2 && !Level.isRange(edge.
|
|
2480
|
+
checkNode1 = checkNode1 && !Level.isRange(edge.vertex1.coords.level);
|
|
2481
|
+
checkNode2 = checkNode2 && !Level.isRange(edge.vertex2.coords.level);
|
|
1457
2482
|
}
|
|
1458
2483
|
if (useBearing) {
|
|
1459
2484
|
if (checkEdge) {
|
|
1460
|
-
const diffAngle = diffAngleLines(edge.bearing, location.bearing);
|
|
2485
|
+
const diffAngle = maths.diffAngleLines(edge.bearing, location.bearing);
|
|
1461
2486
|
if (diffAngle > this._maxAngleBearing) {
|
|
1462
2487
|
checkEdge = false;
|
|
1463
2488
|
}
|
|
@@ -1478,11 +2503,8 @@ const _MapMatching = class {
|
|
|
1478
2503
|
}
|
|
1479
2504
|
}
|
|
1480
2505
|
getProjection(location, useDistance = false, useBearing = false, useMultiLevelSegments = true, acceptEdgeFn = () => true) {
|
|
1481
|
-
if (this.
|
|
1482
|
-
throw new Error("
|
|
1483
|
-
}
|
|
1484
|
-
if (!(location instanceof Coordinates)) {
|
|
1485
|
-
throw new TypeError("location is not an instance of Coordinates");
|
|
2506
|
+
if (this.graph === null) {
|
|
2507
|
+
throw new Error("Graph has not been set yet");
|
|
1486
2508
|
}
|
|
1487
2509
|
if (useBearing && (!("bearing" in location && location.bearing !== null) || !this._maxAngleBearing)) {
|
|
1488
2510
|
return null;
|
|
@@ -1493,7 +2515,7 @@ const _MapMatching = class {
|
|
|
1493
2515
|
const isProjectionBetter = (distanceOfNewProjection) => {
|
|
1494
2516
|
return distanceOfNewProjection < distanceFromNearestElement && (!useDistance || distanceOfNewProjection <= this._maxDistance);
|
|
1495
2517
|
};
|
|
1496
|
-
for (const edge of this.
|
|
2518
|
+
for (const edge of this.graph.edges) {
|
|
1497
2519
|
const [checkEdge, checkNode1, checkNode2] = this._shouldProjectOnEdgeAndNodes(
|
|
1498
2520
|
edge,
|
|
1499
2521
|
location,
|
|
@@ -1502,38 +2524,38 @@ const _MapMatching = class {
|
|
|
1502
2524
|
acceptEdgeFn
|
|
1503
2525
|
);
|
|
1504
2526
|
if (checkNode1) {
|
|
1505
|
-
const distNode1 = location.distanceTo(edge.
|
|
2527
|
+
const distNode1 = location.distanceTo(edge.vertex1.coords);
|
|
1506
2528
|
if (isProjectionBetter(distNode1) || distNode1 <= EPS_MM) {
|
|
1507
2529
|
distanceFromNearestElement = distNode1;
|
|
1508
|
-
nearestElement = edge.
|
|
1509
|
-
|
|
1510
|
-
|
|
2530
|
+
nearestElement = edge.vertex1;
|
|
2531
|
+
_GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex1.coords, projection);
|
|
2532
|
+
_GeoGraphProjectionHandler._handleLevelsWithIONodes(projection, location, edge.vertex1);
|
|
1511
2533
|
if (distNode1 <= EPS_MM) {
|
|
1512
2534
|
break;
|
|
1513
2535
|
}
|
|
1514
2536
|
}
|
|
1515
2537
|
}
|
|
1516
2538
|
if (checkNode2) {
|
|
1517
|
-
const distNode2 = location.distanceTo(edge.
|
|
2539
|
+
const distNode2 = location.distanceTo(edge.vertex2.coords);
|
|
1518
2540
|
if (isProjectionBetter(distNode2) || distNode2 <= EPS_MM) {
|
|
1519
2541
|
distanceFromNearestElement = distNode2;
|
|
1520
|
-
nearestElement = edge.
|
|
1521
|
-
|
|
1522
|
-
|
|
2542
|
+
nearestElement = edge.vertex2;
|
|
2543
|
+
_GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex2.coords, projection);
|
|
2544
|
+
_GeoGraphProjectionHandler._handleLevelsWithIONodes(projection, location, edge.vertex2);
|
|
1523
2545
|
if (distNode2 <= EPS_MM) {
|
|
1524
2546
|
break;
|
|
1525
2547
|
}
|
|
1526
2548
|
}
|
|
1527
2549
|
}
|
|
1528
2550
|
if (checkEdge) {
|
|
1529
|
-
const segmentProjection = location.getSegmentProjection(edge.
|
|
2551
|
+
const segmentProjection = location.getSegmentProjection(edge.vertex1.coords, edge.vertex2.coords);
|
|
1530
2552
|
if (segmentProjection) {
|
|
1531
2553
|
const distEdge = location.distanceTo(segmentProjection);
|
|
1532
2554
|
if (isProjectionBetter(distEdge)) {
|
|
1533
2555
|
distanceFromNearestElement = distEdge;
|
|
1534
2556
|
nearestElement = edge;
|
|
1535
|
-
|
|
1536
|
-
|
|
2557
|
+
_GeoGraphProjectionHandler._assignLatLngLevel(segmentProjection, projection);
|
|
2558
|
+
_GeoGraphProjectionHandler._updateProjectionLevelFromEdge(edge, projection);
|
|
1537
2559
|
}
|
|
1538
2560
|
}
|
|
1539
2561
|
}
|
|
@@ -1544,7 +2566,7 @@ const _MapMatching = class {
|
|
|
1544
2566
|
if (projection instanceof UserPosition && projection.accuracy !== null) {
|
|
1545
2567
|
projection.accuracy += distanceFromNearestElement;
|
|
1546
2568
|
}
|
|
1547
|
-
return new
|
|
2569
|
+
return new GeoGraphProjection(
|
|
1548
2570
|
location,
|
|
1549
2571
|
distanceFromNearestElement,
|
|
1550
2572
|
projection,
|
|
@@ -1552,74 +2574,59 @@ const _MapMatching = class {
|
|
|
1552
2574
|
);
|
|
1553
2575
|
}
|
|
1554
2576
|
};
|
|
1555
|
-
let
|
|
1556
|
-
__publicField(
|
|
2577
|
+
let GeoGraphProjectionHandler = _GeoGraphProjectionHandler;
|
|
2578
|
+
__publicField(GeoGraphProjectionHandler, "_updateProjectionLevelFromEdge", (_edge, _projection) => {
|
|
1557
2579
|
_projection.level = Level.clone(_edge.level);
|
|
1558
2580
|
});
|
|
1559
|
-
class
|
|
1560
|
-
constructor(start, end,
|
|
1561
|
-
|
|
1562
|
-
__publicField(this, "end");
|
|
1563
|
-
__publicField(this, "nodes");
|
|
1564
|
-
__publicField(this, "edges");
|
|
1565
|
-
__publicField(this, "edgesWeights");
|
|
2581
|
+
class GeoGraphItinerary extends GeoGraph {
|
|
2582
|
+
constructor(start, end, vertices, edges, edgesWeights) {
|
|
2583
|
+
super(vertices, edges);
|
|
1566
2584
|
this.start = start;
|
|
1567
2585
|
this.end = end;
|
|
1568
|
-
this.nodes = nodes;
|
|
1569
|
-
this.edges = edges;
|
|
1570
2586
|
this.edgesWeights = edgesWeights;
|
|
1571
2587
|
}
|
|
1572
|
-
static
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
newNode.coords.level = null;
|
|
1579
|
-
}
|
|
1580
|
-
return newNode;
|
|
2588
|
+
static fromGraphVertices(start, end, networkVertices, edgesWeights) {
|
|
2589
|
+
const vertices = networkVertices.map((vertex) => {
|
|
2590
|
+
return new GeoGraphVertex(
|
|
2591
|
+
vertex.coords.clone(),
|
|
2592
|
+
{ name: vertex.name, id: vertex.id, data: vertex.data, io: vertex.io }
|
|
2593
|
+
);
|
|
1581
2594
|
});
|
|
1582
2595
|
const edges = [];
|
|
1583
|
-
|
|
2596
|
+
networkVertices.forEach((vertex, idx, arr) => {
|
|
1584
2597
|
if (idx === 0) {
|
|
1585
2598
|
return;
|
|
1586
2599
|
}
|
|
1587
|
-
const
|
|
1588
|
-
const edge =
|
|
2600
|
+
const prevVertex = arr[idx - 1];
|
|
2601
|
+
const edge = GeoGraphEdge.getEdgeByVertices(prevVertex.edges, prevVertex, vertex);
|
|
1589
2602
|
if (!edge) {
|
|
1590
|
-
|
|
2603
|
+
Logger__default.default.error("Cannot retrieve edge to create itinerary");
|
|
1591
2604
|
return;
|
|
1592
2605
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
edge.level,
|
|
1597
|
-
|
|
1598
|
-
);
|
|
1599
|
-
newEdge.isOneway = edge.isOneway;
|
|
1600
|
-
edges.push(newEdge);
|
|
2606
|
+
edges.push(new GeoGraphEdge(
|
|
2607
|
+
vertices[idx - 1],
|
|
2608
|
+
vertices[idx],
|
|
2609
|
+
{ name: edge.name, id: edge.id, data: edge.data, level: edge.level, isOneway: edge.isOneway }
|
|
2610
|
+
));
|
|
1601
2611
|
});
|
|
1602
|
-
return new
|
|
2612
|
+
return new GeoGraphItinerary(start, end, vertices, edges, edgesWeights);
|
|
1603
2613
|
}
|
|
1604
2614
|
}
|
|
1605
2615
|
class NoRouteFoundError extends Error {
|
|
1606
|
-
constructor(start, end, details) {
|
|
2616
|
+
constructor(start, end, details = null) {
|
|
1607
2617
|
super();
|
|
1608
|
-
__publicField(this, "details");
|
|
1609
|
-
__publicField(this, "end");
|
|
1610
|
-
__publicField(this, "start");
|
|
1611
2618
|
this.start = start;
|
|
1612
2619
|
this.end = end;
|
|
1613
2620
|
this.details = details;
|
|
1614
2621
|
}
|
|
1615
2622
|
get startStr() {
|
|
1616
|
-
if (this.start instanceof
|
|
2623
|
+
if (this.start instanceof GeoGraphVertex) {
|
|
1617
2624
|
return `GraphNode ${this.start.coords.toString()}`;
|
|
1618
2625
|
}
|
|
1619
2626
|
return this.start.toString();
|
|
1620
2627
|
}
|
|
1621
2628
|
get endStr() {
|
|
1622
|
-
if (this.end instanceof
|
|
2629
|
+
if (this.end instanceof GeoGraphVertex) {
|
|
1623
2630
|
return `GraphNode ${this.end.coords.toString()}`;
|
|
1624
2631
|
}
|
|
1625
2632
|
return this.end.toString();
|
|
@@ -1632,159 +2639,142 @@ class NoRouteFoundError extends Error {
|
|
|
1632
2639
|
return message;
|
|
1633
2640
|
}
|
|
1634
2641
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
class GraphRouter {
|
|
1643
|
-
constructor(network) {
|
|
2642
|
+
const DEFAULT_OPTIONS = {
|
|
2643
|
+
projectionMaxDistance: 50,
|
|
2644
|
+
weightEdgeFn: (edge) => edge.length,
|
|
2645
|
+
acceptEdgeFn: () => true
|
|
2646
|
+
};
|
|
2647
|
+
class GeoGraphRouter {
|
|
2648
|
+
constructor(graph) {
|
|
1644
2649
|
__publicField(this, "_mapMatching");
|
|
1645
|
-
__publicField(this, "
|
|
2650
|
+
__publicField(this, "_graph");
|
|
1646
2651
|
__publicField(this, "disabledEdges", /* @__PURE__ */ new Set());
|
|
1647
|
-
this.
|
|
1648
|
-
this._mapMatching = new
|
|
2652
|
+
this._graph = graph;
|
|
2653
|
+
this._mapMatching = new GeoGraphProjectionHandler(graph);
|
|
1649
2654
|
}
|
|
1650
|
-
getShortestPath(start, end, options =
|
|
1651
|
-
if (!(start instanceof GraphNode) && !(start instanceof Coordinates)) {
|
|
1652
|
-
throw new Error("Unknown start type");
|
|
1653
|
-
}
|
|
1654
|
-
if (!(end instanceof GraphNode) && !(end instanceof Coordinates)) {
|
|
1655
|
-
throw new Error("Unknown end type");
|
|
1656
|
-
}
|
|
2655
|
+
getShortestPath(start, end, options = DEFAULT_OPTIONS) {
|
|
1657
2656
|
const { acceptEdgeFn, weightEdgeFn, projectionMaxDistance } = options;
|
|
1658
2657
|
this._mapMatching.maxDistance = projectionMaxDistance;
|
|
1659
|
-
const
|
|
1660
|
-
const
|
|
1661
|
-
if (point instanceof
|
|
2658
|
+
const createdVertices = [];
|
|
2659
|
+
const retrieveOrCreateNearestVertex = (point) => {
|
|
2660
|
+
if (point instanceof GeoGraphVertex) {
|
|
1662
2661
|
return point;
|
|
1663
2662
|
}
|
|
1664
|
-
const
|
|
1665
|
-
if (
|
|
1666
|
-
return
|
|
2663
|
+
const closeVertex = this._graph.getVertexByCoords(point);
|
|
2664
|
+
if (closeVertex) {
|
|
2665
|
+
return closeVertex;
|
|
1667
2666
|
}
|
|
1668
2667
|
const proj = this._mapMatching.getProjection(point, true, false, false, acceptEdgeFn);
|
|
1669
2668
|
if (!proj) {
|
|
1670
|
-
let message = `Point ${point.toString()} is too far from the
|
|
2669
|
+
let message = `Point ${point.toString()} is too far from the graph > ${this._mapMatching.maxDistance.toFixed(0)} meters.`;
|
|
1671
2670
|
if (point.level !== null) {
|
|
1672
|
-
message += ` If it is a multi-level map, please verify if you have a
|
|
2671
|
+
message += ` If it is a multi-level map, please verify if you have a graph at level ${Level.toString(point.level)}.`;
|
|
1673
2672
|
}
|
|
1674
2673
|
throw new NoRouteFoundError(start, end, message);
|
|
1675
2674
|
}
|
|
1676
|
-
if (proj.nearestElement instanceof
|
|
2675
|
+
if (proj.nearestElement instanceof GeoGraphVertex) {
|
|
1677
2676
|
return proj.nearestElement;
|
|
1678
2677
|
}
|
|
1679
|
-
const
|
|
2678
|
+
const vertexCreated = this.createVertexInsideEdge(
|
|
1680
2679
|
proj.nearestElement,
|
|
1681
2680
|
proj.coords
|
|
1682
2681
|
);
|
|
1683
|
-
|
|
1684
|
-
return
|
|
2682
|
+
createdVertices.push(vertexCreated);
|
|
2683
|
+
return vertexCreated;
|
|
1685
2684
|
};
|
|
1686
|
-
const
|
|
1687
|
-
while (
|
|
1688
|
-
this.
|
|
2685
|
+
const removeCreatedVertices = () => {
|
|
2686
|
+
while (createdVertices.length) {
|
|
2687
|
+
this.removeVertexFromPreviouslyCreatedEdge(createdVertices.pop());
|
|
1689
2688
|
}
|
|
1690
2689
|
};
|
|
1691
|
-
const
|
|
1692
|
-
const
|
|
1693
|
-
const startCoords = start instanceof
|
|
1694
|
-
const endCoords = end instanceof
|
|
2690
|
+
const startVertex = retrieveOrCreateNearestVertex(start);
|
|
2691
|
+
const endVertex = retrieveOrCreateNearestVertex(end);
|
|
2692
|
+
const startCoords = start instanceof GeoGraphVertex ? start.coords : start;
|
|
2693
|
+
const endCoords = end instanceof GeoGraphVertex ? end.coords : end;
|
|
1695
2694
|
let graphItinerary;
|
|
1696
|
-
if (
|
|
1697
|
-
graphItinerary =
|
|
2695
|
+
if (startVertex === endVertex) {
|
|
2696
|
+
graphItinerary = GeoGraphItinerary.fromGraphVertices(
|
|
1698
2697
|
startCoords,
|
|
1699
2698
|
endCoords,
|
|
1700
|
-
[
|
|
2699
|
+
[startVertex],
|
|
1701
2700
|
[]
|
|
1702
2701
|
);
|
|
1703
2702
|
} else {
|
|
1704
|
-
graphItinerary = this.
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
2703
|
+
graphItinerary = this.getShortestPathBetweenGeoGraphVertices(
|
|
2704
|
+
startVertex,
|
|
2705
|
+
endVertex,
|
|
2706
|
+
weightEdgeFn,
|
|
2707
|
+
acceptEdgeFn
|
|
1709
2708
|
);
|
|
1710
2709
|
}
|
|
1711
2710
|
graphItinerary.start = startCoords;
|
|
1712
2711
|
graphItinerary.end = endCoords;
|
|
1713
|
-
|
|
1714
|
-
if (!graphItinerary.
|
|
2712
|
+
removeCreatedVertices();
|
|
2713
|
+
if (!graphItinerary.vertices.length) {
|
|
1715
2714
|
throw new NoRouteFoundError(start, end);
|
|
1716
2715
|
}
|
|
1717
2716
|
return graphItinerary;
|
|
1718
2717
|
}
|
|
1719
|
-
|
|
1720
|
-
const a = edge.
|
|
1721
|
-
const b = edge.
|
|
1722
|
-
const m = new
|
|
1723
|
-
|
|
1724
|
-
const u =
|
|
1725
|
-
|
|
1726
|
-
u.node2 = m;
|
|
1727
|
-
const v = edge.clone();
|
|
1728
|
-
v.node1 = m;
|
|
1729
|
-
v.node2 = b;
|
|
2718
|
+
createVertexInsideEdge(edge, point) {
|
|
2719
|
+
const a = edge.vertex1;
|
|
2720
|
+
const b = edge.vertex2;
|
|
2721
|
+
const m = new GeoGraphVertex(point, { name: `proj on ${edge.name || null} (tmp)` });
|
|
2722
|
+
const newEdgesParams = { name: `splitted ${edge.name || null} (tmp)`, data: edge.data, isOneway: edge.isOneway, level: edge.level };
|
|
2723
|
+
const u = new GeoGraphEdge(a, m, newEdgesParams);
|
|
2724
|
+
const v = new GeoGraphEdge(m, b, newEdgesParams);
|
|
1730
2725
|
a.edges = a.edges.filter((_edge) => _edge !== edge);
|
|
1731
2726
|
b.edges = b.edges.filter((_edge) => _edge !== edge);
|
|
1732
|
-
this.
|
|
1733
|
-
this.
|
|
1734
|
-
this.
|
|
2727
|
+
this._graph.vertices.push(m);
|
|
2728
|
+
this._graph.edges.push(u, v);
|
|
2729
|
+
this._graph.edges = this._graph.edges.filter(
|
|
1735
2730
|
(_edge) => _edge !== edge
|
|
1736
2731
|
);
|
|
1737
2732
|
return m;
|
|
1738
2733
|
}
|
|
1739
|
-
|
|
1740
|
-
const u =
|
|
1741
|
-
const v =
|
|
1742
|
-
u.
|
|
1743
|
-
v.
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1746
|
-
oldEdge
|
|
1747
|
-
this.
|
|
1748
|
-
this.
|
|
1749
|
-
this.
|
|
2734
|
+
removeVertexFromPreviouslyCreatedEdge(_vertex) {
|
|
2735
|
+
const u = _vertex.edges[0];
|
|
2736
|
+
const v = _vertex.edges[1];
|
|
2737
|
+
u.vertex1.edges = u.vertex1.edges.filter((edge) => edge !== u);
|
|
2738
|
+
v.vertex1.edges = v.vertex1.edges.filter((edge) => edge !== v);
|
|
2739
|
+
const oldEdgeName = u.name.substring("splitted ".length, u.name.length - " (tmp)".length);
|
|
2740
|
+
const oldEdgeParams = { name: oldEdgeName, data: u.data, isOneway: u.isOneway, level: u.level };
|
|
2741
|
+
const oldEdge = new GeoGraphEdge(u.vertex1, v.vertex2, oldEdgeParams);
|
|
2742
|
+
this._graph.edges.push(oldEdge);
|
|
2743
|
+
this._graph.vertices = this._graph.vertices.filter((vertex) => vertex !== _vertex);
|
|
2744
|
+
this._graph.edges = this._graph.edges.filter(
|
|
1750
2745
|
(edge) => edge !== u && edge !== v
|
|
1751
2746
|
);
|
|
1752
2747
|
}
|
|
1753
|
-
|
|
1754
|
-
const distanceMap = {}, checking = {}, vertexList = {},
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
vertex.
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
checking[vertexId] = null;
|
|
1761
|
-
vertexList[vertexId] = true;
|
|
1762
|
-
vertexId++;
|
|
2748
|
+
getShortestPathBetweenGeoGraphVertices(start, end, weightFn, acceptEdgeFn) {
|
|
2749
|
+
const distanceMap = {}, checking = {}, vertexList = {}, vertices = {}, parentVertices = {}, path = [];
|
|
2750
|
+
this._graph.vertices.forEach((vertex) => {
|
|
2751
|
+
vertices[vertex.id] = vertex;
|
|
2752
|
+
distanceMap[vertex.id] = Infinity;
|
|
2753
|
+
checking[vertex.id] = null;
|
|
2754
|
+
vertexList[vertex.id] = true;
|
|
1763
2755
|
});
|
|
1764
|
-
|
|
1765
|
-
const endVertex = Object.values(vertexNodes).find((vertex) => end.equals(vertex));
|
|
1766
|
-
distanceMap[startVertex.uniqueRouterId] = 0;
|
|
2756
|
+
distanceMap[start.id] = 0;
|
|
1767
2757
|
while (Object.keys(vertexList).length > 0) {
|
|
1768
2758
|
const keys = Object.keys(vertexList).map(Number);
|
|
1769
2759
|
const current = Number(
|
|
1770
|
-
keys.reduce((_checking,
|
|
1771
|
-
return distanceMap[_checking] > distanceMap[
|
|
2760
|
+
keys.reduce((_checking, vertexId) => {
|
|
2761
|
+
return distanceMap[_checking] > distanceMap[vertexId] ? vertexId : _checking;
|
|
1772
2762
|
}, keys[0])
|
|
1773
2763
|
);
|
|
1774
|
-
this.
|
|
1775
|
-
if (!acceptEdgeFn(edge) || this.disabledEdges.has(edge)) {
|
|
2764
|
+
this._graph.edges.filter((edge) => {
|
|
2765
|
+
if (acceptEdgeFn && !acceptEdgeFn(edge) || this.disabledEdges.has(edge)) {
|
|
1776
2766
|
return false;
|
|
1777
2767
|
}
|
|
1778
|
-
const from = edge.
|
|
2768
|
+
const from = edge.vertex1.id, to = edge.vertex2.id;
|
|
1779
2769
|
return from === current || to === current;
|
|
1780
2770
|
}).forEach((edge) => {
|
|
1781
2771
|
let to, from, reversed = false;
|
|
1782
|
-
if (edge.
|
|
1783
|
-
to = edge.
|
|
1784
|
-
from = edge.
|
|
2772
|
+
if (edge.vertex1.id === current) {
|
|
2773
|
+
to = edge.vertex2.id;
|
|
2774
|
+
from = edge.vertex1.id;
|
|
1785
2775
|
} else {
|
|
1786
|
-
to = edge.
|
|
1787
|
-
from = edge.
|
|
2776
|
+
to = edge.vertex1.id;
|
|
2777
|
+
from = edge.vertex2.id;
|
|
1788
2778
|
reversed = true;
|
|
1789
2779
|
}
|
|
1790
2780
|
if (edge.isOneway && reversed) {
|
|
@@ -1800,42 +2790,36 @@ class GraphRouter {
|
|
|
1800
2790
|
delete vertexList[current];
|
|
1801
2791
|
}
|
|
1802
2792
|
const edgesWeights = [];
|
|
1803
|
-
let endId =
|
|
1804
|
-
while (parentVertices[endId]) {
|
|
1805
|
-
path.unshift(
|
|
2793
|
+
let endId = end.id;
|
|
2794
|
+
while (typeof parentVertices[endId] !== "undefined") {
|
|
2795
|
+
path.unshift(vertices[endId]);
|
|
1806
2796
|
edgesWeights.unshift(distanceMap[endId] - distanceMap[parentVertices[endId]]);
|
|
1807
2797
|
endId = parentVertices[endId];
|
|
1808
2798
|
}
|
|
1809
2799
|
if (path.length !== 0) {
|
|
1810
2800
|
path.unshift(start);
|
|
1811
2801
|
}
|
|
1812
|
-
|
|
1813
|
-
delete vertex.uniqueRouterId;
|
|
1814
|
-
});
|
|
1815
|
-
return GraphItinerary.fromNetworkNodes(start.coords, end.coords, path, edgesWeights);
|
|
2802
|
+
return GeoGraphItinerary.fromGraphVertices(start.coords, end.coords, path, edgesWeights);
|
|
1816
2803
|
}
|
|
1817
2804
|
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
UserPosition,
|
|
1839
|
-
Utils
|
|
1840
|
-
};
|
|
2805
|
+
__publicField(GeoGraphRouter, "DEFAULT_OPTIONS", DEFAULT_OPTIONS);
|
|
2806
|
+
exports.AbsoluteHeading = AbsoluteHeading;
|
|
2807
|
+
exports.Attitude = Attitude;
|
|
2808
|
+
exports.BoundingBox = BoundingBox;
|
|
2809
|
+
exports.Constants = Constants;
|
|
2810
|
+
exports.Coordinates = Coordinates;
|
|
2811
|
+
exports.GeoGraph = GeoGraph;
|
|
2812
|
+
exports.GeoGraphEdge = GeoGraphEdge;
|
|
2813
|
+
exports.GeoGraphItinerary = GeoGraphItinerary;
|
|
2814
|
+
exports.GeoGraphProjection = GeoGraphProjection;
|
|
2815
|
+
exports.GeoGraphProjectionHandler = GeoGraphProjectionHandler;
|
|
2816
|
+
exports.GeoGraphRouter = GeoGraphRouter;
|
|
2817
|
+
exports.GeoGraphVertex = GeoGraphVertex;
|
|
2818
|
+
exports.GeoRef = GeoRef;
|
|
2819
|
+
exports.GeoRelativePosition = GeoRelativePosition;
|
|
2820
|
+
exports.Level = Level;
|
|
2821
|
+
exports.NoRouteFoundError = NoRouteFoundError;
|
|
2822
|
+
exports.RelativePosition = RelativePosition;
|
|
2823
|
+
exports.UserPosition = UserPosition;
|
|
2824
|
+
exports.Utils = Utils;
|
|
1841
2825
|
//# sourceMappingURL=index.js.map
|