@wemap/geo 11.0.0-alpha.24 → 11.0.0-alpha.4

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.
Files changed (37) hide show
  1. package/dist/index.js +404 -1386
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +404 -1386
  4. package/dist/index.mjs.map +1 -1
  5. package/index.ts +19 -9
  6. package/package.json +5 -6
  7. package/src/Utils.ts +4 -4
  8. package/src/coordinates/Coordinates.ts +7 -16
  9. package/src/graph/GraphEdge.spec.ts +74 -0
  10. package/src/graph/GraphEdge.ts +134 -0
  11. package/src/graph/GraphNode.spec.ts +200 -0
  12. package/src/graph/GraphNode.ts +174 -0
  13. package/src/graph/GraphProjection.ts +23 -0
  14. package/src/graph/GraphUtils.ts +21 -0
  15. package/src/graph/{GeoGraphProjectionHandler.spec.ts → MapMatching.spec.ts} +73 -74
  16. package/src/graph/{GeoGraphProjectionHandler.ts → MapMatching.ts} +44 -39
  17. package/src/graph/Network.spec.ts +145 -0
  18. package/src/graph/Network.ts +175 -0
  19. package/src/router/GraphItinerary.spec.ts +14 -0
  20. package/src/router/GraphItinerary.ts +80 -0
  21. package/src/router/GraphRouter.spec.ts +298 -0
  22. package/src/router/GraphRouter.ts +283 -0
  23. package/src/router/GraphRouterOptions.ts +14 -0
  24. package/src/{graph → router}/NoRouteFoundError.ts +14 -9
  25. package/src/types.ts +3 -3
  26. package/tests/CommonTest.ts +72 -69
  27. package/src/graph/GeoGraph.spec.ts +0 -278
  28. package/src/graph/GeoGraph.ts +0 -170
  29. package/src/graph/GeoGraphEdge.spec.ts +0 -51
  30. package/src/graph/GeoGraphEdge.ts +0 -98
  31. package/src/graph/GeoGraphItinerary.spec.ts +0 -14
  32. package/src/graph/GeoGraphItinerary.ts +0 -61
  33. package/src/graph/GeoGraphProjection.ts +0 -24
  34. package/src/graph/GeoGraphRouter.spec.ts +0 -297
  35. package/src/graph/GeoGraphRouter.ts +0 -267
  36. package/src/graph/GeoGraphVertex.spec.ts +0 -54
  37. package/src/graph/GeoGraphVertex.ts +0 -139
package/dist/index.js CHANGED
@@ -483,9 +483,9 @@ class Coordinates {
483
483
  }
484
484
  toJson() {
485
485
  return {
486
- lat: Number(this.lat.toFixed(8)),
487
- lng: Number(this.lng.toFixed(8)),
488
- ...this.alt !== null && { alt: Number(this.alt.toFixed(3)) },
486
+ lat: this.lat,
487
+ lng: this.lng,
488
+ ...this.alt !== null && { alt: this.alt },
489
489
  ...this.level !== null && { level: this.level }
490
490
  };
491
491
  }
@@ -494,21 +494,12 @@ class Coordinates {
494
494
  }
495
495
  toCompressedJson() {
496
496
  if (this.level !== null) {
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
- ];
497
+ return [this.lat, this.lng, this.alt, this.level];
503
498
  }
504
499
  if (this.alt !== null) {
505
- return [
506
- Number(this.lat.toFixed(8)),
507
- Number(this.lng.toFixed(8)),
508
- Number(this.alt.toFixed(3))
509
- ];
500
+ return [this.lat, this.lng, this.alt];
510
501
  }
511
- return [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))];
502
+ return [this.lat, this.lng];
512
503
  }
513
504
  static fromCompressedJson(json) {
514
505
  const coords = new Coordinates(json[0], json[1]);
@@ -1104,1118 +1095,158 @@ class AbsoluteHeading {
1104
1095
  return new AbsoluteHeading(this.heading, this.time, this.accuracy);
1105
1096
  }
1106
1097
  }
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]);
1098
+ class GraphNode {
1099
+ constructor(coords, builtFrom = null) {
1100
+ __publicField(this, "coords");
1101
+ __publicField(this, "edges", []);
1102
+ __publicField(this, "builtFrom");
1103
+ __publicField(this, "io", false);
1104
+ this.coords = coords;
1105
+ this.builtFrom = builtFrom;
1106
+ }
1107
+ distanceTo(other) {
1108
+ return this.coords.distanceTo(other.coords);
1109
+ }
1110
+ bearingTo(other) {
1111
+ return this.coords.bearingTo(other.coords);
1112
+ }
1113
+ equals(other) {
1114
+ return this.coords.equals(other.coords) && this.builtFrom === other.builtFrom;
1115
+ }
1116
+ clone() {
1117
+ const node = new GraphNode(this.coords, this.builtFrom);
1118
+ node.edges = this.edges.slice(0);
1119
+ node.io = this.io;
1120
+ return node;
1121
+ }
1122
+ toJson() {
1123
+ return this.coords.toCompressedJson();
1124
+ }
1125
+ static fromJson(json, builtFrom = null) {
1126
+ return new GraphNode(Coordinates.fromCompressedJson(json), builtFrom);
1127
+ }
1128
+ _generateLevelFromEdges() {
1129
+ let tmpLevel = null;
1130
+ for (let i = 0; i < this.edges.length; i++) {
1131
+ const edge = this.edges[i];
1132
+ if (edge.level !== null) {
1133
+ if (tmpLevel === null) {
1134
+ tmpLevel = Level.clone(edge.level);
1118
1135
  } else {
1119
- mergedRegexes[i] = regexes2[i];
1120
- }
1121
- }
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];
1127
- }
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);
1139
- }
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
- }
1173
- }
1174
- i += 2;
1175
- }
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
- }
1136
+ tmpLevel = Level.intersection(tmpLevel, edge.level);
1137
+ if (tmpLevel === null) {
1138
+ throw Error("Something bad happend during parsing: We cannot retrieve node level from adjacent ways: " + this.coords);
1183
1139
  }
1184
- } else if (has(map[i], str)) {
1185
- return i === UNKNOWN ? undefined$1 : i;
1186
1140
  }
1187
1141
  }
1188
- return str;
1189
- };
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();
1142
+ }
1143
+ this.coords.level = tmpLevel;
1144
+ }
1145
+ _inferNodeLevelByRecursion() {
1146
+ const { level } = this.coords;
1147
+ if (level === null || !Level.isRange(level)) {
1148
+ return;
1149
+ }
1150
+ if (this.edges.length > 1) {
1151
+ return;
1152
+ }
1153
+ const lookForLevel = (node, visitedNodes) => {
1154
+ visitedNodes.push(node);
1155
+ if (node.coords.level === null) {
1156
+ return null;
1952
1157
  }
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;
1158
+ if (!Level.isRange(node.coords.level)) {
1159
+ return node.coords.level;
2019
1160
  }
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;
1161
+ let tmpLevel = null;
1162
+ for (let i = 0; i < node.edges.length; i++) {
1163
+ const edge = node.edges[i];
1164
+ const otherNode = edge.node1 === node ? edge.node2 : edge.node1;
1165
+ if (!visitedNodes.includes(otherNode)) {
1166
+ tmpLevel = Level.union(lookForLevel(otherNode, visitedNodes), tmpLevel);
2072
1167
  }
2073
1168
  }
2074
- }
2075
- return this._name;
2076
- }
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
- }
1169
+ return tmpLevel;
1170
+ };
1171
+ const othersLevels = lookForLevel(this, []);
1172
+ if (othersLevels !== null) {
1173
+ if (!Level.isRange(othersLevels)) {
1174
+ this.coords.level = othersLevels === level[0] ? level[1] : level[0];
1175
+ return;
2085
1176
  }
2086
- }
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++;
1177
+ throw Error("Level of: " + this.coords.toString() + " cannot be decided");
2108
1178
  }
2109
1179
  }
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++;
1180
+ _inferNodeLevelByNeighboors() {
1181
+ const { level } = this.coords;
1182
+ if (level === null || !Level.isRange(level)) {
1183
+ return true;
2128
1184
  }
2129
- }
2130
- get vertex1() {
2131
- return this._vertex1;
2132
- }
2133
- set vertex1(vertex) {
2134
- if (this._vertex1 && this._vertex2 !== this._vertex1) {
2135
- this._vertex1.edges = this._vertex1.edges.filter((edge) => edge !== this);
1185
+ let tmpLevel = null;
1186
+ for (let i = 0; i < this.edges.length; i++) {
1187
+ const edge = this.edges[i];
1188
+ const otherNode = edge.node1 === this ? edge.node2 : edge.node1;
1189
+ tmpLevel = Level.union(otherNode.coords.level, tmpLevel);
2136
1190
  }
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);
1191
+ if (tmpLevel === null || !Level.isRange(tmpLevel)) {
1192
+ this.coords.level = tmpLevel === level[0] ? level[1] : level[0];
2146
1193
  }
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);
1194
+ return true;
2167
1195
  }
2168
- getVertexByName(name) {
2169
- return this.vertices.find((vertex) => vertex.name === name);
1196
+ _checkIO() {
1197
+ this.io = this.coords.level !== null && this.edges.some((edge) => edge.level === null);
1198
+ return true;
2170
1199
  }
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;
1200
+ static generateNodesLevels(nodes) {
1201
+ nodes.forEach((node) => node._generateLevelFromEdges());
1202
+ nodes.forEach((node) => node._inferNodeLevelByNeighboors());
1203
+ nodes.forEach((node) => node._inferNodeLevelByRecursion());
1204
+ nodes.forEach((node) => node._checkIO());
2193
1205
  }
2194
1206
  }
2195
- class GeoGraphEdge extends GraphEdge {
2196
- constructor(vertex1, vertex2, params) {
2197
- super(vertex1, vertex2, params);
1207
+ class GraphEdge {
1208
+ constructor(node1, node2, level = null, builtFrom = null) {
1209
+ __publicField(this, "_node1");
1210
+ __publicField(this, "_node2");
2198
1211
  __publicField(this, "_level", null);
2199
1212
  __publicField(this, "_bearing", null);
2200
1213
  __publicField(this, "_length", null);
2201
1214
  __publicField(this, "_computedSizeAndBearing", false);
1215
+ __publicField(this, "builtFrom");
2202
1216
  __publicField(this, "isOneway", false);
2203
- Object.assign(this, params);
1217
+ this.node1 = node1;
1218
+ this.node2 = node2;
1219
+ this.level = level;
1220
+ this.builtFrom = builtFrom;
2204
1221
  }
2205
- set vertex1(vertex) {
2206
- super.vertex1 = vertex;
1222
+ get node1() {
1223
+ return this._node1;
1224
+ }
1225
+ set node1(node) {
1226
+ if (!(node instanceof GraphNode)) {
1227
+ throw new TypeError("node1 is not a GraphNode");
1228
+ }
1229
+ if (this._node1 instanceof GraphNode && this._node2 !== this._node1) {
1230
+ this._node1.edges = this._node1.edges.filter((edge) => edge !== this);
1231
+ }
1232
+ node.edges.push(this);
1233
+ this._node1 = node;
2207
1234
  this._computedSizeAndBearing = false;
2208
1235
  }
2209
- get vertex1() {
2210
- return this._vertex1;
1236
+ get node2() {
1237
+ return this._node2;
2211
1238
  }
2212
- set vertex2(vertex) {
2213
- super.vertex2 = vertex;
1239
+ set node2(node) {
1240
+ if (!(node instanceof GraphNode)) {
1241
+ throw new TypeError("node2 is not a GraphNode");
1242
+ }
1243
+ if (this._node2 instanceof GraphNode && this._node2 !== this._node1) {
1244
+ this._node2.edges = this._node2.edges.filter((edge) => edge !== this);
1245
+ }
1246
+ node.edges.push(this);
1247
+ this._node2 = node;
2214
1248
  this._computedSizeAndBearing = false;
2215
1249
  }
2216
- get vertex2() {
2217
- return this._vertex2;
2218
- }
2219
1250
  get level() {
2220
1251
  return this._level;
2221
1252
  }
@@ -2236,206 +1267,154 @@ class GeoGraphEdge extends GraphEdge {
2236
1267
  return this._length;
2237
1268
  }
2238
1269
  _computeSizeAndBearing() {
2239
- this._length = this.vertex1.distanceTo(this.vertex2);
2240
- this._bearing = this.vertex1.bearingTo(this.vertex2);
1270
+ this._length = this.node1.distanceTo(this.node2);
1271
+ this._bearing = this.node1.bearingTo(this.node2);
2241
1272
  this._computedSizeAndBearing = true;
2242
1273
  }
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)) {
1274
+ equals(other) {
1275
+ if (this === other) {
2286
1276
  return true;
2287
1277
  }
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);
2293
- }
2294
- if (tmpLevel === null || !Level.isRange(tmpLevel)) {
2295
- this.coords.level = tmpLevel === level[0] ? level[1] : level[0];
1278
+ if (!(other instanceof GraphEdge)) {
1279
+ return false;
2296
1280
  }
2297
- return true;
1281
+ return other.node1.equals(this.node1) && other.node2.equals(this.node2) && Level.equals(other.level, this.level) && other.isOneway === this.isOneway && other.builtFrom === this.builtFrom;
2298
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
+ clone() {
1284
+ const edge = new GraphEdge(this.node1, this.node2, this.level, this.builtFrom);
1285
+ edge.isOneway = this.isOneway;
1286
+ return edge;
2333
1287
  }
2334
1288
  }
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));
1289
+ function getEdgeByNodes(edges, node1, node2) {
1290
+ return edges.find(
1291
+ (edge) => node1 === edge.node1 && node2 === edge.node2 || node2 === edge.node1 && node1 === edge.node2
1292
+ );
1293
+ }
1294
+ function getNodeByCoords(nodes, coords) {
1295
+ return nodes.find((node) => node.coords.equals(coords));
1296
+ }
1297
+ const GraphUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1298
+ __proto__: null,
1299
+ getEdgeByNodes,
1300
+ getNodeByCoords
1301
+ }, Symbol.toStringTag, { value: "Module" }));
1302
+ class Network {
1303
+ constructor(nodes, edges) {
1304
+ __publicField(this, "nodes");
1305
+ __publicField(this, "edges");
1306
+ this.nodes = Array.isArray(nodes) ? nodes : [];
1307
+ this.edges = Array.isArray(edges) ? edges : [];
2345
1308
  }
2346
- getVertexByName(name) {
2347
- return super.getVertexByName(name);
1309
+ getNodeByCoords(coords) {
1310
+ return this.nodes.find((node) => node.coords.equals(coords));
2348
1311
  }
2349
- getEdgeByName(name) {
2350
- return super.getEdgeByName(name);
1312
+ getEdgeByNodes(node1, node2) {
1313
+ return getEdgeByNodes(this.edges, node1, node2);
2351
1314
  }
2352
1315
  getBoundingBox(extendedMeasure) {
2353
- if (!this.vertices.length) {
1316
+ if (!this.nodes.length) {
2354
1317
  return null;
2355
1318
  }
2356
- const boundingBox = BoundingBox.fromCoordinates(this.vertices.map((vertex) => vertex.coords));
1319
+ const boundingBox = BoundingBox.fromCoordinates(this.nodes.map((node) => node.coords));
2357
1320
  if (extendedMeasure) {
2358
1321
  boundingBox.extendsWithMeasure(extendedMeasure);
2359
1322
  }
2360
1323
  return boundingBox;
2361
1324
  }
1325
+ toDetailedString(_nodeToStringFn, _edgeToStringFn) {
1326
+ let nodeToStringFn = _nodeToStringFn;
1327
+ if (!nodeToStringFn) {
1328
+ nodeToStringFn = (node) => `${node.builtFrom}`;
1329
+ }
1330
+ let edgeToStringFn = _edgeToStringFn;
1331
+ if (!_edgeToStringFn) {
1332
+ edgeToStringFn = (edge) => `${edge.builtFrom}`;
1333
+ }
1334
+ let output = `--- Network ---
1335
+ Nodes: ${this.nodes.length}
1336
+ Edges: ${this.edges.length}
1337
+ ---
1338
+ Nodes
1339
+ `;
1340
+ this.nodes.forEach((node) => {
1341
+ output += `${nodeToStringFn(node)} [edges: ${node.edges.length}]
1342
+ `;
1343
+ });
1344
+ output += "---\nEdges\n";
1345
+ this.edges.forEach((edge) => {
1346
+ output += `${edgeToStringFn(edge)} `;
1347
+ output += `[${nodeToStringFn(edge.node1)} -- ${nodeToStringFn(edge.node2)}]
1348
+ `;
1349
+ });
1350
+ output += "---";
1351
+ return output;
1352
+ }
2362
1353
  toCompressedJson() {
2363
1354
  return {
2364
- vertices: this.vertices.map((vertex) => vertex.toJson()),
1355
+ nodes: this.nodes.map((node) => node.toJson()),
2365
1356
  edges: this.edges.map((edge) => {
2366
- const vertex1Idx = this.vertices.indexOf(edge.vertex1);
2367
- const vertex2Idx = this.vertices.indexOf(edge.vertex2);
1357
+ const node1Idx = this.nodes.indexOf(edge.node1);
1358
+ const node2Idx = this.nodes.indexOf(edge.node2);
2368
1359
  if (edge.isOneway) {
2369
- return [vertex1Idx, vertex2Idx, edge.level, true];
1360
+ return [node1Idx, node2Idx, edge.level, true];
2370
1361
  }
2371
- if (edge.level !== null) {
2372
- return [vertex1Idx, vertex2Idx, edge.level];
1362
+ if (edge.level) {
1363
+ return [node1Idx, node2Idx, edge.level];
2373
1364
  }
2374
- return [vertex1Idx, vertex2Idx];
1365
+ return [node1Idx, node2Idx];
2375
1366
  })
2376
1367
  };
2377
1368
  }
2378
1369
  static fromCompressedJson(json) {
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 }
1370
+ const network = new Network();
1371
+ network.nodes = json.nodes.map((node) => GraphNode.fromJson(node, null));
1372
+ network.edges = json.edges.map((jsonEdge) => {
1373
+ const edge = new GraphEdge(
1374
+ network.nodes[jsonEdge[0]],
1375
+ network.nodes[jsonEdge[1]],
1376
+ jsonEdge[2],
1377
+ null
2386
1378
  );
2387
1379
  if (jsonEdge.length > 3 && jsonEdge[3]) {
2388
1380
  edge.isOneway = true;
2389
1381
  }
2390
1382
  return edge;
2391
1383
  });
2392
- return geograph;
1384
+ return network;
2393
1385
  }
2394
1386
  static fromCoordinates(segments) {
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;
1387
+ const network = new Network();
1388
+ const getOrCreateNode = (coords) => {
1389
+ const node = network.nodes.find((otherNode) => otherNode.coords.equals(coords));
1390
+ if (node) {
1391
+ return node;
2400
1392
  }
2401
- const newVertex = new GeoGraphVertex(coords);
2402
- geograph.vertices.push(newVertex);
2403
- return newVertex;
1393
+ const newNode = new GraphNode(coords, null);
1394
+ network.nodes.push(newNode);
1395
+ return newNode;
2404
1396
  };
2405
- const createEdgeFromVertices = (vertex1, vertex2) => new GeoGraphEdge(
2406
- vertex1,
2407
- vertex2,
2408
- { level: Level.union(vertex1.coords.level, vertex2.coords.level) }
2409
- );
1397
+ const createEdgeFromNodes = (node1, node2) => new GraphEdge(node1, node2, Level.union(node1.coords.level, node2.coords.level), null);
2410
1398
  for (const segment of segments) {
2411
- let previousVertex = null;
1399
+ let previousNode = null;
2412
1400
  for (const coords of segment) {
2413
- const currentVertex = getOrCreateVertex(coords);
2414
- if (previousVertex) {
2415
- const edge = createEdgeFromVertices(currentVertex, previousVertex);
2416
- geograph.edges.push(edge);
1401
+ const currentNode = getOrCreateNode(coords);
1402
+ if (previousNode) {
1403
+ const edge = createEdgeFromNodes(currentNode, previousNode);
1404
+ network.edges.push(edge);
2417
1405
  }
2418
- previousVertex = currentVertex;
1406
+ previousNode = currentNode;
2419
1407
  }
2420
1408
  }
2421
- return geograph;
1409
+ return network;
2422
1410
  }
2423
1411
  getEdgesAtLevel(targetLevel, useMultiLevelEdges = true) {
2424
1412
  return this.edges.filter(
2425
1413
  ({ level }) => useMultiLevelEdges ? Level.intersect(targetLevel, level) : Level.contains(targetLevel, level)
2426
1414
  );
2427
1415
  }
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
- }
2437
1416
  }
2438
- class GeoGraphProjection {
1417
+ class GraphProjection {
2439
1418
  constructor(origin, distanceFromNearestElement, coords, nearestElement) {
2440
1419
  __publicField(this, "origin");
2441
1420
  __publicField(this, "distanceFromNearestElement");
@@ -2447,12 +1426,12 @@ class GeoGraphProjection {
2447
1426
  this.nearestElement = nearestElement;
2448
1427
  }
2449
1428
  }
2450
- const _GeoGraphProjectionHandler = class {
2451
- constructor(graph = null) {
2452
- __publicField(this, "graph", null);
1429
+ const _MapMatching = class {
1430
+ constructor(network = null) {
1431
+ __publicField(this, "network", null);
2453
1432
  __publicField(this, "_maxDistance", Number.MAX_VALUE);
2454
1433
  __publicField(this, "_maxAngleBearing", Math.PI);
2455
- this.graph = graph;
1434
+ this.network = network;
2456
1435
  }
2457
1436
  set maxAngleBearing(maxAngleBearing) {
2458
1437
  this._maxAngleBearing = maxAngleBearing;
@@ -2471,14 +1450,14 @@ const _GeoGraphProjectionHandler = class {
2471
1450
  return [false, false, false];
2472
1451
  }
2473
1452
  let checkEdge = Level.intersect(location.level, edge.level);
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
+ let checkNode1 = Level.intersect(location.level, edge.node1.coords.level);
1454
+ let checkNode2 = Level.intersect(location.level, edge.node2.coords.level);
1455
+ checkNode1 = checkNode1 || edge.node1.io && location.level === null;
1456
+ checkNode2 = checkNode2 || edge.node2.io && location.level === null;
2478
1457
  if (!useMultiLevelSegments) {
2479
1458
  checkEdge = checkEdge && !Level.isRange(edge.level);
2480
- checkNode1 = checkNode1 && !Level.isRange(edge.vertex1.coords.level);
2481
- checkNode2 = checkNode2 && !Level.isRange(edge.vertex2.coords.level);
1459
+ checkNode1 = checkNode1 && !Level.isRange(edge.node1.coords.level);
1460
+ checkNode2 = checkNode2 && !Level.isRange(edge.node2.coords.level);
2482
1461
  }
2483
1462
  if (useBearing) {
2484
1463
  if (checkEdge) {
@@ -2503,8 +1482,11 @@ const _GeoGraphProjectionHandler = class {
2503
1482
  }
2504
1483
  }
2505
1484
  getProjection(location, useDistance = false, useBearing = false, useMultiLevelSegments = true, acceptEdgeFn = () => true) {
2506
- if (this.graph === null) {
2507
- throw new Error("Graph has not been set yet");
1485
+ if (this.network === null) {
1486
+ throw new Error("Network has not been set yet");
1487
+ }
1488
+ if (!(location instanceof Coordinates)) {
1489
+ throw new TypeError("location is not an instance of Coordinates");
2508
1490
  }
2509
1491
  if (useBearing && (!("bearing" in location && location.bearing !== null) || !this._maxAngleBearing)) {
2510
1492
  return null;
@@ -2515,7 +1497,7 @@ const _GeoGraphProjectionHandler = class {
2515
1497
  const isProjectionBetter = (distanceOfNewProjection) => {
2516
1498
  return distanceOfNewProjection < distanceFromNearestElement && (!useDistance || distanceOfNewProjection <= this._maxDistance);
2517
1499
  };
2518
- for (const edge of this.graph.edges) {
1500
+ for (const edge of this.network.edges) {
2519
1501
  const [checkEdge, checkNode1, checkNode2] = this._shouldProjectOnEdgeAndNodes(
2520
1502
  edge,
2521
1503
  location,
@@ -2524,38 +1506,38 @@ const _GeoGraphProjectionHandler = class {
2524
1506
  acceptEdgeFn
2525
1507
  );
2526
1508
  if (checkNode1) {
2527
- const distNode1 = location.distanceTo(edge.vertex1.coords);
1509
+ const distNode1 = location.distanceTo(edge.node1.coords);
2528
1510
  if (isProjectionBetter(distNode1) || distNode1 <= EPS_MM) {
2529
1511
  distanceFromNearestElement = distNode1;
2530
- nearestElement = edge.vertex1;
2531
- _GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex1.coords, projection);
2532
- _GeoGraphProjectionHandler._handleLevelsWithIONodes(projection, location, edge.vertex1);
1512
+ nearestElement = edge.node1;
1513
+ _MapMatching._assignLatLngLevel(edge.node1.coords, projection);
1514
+ _MapMatching._handleLevelsWithIONodes(projection, location, edge.node1);
2533
1515
  if (distNode1 <= EPS_MM) {
2534
1516
  break;
2535
1517
  }
2536
1518
  }
2537
1519
  }
2538
1520
  if (checkNode2) {
2539
- const distNode2 = location.distanceTo(edge.vertex2.coords);
1521
+ const distNode2 = location.distanceTo(edge.node2.coords);
2540
1522
  if (isProjectionBetter(distNode2) || distNode2 <= EPS_MM) {
2541
1523
  distanceFromNearestElement = distNode2;
2542
- nearestElement = edge.vertex2;
2543
- _GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex2.coords, projection);
2544
- _GeoGraphProjectionHandler._handleLevelsWithIONodes(projection, location, edge.vertex2);
1524
+ nearestElement = edge.node2;
1525
+ _MapMatching._assignLatLngLevel(edge.node2.coords, projection);
1526
+ _MapMatching._handleLevelsWithIONodes(projection, location, edge.node2);
2545
1527
  if (distNode2 <= EPS_MM) {
2546
1528
  break;
2547
1529
  }
2548
1530
  }
2549
1531
  }
2550
1532
  if (checkEdge) {
2551
- const segmentProjection = location.getSegmentProjection(edge.vertex1.coords, edge.vertex2.coords);
1533
+ const segmentProjection = location.getSegmentProjection(edge.node1.coords, edge.node2.coords);
2552
1534
  if (segmentProjection) {
2553
1535
  const distEdge = location.distanceTo(segmentProjection);
2554
1536
  if (isProjectionBetter(distEdge)) {
2555
1537
  distanceFromNearestElement = distEdge;
2556
1538
  nearestElement = edge;
2557
- _GeoGraphProjectionHandler._assignLatLngLevel(segmentProjection, projection);
2558
- _GeoGraphProjectionHandler._updateProjectionLevelFromEdge(edge, projection);
1539
+ _MapMatching._assignLatLngLevel(segmentProjection, projection);
1540
+ _MapMatching._updateProjectionLevelFromEdge(edge, projection);
2559
1541
  }
2560
1542
  }
2561
1543
  }
@@ -2566,7 +1548,7 @@ const _GeoGraphProjectionHandler = class {
2566
1548
  if (projection instanceof UserPosition && projection.accuracy !== null) {
2567
1549
  projection.accuracy += distanceFromNearestElement;
2568
1550
  }
2569
- return new GeoGraphProjection(
1551
+ return new GraphProjection(
2570
1552
  location,
2571
1553
  distanceFromNearestElement,
2572
1554
  projection,
@@ -2574,59 +1556,74 @@ const _GeoGraphProjectionHandler = class {
2574
1556
  );
2575
1557
  }
2576
1558
  };
2577
- let GeoGraphProjectionHandler = _GeoGraphProjectionHandler;
2578
- __publicField(GeoGraphProjectionHandler, "_updateProjectionLevelFromEdge", (_edge, _projection) => {
1559
+ let MapMatching = _MapMatching;
1560
+ __publicField(MapMatching, "_updateProjectionLevelFromEdge", (_edge, _projection) => {
2579
1561
  _projection.level = Level.clone(_edge.level);
2580
1562
  });
2581
- class GeoGraphItinerary extends GeoGraph {
2582
- constructor(start, end, vertices, edges, edgesWeights) {
2583
- super(vertices, edges);
1563
+ class GraphItinerary {
1564
+ constructor(start, end, nodes, edges, edgesWeights) {
1565
+ __publicField(this, "start");
1566
+ __publicField(this, "end");
1567
+ __publicField(this, "nodes");
1568
+ __publicField(this, "edges");
1569
+ __publicField(this, "edgesWeights");
2584
1570
  this.start = start;
2585
1571
  this.end = end;
1572
+ this.nodes = nodes;
1573
+ this.edges = edges;
2586
1574
  this.edgesWeights = edgesWeights;
2587
1575
  }
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
- );
1576
+ static fromNetworkNodes(start, end, networkNodes, edgesWeights) {
1577
+ const nodes = networkNodes.map((node) => {
1578
+ const newNode = node.clone();
1579
+ newNode.edges = [];
1580
+ if (newNode.io) {
1581
+ newNode.coords = newNode.coords.clone();
1582
+ newNode.coords.level = null;
1583
+ }
1584
+ return newNode;
2594
1585
  });
2595
1586
  const edges = [];
2596
- networkVertices.forEach((vertex, idx, arr) => {
1587
+ networkNodes.forEach((node, idx, arr) => {
2597
1588
  if (idx === 0) {
2598
1589
  return;
2599
1590
  }
2600
- const prevVertex = arr[idx - 1];
2601
- const edge = GeoGraphEdge.getEdgeByVertices(prevVertex.edges, prevVertex, vertex);
1591
+ const prevNode = arr[idx - 1];
1592
+ const edge = getEdgeByNodes(prevNode.edges, prevNode, node);
2602
1593
  if (!edge) {
2603
1594
  Logger__default.default.error("Cannot retrieve edge to create itinerary");
2604
1595
  return;
2605
1596
  }
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
- ));
1597
+ const newEdge = new GraphEdge(
1598
+ nodes[idx - 1],
1599
+ nodes[idx],
1600
+ edge.level,
1601
+ edge.builtFrom
1602
+ );
1603
+ newEdge.isOneway = edge.isOneway;
1604
+ edges.push(newEdge);
2611
1605
  });
2612
- return new GeoGraphItinerary(start, end, vertices, edges, edgesWeights);
1606
+ return new GraphItinerary(start, end, nodes, edges, edgesWeights);
2613
1607
  }
2614
1608
  }
2615
1609
  class NoRouteFoundError extends Error {
2616
- constructor(start, end, details = null) {
1610
+ constructor(start, end, details) {
2617
1611
  super();
1612
+ __publicField(this, "details");
1613
+ __publicField(this, "end");
1614
+ __publicField(this, "start");
2618
1615
  this.start = start;
2619
1616
  this.end = end;
2620
1617
  this.details = details;
2621
1618
  }
2622
1619
  get startStr() {
2623
- if (this.start instanceof GeoGraphVertex) {
1620
+ if (this.start instanceof GraphNode) {
2624
1621
  return `GraphNode ${this.start.coords.toString()}`;
2625
1622
  }
2626
1623
  return this.start.toString();
2627
1624
  }
2628
1625
  get endStr() {
2629
- if (this.end instanceof GeoGraphVertex) {
1626
+ if (this.end instanceof GraphNode) {
2630
1627
  return `GraphNode ${this.end.coords.toString()}`;
2631
1628
  }
2632
1629
  return this.end.toString();
@@ -2639,142 +1636,159 @@ class NoRouteFoundError extends Error {
2639
1636
  return message;
2640
1637
  }
2641
1638
  }
2642
- const DEFAULT_OPTIONS = {
2643
- projectionMaxDistance: 50,
2644
- weightEdgeFn: (edge) => edge.length,
2645
- acceptEdgeFn: () => true
2646
- };
2647
- class GeoGraphRouter {
2648
- constructor(graph) {
1639
+ class GraphRouterOptions {
1640
+ constructor() {
1641
+ __publicField(this, "projectionMaxDistance", 50);
1642
+ __publicField(this, "weightEdgeFn", (edge) => edge.length);
1643
+ __publicField(this, "acceptEdgeFn", () => true);
1644
+ }
1645
+ }
1646
+ class GraphRouter {
1647
+ constructor(network) {
2649
1648
  __publicField(this, "_mapMatching");
2650
- __publicField(this, "_graph");
1649
+ __publicField(this, "_network");
2651
1650
  __publicField(this, "disabledEdges", /* @__PURE__ */ new Set());
2652
- this._graph = graph;
2653
- this._mapMatching = new GeoGraphProjectionHandler(graph);
1651
+ this._network = network;
1652
+ this._mapMatching = new MapMatching(network);
2654
1653
  }
2655
- getShortestPath(start, end, options = DEFAULT_OPTIONS) {
1654
+ getShortestPath(start, end, options = new GraphRouterOptions()) {
1655
+ if (!(start instanceof GraphNode) && !(start instanceof Coordinates)) {
1656
+ throw new Error("Unknown start type");
1657
+ }
1658
+ if (!(end instanceof GraphNode) && !(end instanceof Coordinates)) {
1659
+ throw new Error("Unknown end type");
1660
+ }
2656
1661
  const { acceptEdgeFn, weightEdgeFn, projectionMaxDistance } = options;
2657
1662
  this._mapMatching.maxDistance = projectionMaxDistance;
2658
- const createdVertices = [];
2659
- const retrieveOrCreateNearestVertex = (point) => {
2660
- if (point instanceof GeoGraphVertex) {
1663
+ const createdNodes = [];
1664
+ const retrieveOrCreateNearestNode = (point) => {
1665
+ if (point instanceof GraphNode) {
2661
1666
  return point;
2662
1667
  }
2663
- const closeVertex = this._graph.getVertexByCoords(point);
2664
- if (closeVertex) {
2665
- return closeVertex;
1668
+ const closeNode = this._network.getNodeByCoords(point);
1669
+ if (closeNode) {
1670
+ return closeNode;
2666
1671
  }
2667
1672
  const proj = this._mapMatching.getProjection(point, true, false, false, acceptEdgeFn);
2668
1673
  if (!proj) {
2669
- let message = `Point ${point.toString()} is too far from the graph > ${this._mapMatching.maxDistance.toFixed(0)} meters.`;
1674
+ let message = `Point ${point.toString()} is too far from the network > ${this._mapMatching.maxDistance.toFixed(0)} meters.`;
2670
1675
  if (point.level !== null) {
2671
- message += ` If it is a multi-level map, please verify if you have a graph at level ${Level.toString(point.level)}.`;
1676
+ message += ` If it is a multi-level map, please verify if you have a network at level ${Level.toString(point.level)}.`;
2672
1677
  }
2673
1678
  throw new NoRouteFoundError(start, end, message);
2674
1679
  }
2675
- if (proj.nearestElement instanceof GeoGraphVertex) {
1680
+ if (proj.nearestElement instanceof GraphNode) {
2676
1681
  return proj.nearestElement;
2677
1682
  }
2678
- const vertexCreated = this.createVertexInsideEdge(
1683
+ const nodeCreated = this.createNodeInsideEdge(
2679
1684
  proj.nearestElement,
2680
1685
  proj.coords
2681
1686
  );
2682
- createdVertices.push(vertexCreated);
2683
- return vertexCreated;
1687
+ createdNodes.push(nodeCreated);
1688
+ return nodeCreated;
2684
1689
  };
2685
- const removeCreatedVertices = () => {
2686
- while (createdVertices.length) {
2687
- this.removeVertexFromPreviouslyCreatedEdge(createdVertices.pop());
1690
+ const removeCreatedNodes = () => {
1691
+ while (createdNodes.length) {
1692
+ this.removeNodeFromPreviouslyCreatedEdge(createdNodes.pop());
2688
1693
  }
2689
1694
  };
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
+ const startNode = retrieveOrCreateNearestNode(start);
1696
+ const endNode = retrieveOrCreateNearestNode(end);
1697
+ const startCoords = start instanceof GraphNode ? start.coords : start;
1698
+ const endCoords = end instanceof GraphNode ? end.coords : end;
2694
1699
  let graphItinerary;
2695
- if (startVertex === endVertex) {
2696
- graphItinerary = GeoGraphItinerary.fromGraphVertices(
1700
+ if (startNode === endNode) {
1701
+ graphItinerary = GraphItinerary.fromNetworkNodes(
2697
1702
  startCoords,
2698
1703
  endCoords,
2699
- [startVertex],
1704
+ [startNode],
2700
1705
  []
2701
1706
  );
2702
1707
  } else {
2703
- graphItinerary = this.getShortestPathBetweenGeoGraphVertices(
2704
- startVertex,
2705
- endVertex,
2706
- weightEdgeFn,
2707
- acceptEdgeFn
1708
+ graphItinerary = this.getShortestPathBetweenGraphNodes(
1709
+ startNode,
1710
+ endNode,
1711
+ acceptEdgeFn,
1712
+ weightEdgeFn
2708
1713
  );
2709
1714
  }
2710
1715
  graphItinerary.start = startCoords;
2711
1716
  graphItinerary.end = endCoords;
2712
- removeCreatedVertices();
2713
- if (!graphItinerary.vertices.length) {
1717
+ removeCreatedNodes();
1718
+ if (!graphItinerary.nodes.length) {
2714
1719
  throw new NoRouteFoundError(start, end);
2715
1720
  }
2716
1721
  return graphItinerary;
2717
1722
  }
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);
1723
+ createNodeInsideEdge(edge, point) {
1724
+ const a = edge.node1;
1725
+ const b = edge.node2;
1726
+ const m = new GraphNode(point, edge.builtFrom);
1727
+ m.coords.level = edge.level;
1728
+ const u = edge.clone();
1729
+ u.node1 = a;
1730
+ u.node2 = m;
1731
+ const v = edge.clone();
1732
+ v.node1 = m;
1733
+ v.node2 = b;
2725
1734
  a.edges = a.edges.filter((_edge) => _edge !== edge);
2726
1735
  b.edges = b.edges.filter((_edge) => _edge !== edge);
2727
- this._graph.vertices.push(m);
2728
- this._graph.edges.push(u, v);
2729
- this._graph.edges = this._graph.edges.filter(
1736
+ this._network.nodes.push(m);
1737
+ this._network.edges.push(u, v);
1738
+ this._network.edges = this._network.edges.filter(
2730
1739
  (_edge) => _edge !== edge
2731
1740
  );
2732
1741
  return m;
2733
1742
  }
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(
1743
+ removeNodeFromPreviouslyCreatedEdge(_node) {
1744
+ const u = _node.edges[0];
1745
+ const v = _node.edges[1];
1746
+ u.node1.edges = u.node1.edges.filter((edge) => edge !== u);
1747
+ v.node1.edges = v.node1.edges.filter((edge) => edge !== v);
1748
+ const oldEdge = u.clone();
1749
+ oldEdge.node1 = u.node1;
1750
+ oldEdge.node2 = v.node2;
1751
+ this._network.edges.push(oldEdge);
1752
+ this._network.nodes = this._network.nodes.filter((node) => node !== _node);
1753
+ this._network.edges = this._network.edges.filter(
2745
1754
  (edge) => edge !== u && edge !== v
2746
1755
  );
2747
1756
  }
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;
1757
+ getShortestPathBetweenGraphNodes(start, end, acceptEdgeFn, weightFn) {
1758
+ const distanceMap = {}, checking = {}, vertexList = {}, vertexNodes = {}, parentVertices = {}, path = [];
1759
+ let vertexId = 1;
1760
+ this._network.nodes.forEach((vertex) => {
1761
+ vertex.uniqueRouterId = vertexId;
1762
+ vertexNodes[vertexId] = vertex;
1763
+ distanceMap[vertexId] = Infinity;
1764
+ checking[vertexId] = null;
1765
+ vertexList[vertexId] = true;
1766
+ vertexId++;
2755
1767
  });
2756
- distanceMap[start.id] = 0;
1768
+ const startVertex = Object.values(vertexNodes).find((vertex) => start.equals(vertex));
1769
+ const endVertex = Object.values(vertexNodes).find((vertex) => end.equals(vertex));
1770
+ distanceMap[startVertex.uniqueRouterId] = 0;
2757
1771
  while (Object.keys(vertexList).length > 0) {
2758
1772
  const keys = Object.keys(vertexList).map(Number);
2759
1773
  const current = Number(
2760
- keys.reduce((_checking, vertexId) => {
2761
- return distanceMap[_checking] > distanceMap[vertexId] ? vertexId : _checking;
1774
+ keys.reduce((_checking, vertexId2) => {
1775
+ return distanceMap[_checking] > distanceMap[vertexId2] ? vertexId2 : _checking;
2762
1776
  }, keys[0])
2763
1777
  );
2764
- this._graph.edges.filter((edge) => {
2765
- if (acceptEdgeFn && !acceptEdgeFn(edge) || this.disabledEdges.has(edge)) {
1778
+ this._network.edges.filter((edge) => {
1779
+ if (!acceptEdgeFn(edge) || this.disabledEdges.has(edge)) {
2766
1780
  return false;
2767
1781
  }
2768
- const from = edge.vertex1.id, to = edge.vertex2.id;
1782
+ const from = edge.node1.uniqueRouterId, to = edge.node2.uniqueRouterId;
2769
1783
  return from === current || to === current;
2770
1784
  }).forEach((edge) => {
2771
1785
  let to, from, reversed = false;
2772
- if (edge.vertex1.id === current) {
2773
- to = edge.vertex2.id;
2774
- from = edge.vertex1.id;
1786
+ if (edge.node1.uniqueRouterId === current) {
1787
+ to = edge.node2.uniqueRouterId;
1788
+ from = edge.node1.uniqueRouterId;
2775
1789
  } else {
2776
- to = edge.vertex1.id;
2777
- from = edge.vertex2.id;
1790
+ to = edge.node1.uniqueRouterId;
1791
+ from = edge.node2.uniqueRouterId;
2778
1792
  reversed = true;
2779
1793
  }
2780
1794
  if (edge.isOneway && reversed) {
@@ -2790,34 +1804,38 @@ class GeoGraphRouter {
2790
1804
  delete vertexList[current];
2791
1805
  }
2792
1806
  const edgesWeights = [];
2793
- let endId = end.id;
2794
- while (typeof parentVertices[endId] !== "undefined") {
2795
- path.unshift(vertices[endId]);
1807
+ let endId = endVertex.uniqueRouterId;
1808
+ while (parentVertices[endId]) {
1809
+ path.unshift(vertexNodes[endId]);
2796
1810
  edgesWeights.unshift(distanceMap[endId] - distanceMap[parentVertices[endId]]);
2797
1811
  endId = parentVertices[endId];
2798
1812
  }
2799
1813
  if (path.length !== 0) {
2800
1814
  path.unshift(start);
2801
1815
  }
2802
- return GeoGraphItinerary.fromGraphVertices(start.coords, end.coords, path, edgesWeights);
1816
+ this._network.nodes.forEach((vertex) => {
1817
+ delete vertex.uniqueRouterId;
1818
+ });
1819
+ return GraphItinerary.fromNetworkNodes(start.coords, end.coords, path, edgesWeights);
2803
1820
  }
2804
1821
  }
2805
- __publicField(GeoGraphRouter, "DEFAULT_OPTIONS", DEFAULT_OPTIONS);
2806
1822
  exports.AbsoluteHeading = AbsoluteHeading;
2807
1823
  exports.Attitude = Attitude;
2808
1824
  exports.BoundingBox = BoundingBox;
2809
1825
  exports.Constants = Constants;
2810
1826
  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
1827
  exports.GeoRef = GeoRef;
2819
1828
  exports.GeoRelativePosition = GeoRelativePosition;
1829
+ exports.GraphEdge = GraphEdge;
1830
+ exports.GraphItinerary = GraphItinerary;
1831
+ exports.GraphNode = GraphNode;
1832
+ exports.GraphProjection = GraphProjection;
1833
+ exports.GraphRouter = GraphRouter;
1834
+ exports.GraphRouterOptions = GraphRouterOptions;
1835
+ exports.GraphUtils = GraphUtils;
2820
1836
  exports.Level = Level;
1837
+ exports.MapMatching = MapMatching;
1838
+ exports.Network = Network;
2821
1839
  exports.NoRouteFoundError = NoRouteFoundError;
2822
1840
  exports.RelativePosition = RelativePosition;
2823
1841
  exports.UserPosition = UserPosition;