@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.3

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 (125) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +43 -45
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +241 -271
  8. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +876 -1188
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +173 -163
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +546 -620
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +155 -160
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  27. package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
  28. package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
  29. package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
  30. package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
  31. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
  32. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +832 -1060
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
  38. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  39. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
  40. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
  41. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
  42. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
  43. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +428 -556
  44. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  45. package/lib/cjs/react/MetaAtlasMap.js +127 -0
  46. package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
  47. package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
  48. package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
  49. package/lib/cjs/react/hooks/useFocus/index.js +48 -55
  50. package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
  51. package/lib/cjs/react/hooks/useMapEvents/index.js +40 -50
  52. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  53. package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
  54. package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
  55. package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
  56. package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
  57. package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
  58. package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
  59. package/lib/cjs/react/hooks/useRouting/index.js +21 -20
  60. package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
  61. package/lib/cjs/react/hooks/useSearch/index.js +35 -34
  62. package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
  63. package/lib/cjs/react/hooks/useStampRally/index.js +30 -29
  64. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
  66. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/cjs/react/index.js +31 -31
  68. package/lib/cjs/react/index.js.map +1 -1
  69. package/lib/cjs/react/stores/useMapDataStore.js +53 -64
  70. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  71. package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
  72. package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
  73. package/lib/esm/index.js +3 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -1
  76. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  77. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +10 -9
  78. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  79. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +2 -2
  80. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  81. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  82. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
  84. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +22 -14
  86. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +8 -8
  88. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  89. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
  90. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  91. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +18 -11
  92. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  93. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +4 -3
  94. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  95. package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
  96. package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
  97. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +80 -61
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
  102. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  103. package/lib/esm/react/MetaAtlasMap.js +120 -0
  104. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  105. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  106. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  107. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  108. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
  110. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  112. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  114. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  117. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  118. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  119. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  120. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useStampRally/index.js +8 -7
  122. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  123. package/lib/esm/react/index.js +11 -15
  124. package/lib/esm/react/index.js.map +1 -1
  125. package/package.json +9 -6
@@ -4,38 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MetaAtlasCore = exports.FilterType = void 0;
7
- var _focustree = _interopRequireDefault(require("./focustree.json"));
8
- var _whatTaxonomies = _interopRequireDefault(require("./whatTaxonomies.json"));
7
+ var _focustreeJson = _interopRequireDefault(require("./focustree.json.js"));
8
+ var _whatTaxonomiesJson = _interopRequireDefault(require("./whatTaxonomies.json.js"));
9
9
  var _length = _interopRequireDefault(require("@turf/length"));
10
10
  var _helpers = require("@turf/helpers");
11
11
  var _center = _interopRequireDefault(require("@turf/center"));
12
12
  var _lineSliceAlong = _interopRequireDefault(require("@turf/line-slice-along"));
13
13
  var _booleanPointInPolygon = _interopRequireDefault(require("@turf/boolean-point-in-polygon"));
14
14
  var _axios = _interopRequireDefault(require("axios"));
15
- var _localStorage = require("../utils/local-storage");
16
- var _fetchPublishedJson = require("./fetch-published-json");
17
- var _mapobjectsStore = _interopRequireDefault(require("../utils/mapobjects-store"));
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
20
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
21
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
23
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
24
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
25
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
26
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
30
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
31
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
32
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
33
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
34
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
35
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
36
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
37
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
38
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ var _localStorage = require("../utils/local-storage.js");
16
+ var _fetchPublishedJson = require("./fetch-published-json.js");
17
+ var _mapobjectsStore = _interopRequireDefault(require("../utils/mapobjects-store.js"));
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
39
19
  // Type for clicked features that includes both metaFeature data and raw click event
40
20
  var SortType = /*#__PURE__*/function (SortType) {
41
21
  SortType["Name"] = "Name";
@@ -44,30 +24,28 @@ var SortType = /*#__PURE__*/function (SortType) {
44
24
  SortType["RelevanceStrict"] = "RelevanceStrict";
45
25
  return SortType;
46
26
  }(SortType || {});
47
- var FilterType = exports.FilterType = /*#__PURE__*/function (FilterType) {
27
+ let FilterType = exports.FilterType = /*#__PURE__*/function (FilterType) {
48
28
  FilterType["Name"] = "title";
49
29
  FilterType["LocalRef"] = "localRef";
50
30
  FilterType["WhatTaxonomy"] = "dimension_what";
51
31
  return FilterType;
52
32
  }({});
53
- var MetaAtlasCore = exports.MetaAtlasCore = /*#__PURE__*/function () {
54
- function MetaAtlasCore() {
55
- _classCallCheck(this, MetaAtlasCore);
56
- _defineProperty(this, "defaultFocusedTaxonomy", 'where.changi');
57
- _defineProperty(this, "searchableGeoJsonFeatures", []);
58
- _defineProperty(this, "currentFocus", this.defaultFocusedTaxonomy);
59
- // For ATOMS API
60
- _defineProperty(this, "token", '');
61
- _defineProperty(this, "empApi", '');
62
- _defineProperty(this, "atomsAPIAccessToken", '');
63
- _defineProperty(this, "apiRequestLimit", 5000);
64
- // For Routing & Search
65
- _defineProperty(this, "secretKeyForDecryption", '');
66
- _defineProperty(this, "routingStatus", _fetchPublishedJson.Status.Awaiting);
67
- _defineProperty(this, "searchStatus", _fetchPublishedJson.Status.Awaiting);
68
- _defineProperty(this, "storage", new _localStorage.LocalStorage());
69
- _defineProperty(this, "ignoredLayers", ['Aerodrome', 'Aerodrome names', 'Aerobridge', 'Aerobridge gates', 'Airplanes', 'Airplanes outline', 'Building Extrusion', 'Building icon', 'Building overlay', 'Building overlay outline', 'Building underlay', 'Building underlay icon', 'Building underlay selected outline', 'building_outline', 'Changi Airport Connector', 'Changi Airport Connector Text', 'Changi Walkway Text', 'T2 overlay outline copy', 'Building overlay base', 'Skytrain track outdoor']);
70
- _defineProperty(this, "nonFloorLayers", ['where.changi', 'where.changi.tarmac', 'where.changi.tarmac.public', 'where.changi.tarmac.private', 'where.changi.terminals', 'where.changi.terminals.jewel', 'where.changi.terminals.t1', 'where.changi.terminals.t2', 'where.changi.terminals.t3', 'where.changi.terminals.t4', 'where.hkcec.main_bldg', 'where.gbtb.flower_dome', 'where.lima', 'where.lima.mahsuri_center', 'where.lima.maritime', 'where.malaysia', 'where.malaysia.bcck', 'where.malaysia.rmh', 'where.malaysia.pm', 'where.indonesia.fairmont_jakarta']);
33
+ class MetaAtlasCore {
34
+ defaultFocusedTaxonomy = 'where.changi';
35
+ searchableGeoJsonFeatures = [];
36
+ currentFocus = this.defaultFocusedTaxonomy;
37
+ // For ATOMS API
38
+ token = '';
39
+ empApi = '';
40
+ atomsAPIAccessToken = '';
41
+ apiRequestLimit = 5000;
42
+
43
+ // For Routing & Search
44
+ secretKeyForDecryption = '';
45
+ routingStatus = (() => _fetchPublishedJson.Status.Awaiting)();
46
+ searchStatus = (() => _fetchPublishedJson.Status.Awaiting)();
47
+ storage = (() => new _localStorage.LocalStorage())();
48
+ constructor() {
71
49
  this.lastClicked = {
72
50
  mapObjectId: null,
73
51
  coordinates: null,
@@ -79,1275 +57,985 @@ var MetaAtlasCore = exports.MetaAtlasCore = /*#__PURE__*/function () {
79
57
  clickEvent: null
80
58
  };
81
59
  }
82
- return _createClass(MetaAtlasCore, [{
83
- key: "init",
84
- value: function init(apiServerURL, token, secretKey, onAuthenticationResponse) {
85
- this.empApi = apiServerURL;
86
- this.token = token;
87
- this.secretKeyForDecryption = secretKey;
88
- this.getAtomsAPIAccessToken(onAuthenticationResponse);
89
- }
90
- }, {
91
- key: "getAtomsAPIAccessToken",
92
- value: function getAtomsAPIAccessToken(onAuthenticationResponse) {
93
- var _this = this;
94
- var data = JSON.stringify({
95
- strategy: 'atomstoken',
96
- atomsSdkToken: this.token,
97
- clientEngine: 'API',
98
- clientOS: 'Linux'
99
- });
100
- var config = {
101
- method: 'post',
102
- url: "".concat(this.empApi, "/authentication"),
103
- headers: {
104
- 'Content-Type': 'application/json'
105
- },
106
- data: data
107
- };
108
- (0, _axios["default"])(config).then(/*#__PURE__*/function () {
109
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(response) {
110
- var _response$data;
111
- return _regenerator().w(function (_context) {
112
- while (1) switch (_context.n) {
113
- case 0:
114
- if (response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.accessToken) {
115
- _this.atomsAPIAccessToken = response.data.accessToken;
116
- onAuthenticationResponse({
117
- authenticated: true
118
- });
119
- }
120
- case 1:
121
- return _context.a(2);
122
- }
123
- }, _callee);
124
- }));
125
- return function (_x) {
126
- return _ref.apply(this, arguments);
127
- };
128
- }())["catch"](function (error) {
60
+ init(apiServerURL, token, secretKey, onAuthenticationResponse) {
61
+ this.empApi = apiServerURL;
62
+ this.token = token;
63
+ this.secretKeyForDecryption = secretKey;
64
+ this.getAtomsAPIAccessToken(onAuthenticationResponse);
65
+ }
66
+ getAtomsAPIAccessToken(onAuthenticationResponse) {
67
+ const data = JSON.stringify({
68
+ strategy: 'atomstoken',
69
+ atomsSdkToken: this.token,
70
+ clientEngine: 'API',
71
+ clientOS: 'Linux'
72
+ });
73
+ const config = {
74
+ method: 'post',
75
+ url: `${this.empApi}/authentication`,
76
+ headers: {
77
+ 'Content-Type': 'application/json'
78
+ },
79
+ data: data
80
+ };
81
+ (0, _axios.default)(config).then(async response => {
82
+ if (response?.data?.accessToken) {
83
+ this.atomsAPIAccessToken = response.data.accessToken;
129
84
  onAuthenticationResponse({
130
- authenticated: false,
131
- error: error
85
+ authenticated: true
132
86
  });
133
- });
134
- }
135
- }, {
136
- key: "setupRouting",
137
- value: function () {
138
- var _setupRouting = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(onRoutingStatusUpdateCallback) {
139
- var status;
140
- return _regenerator().w(function (_context2) {
141
- while (1) switch (_context2.n) {
142
- case 0:
143
- _context2.n = 1;
144
- return (0, _fetchPublishedJson.getPublishedData)({
145
- URL: this.empApi,
146
- accessToken: this.atomsAPIAccessToken,
147
- secretKey: this.secretKeyForDecryption,
148
- publishedDataType: _fetchPublishedJson.PublishedDataType.Routing
149
- }, this.storage);
150
- case 1:
151
- status = _context2.v;
152
- this.routingStatus = status;
153
- console.log('routing status: ', status);
154
- if (onRoutingStatusUpdateCallback) {
155
- onRoutingStatusUpdateCallback(status === _fetchPublishedJson.Status.Ready ? true : false);
156
- }
157
- case 2:
158
- return _context2.a(2);
159
- }
160
- }, _callee2, this);
161
- }));
162
- function setupRouting(_x2) {
163
- return _setupRouting.apply(this, arguments);
164
87
  }
165
- return setupRouting;
166
- }()
167
- }, {
168
- key: "getRoutingStatus",
169
- value: function getRoutingStatus() {
170
- return this.routingStatus;
88
+ }).catch(function (error) {
89
+ onAuthenticationResponse({
90
+ authenticated: false,
91
+ error: error
92
+ });
93
+ });
94
+ }
95
+ async setupRouting(onRoutingStatusUpdateCallback) {
96
+ const status = await (0, _fetchPublishedJson.getPublishedData)({
97
+ URL: this.empApi,
98
+ accessToken: this.atomsAPIAccessToken,
99
+ secretKey: this.secretKeyForDecryption,
100
+ publishedDataType: _fetchPublishedJson.PublishedDataType.Routing
101
+ }, this.storage);
102
+ this.routingStatus = status;
103
+ console.log('routing status: ', status);
104
+ if (onRoutingStatusUpdateCallback) {
105
+ onRoutingStatusUpdateCallback(status === _fetchPublishedJson.Status.Ready ? true : false);
171
106
  }
107
+ }
108
+ getRoutingStatus() {
109
+ return this.routingStatus;
110
+ }
172
111
 
173
- // last clicked related functionality
174
- }, {
175
- key: "setLastClickedFeature",
176
- value: function setLastClickedFeature(featureData) {
177
- var _this2 = this;
178
- if (featureData.mapObjectId) {
179
- this.getMapObjectById(featureData.mapObjectId, function (res) {
180
- var mo = res === null || res === void 0 ? void 0 : res[0];
181
- if (mo) {
182
- _this2.lastClicked = _objectSpread(_objectSpread({}, featureData), {}, {
183
- properties: _objectSpread(_objectSpread({}, featureData.properties), {}, {
184
- booth_info: mo.properties.booth_info
185
- })
186
- });
187
- }
188
- });
189
- } else {
190
- this.lastClicked = featureData;
191
- }
112
+ // last clicked related functionality
113
+ setLastClickedFeature(featureData) {
114
+ if (featureData.mapObjectId) {
115
+ this.getMapObjectById(featureData.mapObjectId, res => {
116
+ const mo = res?.[0];
117
+ if (mo) {
118
+ this.lastClicked = {
119
+ ...featureData,
120
+ properties: {
121
+ ...featureData.properties,
122
+ booth_info: mo.properties.booth_info
123
+ }
124
+ };
125
+ }
126
+ });
127
+ } else {
128
+ this.lastClicked = featureData;
192
129
  }
193
- }, {
194
- key: "getLastClickedFeature",
195
- value: function getLastClickedFeature() {
196
- var clickedFeature = this.lastClicked;
197
- if (!this.lastClicked || this.lastClicked && (this.lastClicked.name === null || this.lastClicked.whereDimension === null)) {
198
- var feature = {
199
- mapObjectId: null,
200
- coordinates: null,
201
- name: null,
202
- whatDimension: null,
203
- whereDimension: null,
204
- geometry: null,
205
- properties: null,
206
- clickEvent: null
207
- };
208
- this.setLastClickedFeature(feature);
209
- clickedFeature = feature;
210
- }
211
- return clickedFeature;
130
+ }
131
+ getLastClickedFeature() {
132
+ let clickedFeature = this.lastClicked;
133
+ if (!this.lastClicked || this.lastClicked && (this.lastClicked.name === null || this.lastClicked.whereDimension === null)) {
134
+ const feature = {
135
+ mapObjectId: null,
136
+ coordinates: null,
137
+ name: null,
138
+ whatDimension: null,
139
+ whereDimension: null,
140
+ geometry: null,
141
+ properties: null,
142
+ clickEvent: null
143
+ };
144
+ this.setLastClickedFeature(feature);
145
+ clickedFeature = feature;
212
146
  }
213
- }, {
214
- key: "isClickableFeature",
215
- value: function isClickableFeature(feature) {
216
- if (feature.properties.isSearchable && feature.properties.title !== 'Transit' && feature.properties.title !== 'Public') {
217
- return true;
218
- }
219
- return false;
147
+ return clickedFeature;
148
+ }
149
+ isClickableFeature(feature) {
150
+ if (feature.properties.isSearchable && feature.properties.title !== 'Transit' && feature.properties.title !== 'Public') {
151
+ return true;
220
152
  }
221
- }, {
222
- key: "getMidPointOfFeature",
223
- value: function getMidPointOfFeature(feature) {
224
- if (!feature) {
225
- return null;
226
- }
227
- if (feature.lngLat) {
228
- return feature.lngLat;
229
- }
230
- if (!feature.geometry) {
231
- return null;
232
- }
233
- if (feature.geometry.type === 'Point') {
234
- return feature.geometry.coordinates;
235
- }
236
- var gjson = (0, _helpers.feature)(feature.geometry);
237
- if (gjson.geometry.type === 'LineString' || gjson.geometry.type === 'MultiLineString' && gjson.geometry.coordinates.length == 1) {
238
- gjson = (0, _helpers.lineString)(feature.geometry.coordinates);
239
- var gjsonLength = (0, _length["default"])(gjson);
240
- var splicedLine = (0, _lineSliceAlong["default"])(gjson, gjsonLength / 2, gjsonLength);
241
- return splicedLine.geometry.coordinates[0];
242
- }
243
- return (0, _center["default"])(gjson).geometry.coordinates;
153
+ return false;
154
+ }
155
+ getMidPointOfFeature(feature) {
156
+ if (!feature) {
157
+ return null;
244
158
  }
245
-
246
- // focus control related methods
247
- }, {
248
- key: "getFocusTree",
249
- value: function getFocusTree() {
250
- return _focustree["default"];
159
+ if (feature.lngLat) {
160
+ return feature.lngLat;
251
161
  }
252
- }, {
253
- key: "getWhatTaxonomies",
254
- value: function getWhatTaxonomies() {
255
- return _whatTaxonomies["default"];
162
+ if (!feature.geometry) {
163
+ return null;
256
164
  }
257
- }, {
258
- key: "getCurrentFocus",
259
- value: function getCurrentFocus() {
260
- return this.currentFocus;
165
+ if (feature.geometry.type === 'Point') {
166
+ return feature.geometry.coordinates;
261
167
  }
262
- }, {
263
- key: "getCurrentFocusBuilding",
264
- value: function getCurrentFocusBuilding() {
265
- for (var bld in _focustree["default"].site.buildings) {
266
- if (this.currentFocus.includes(_focustree["default"].site.buildings[bld].taxonomyPath)) {
267
- return _focustree["default"].site.buildings[bld];
268
- }
269
- }
270
- return null;
168
+ let gjson = (0, _helpers.feature)(feature.geometry);
169
+ if (gjson.geometry.type === 'LineString' || gjson.geometry.type === 'MultiLineString' && gjson.geometry.coordinates.length == 1) {
170
+ gjson = (0, _helpers.lineString)(feature.geometry.coordinates);
171
+ let gjsonLength = (0, _length.default)(gjson);
172
+ let splicedLine = (0, _lineSliceAlong.default)(gjson, gjsonLength / 2, gjsonLength);
173
+ return splicedLine.geometry.coordinates[0];
271
174
  }
272
- }, {
273
- key: "getCurrentFocusFloor",
274
- value: function getCurrentFocusFloor() {
275
- var currentBuilding = this.getCurrentFocusBuilding();
276
- if (!currentBuilding) {
277
- return;
278
- }
279
- for (var f in currentBuilding.floors) {
280
- if (this.currentFocus === currentBuilding.floors[f].taxonomyPath) {
281
- return currentBuilding.floors[f];
282
- }
175
+ return (0, _center.default)(gjson).geometry.coordinates;
176
+ }
177
+
178
+ // focus control related methods
179
+ getFocusTree() {
180
+ return _focustreeJson.default;
181
+ }
182
+ getWhatTaxonomies() {
183
+ return _whatTaxonomiesJson.default;
184
+ }
185
+ getCurrentFocus() {
186
+ return this.currentFocus;
187
+ }
188
+ getCurrentFocusBuilding() {
189
+ for (let bld in _focustreeJson.default.site.buildings) {
190
+ if (this.currentFocus.includes(_focustreeJson.default.site.buildings[bld].taxonomyPath)) {
191
+ return _focustreeJson.default.site.buildings[bld];
283
192
  }
284
- return null;
285
193
  }
286
- }, {
287
- key: "getUserViewportBuilding",
288
- value: function getUserViewportBuilding(currentCenter) {
289
- var centerPoint = (0, _helpers.point)(currentCenter);
290
- //get building bounds
291
- for (var bIndex in _focustree["default"].site.buildings) {
292
- //check if center in building bounds
293
- var b = _focustree["default"].site.buildings[bIndex];
294
- if (!b.hasOwnProperty('bounds')) {
295
- continue;
296
- }
297
- var bounds = (0, _helpers.polygon)(b.bounds);
298
- if ((0, _booleanPointInPolygon["default"])(centerPoint, bounds)) {
299
- return b;
300
- }
301
- }
302
- return null;
194
+ return null;
195
+ }
196
+ getCurrentFocusFloor() {
197
+ let currentBuilding = this.getCurrentFocusBuilding();
198
+ if (!currentBuilding) {
199
+ return;
303
200
  }
304
- }, {
305
- key: "checkUserViewport",
306
- value: function checkUserViewport(currentCenter, building, floor) {
307
- //get user center
308
- var centerPoint = (0, _helpers.point)(currentCenter);
309
- //check building
310
- if (building === null || building === undefined) {
311
- return false;
312
- }
313
- //check if user is viewing building
314
- if (!building.hasOwnProperty('bounds')) {
315
- return false;
201
+ for (let f in currentBuilding.floors) {
202
+ if (this.currentFocus === currentBuilding.floors[f].taxonomyPath) {
203
+ return currentBuilding.floors[f];
316
204
  }
317
- var bBounds = (0, _helpers.polygon)(building.bounds);
318
- var isViewingBuilding = (0, _booleanPointInPolygon["default"])(centerPoint, bBounds);
319
- //check floor
320
- if (floor === null || floor === undefined) {
321
- return isViewingBuilding;
205
+ }
206
+ return null;
207
+ }
208
+ getUserViewportBuilding(currentCenter) {
209
+ let centerPoint = (0, _helpers.point)(currentCenter);
210
+ //get building bounds
211
+ for (let bIndex in _focustreeJson.default.site.buildings) {
212
+ //check if center in building bounds
213
+ let b = _focustreeJson.default.site.buildings[bIndex];
214
+ if (!b.hasOwnProperty('bounds')) {
215
+ continue;
322
216
  }
323
- //check if user is viewing floor
324
- if (!floor.hasOwnProperty('bounds')) {
325
- return isViewingBuilding;
217
+ let bounds = (0, _helpers.polygon)(b.bounds);
218
+ if ((0, _booleanPointInPolygon.default)(centerPoint, bounds)) {
219
+ return b;
326
220
  }
327
- var fBounds = (0, _helpers.polygon)(floor.bounds);
328
- var isViewingFloor = (0, _booleanPointInPolygon["default"])(centerPoint, fBounds);
329
- return isViewingBuilding || isViewingFloor;
330
221
  }
331
- }, {
332
- key: "filterBaseMapWhereDimension",
333
- value: function filterBaseMapWhereDimension(layersData, whereTaxonomyPath) {
334
- var dimensionWhere = whereTaxonomyPath;
335
- if (!dimensionWhere) {
336
- return;
337
- }
338
- this.currentFocus = dimensionWhere;
339
- var whereFilters = [dimensionWhere];
222
+ return null;
223
+ }
224
+ checkUserViewport(currentCenter, building, floor) {
225
+ //get user center
226
+ let centerPoint = (0, _helpers.point)(currentCenter);
227
+ //check building
228
+ if (building === null || building === undefined) {
229
+ return false;
230
+ }
231
+ //check if user is viewing building
232
+ if (!building.hasOwnProperty('bounds')) {
233
+ return false;
234
+ }
235
+ let bBounds = (0, _helpers.polygon)(building.bounds);
236
+ let isViewingBuilding = (0, _booleanPointInPolygon.default)(centerPoint, bBounds);
237
+ //check floor
238
+ if (floor === null || floor === undefined) {
239
+ return isViewingBuilding;
240
+ }
241
+ //check if user is viewing floor
242
+ if (!floor.hasOwnProperty('bounds')) {
243
+ return isViewingBuilding;
244
+ }
245
+ let fBounds = (0, _helpers.polygon)(floor.bounds);
246
+ let isViewingFloor = (0, _booleanPointInPolygon.default)(centerPoint, fBounds);
247
+ return isViewingBuilding || isViewingFloor;
248
+ }
249
+ ignoredLayers = ['Aerodrome', 'Aerodrome names', 'Aerobridge', 'Aerobridge gates', 'Airplanes', 'Airplanes outline', 'Building Extrusion', 'Building icon', 'Building overlay', 'Building overlay outline', 'Building underlay', 'Building underlay icon', 'Building underlay selected outline', 'building_outline', 'Changi Airport Connector', 'Changi Airport Connector Text', 'Changi Walkway Text', 'T2 overlay outline copy', 'Building overlay base', 'Skytrain track outdoor'];
250
+ nonFloorLayers = ['where.changi', 'where.changi.tarmac', 'where.changi.tarmac.public', 'where.changi.tarmac.private', 'where.changi.terminals', 'where.changi.terminals.jewel', 'where.changi.terminals.t1', 'where.changi.terminals.t2', 'where.changi.terminals.t3', 'where.changi.terminals.t4', 'where.hkcec.main_bldg', 'where.gbtb.flower_dome', 'where.lima', 'where.lima.mahsuri_center', 'where.lima.maritime', 'where.malaysia', 'where.malaysia.bcck', 'where.malaysia.rmh', 'where.malaysia.pm', 'where.indonesia.fairmont_jakarta'];
251
+ filterBaseMapWhereDimension(layersData, whereTaxonomyPath) {
252
+ let dimensionWhere = whereTaxonomyPath;
253
+ if (!dimensionWhere) {
254
+ return;
255
+ }
256
+ this.currentFocus = dimensionWhere;
257
+ let whereFilters = [dimensionWhere];
340
258
 
341
- // Check if dimensionWhere matches the site taxonomyPath
342
- if (dimensionWhere === _focustree["default"].site.taxonomyPath) {
343
- // If it equals site, add all floors of all buildings
344
- whereFilters = [];
345
- if (_focustree["default"].site.buildings && Array.isArray(_focustree["default"].site.buildings)) {
346
- var _iterator = _createForOfIteratorHelper(_focustree["default"].site.buildings),
347
- _step;
348
- try {
349
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
350
- var building = _step.value;
351
- if (building.floors && Array.isArray(building.floors)) {
352
- var _iterator2 = _createForOfIteratorHelper(building.floors),
353
- _step2;
354
- try {
355
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
356
- var floor = _step2.value;
357
- if (floor.taxonomyPath) {
358
- whereFilters.push(floor.taxonomyPath);
359
- }
360
- }
361
- } catch (err) {
362
- _iterator2.e(err);
363
- } finally {
364
- _iterator2.f();
365
- }
259
+ // Check if dimensionWhere matches the site taxonomyPath
260
+ if (dimensionWhere === _focustreeJson.default.site.taxonomyPath) {
261
+ // If it equals site, add all floors of all buildings
262
+ whereFilters = [];
263
+ if (_focustreeJson.default.site.buildings && Array.isArray(_focustreeJson.default.site.buildings)) {
264
+ for (const building of _focustreeJson.default.site.buildings) {
265
+ if (building.floors && Array.isArray(building.floors)) {
266
+ for (const floor of building.floors) {
267
+ if (floor.taxonomyPath) {
268
+ whereFilters.push(floor.taxonomyPath);
366
269
  }
367
270
  }
368
- } catch (err) {
369
- _iterator.e(err);
370
- } finally {
371
- _iterator.f();
372
271
  }
373
- } else {
374
- // If it equals a site and has no buildings, add the site itself
375
- whereFilters = [_focustree["default"].site.taxonomyPath];
376
272
  }
377
273
  } else {
378
- // Check if dimensionWhere matches any building's taxonomyPath
379
- var _iterator3 = _createForOfIteratorHelper(_focustree["default"].site.buildings),
380
- _step3;
381
- try {
382
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
383
- var _building = _step3.value;
384
- if (dimensionWhere === _building.taxonomyPath) {
385
- // If it equals a building, add all floors of that building
386
- whereFilters = [];
387
- if (_building.floors && Array.isArray(_building.floors)) {
388
- var _iterator4 = _createForOfIteratorHelper(_building.floors),
389
- _step4;
390
- try {
391
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
392
- var _floor = _step4.value;
393
- if (_floor.taxonomyPath) {
394
- whereFilters.push(_floor.taxonomyPath);
395
- }
396
- }
397
- } catch (err) {
398
- _iterator4.e(err);
399
- } finally {
400
- _iterator4.f();
401
- }
402
- }
403
- // If it equals a building, but has no floors, add the building itself
404
- else {
405
- whereFilters = [_building.taxonomyPath];
274
+ // If it equals a site and has no buildings, add the site itself
275
+ whereFilters = [_focustreeJson.default.site.taxonomyPath];
276
+ }
277
+ } else {
278
+ // Check if dimensionWhere matches any building's taxonomyPath
279
+ for (const building of _focustreeJson.default.site.buildings) {
280
+ if (dimensionWhere === building.taxonomyPath) {
281
+ // If it equals a building, add all floors of that building
282
+ whereFilters = [];
283
+ if (building.floors && Array.isArray(building.floors)) {
284
+ for (const floor of building.floors) {
285
+ if (floor.taxonomyPath) {
286
+ whereFilters.push(floor.taxonomyPath);
406
287
  }
407
- break;
408
288
  }
409
289
  }
410
- } catch (err) {
411
- _iterator3.e(err);
412
- } finally {
413
- _iterator3.f();
414
- }
415
- }
416
- console.log('whereFilters: ', whereFilters);
417
- if (layersData.length > 0) {
418
- for (var index = 0; index < layersData.length; index += 1) {
419
- var layerID = layersData[index].id;
420
- if (!this.ignoredLayers.includes(layerID)) {
421
- this.filterLayer(layersData[index], whereFilters);
290
+ // If it equals a building, but has no floors, add the building itself
291
+ else {
292
+ whereFilters = [building.taxonomyPath];
422
293
  }
294
+ break;
423
295
  }
424
296
  }
425
- return layersData;
426
297
  }
427
- }, {
428
- key: "filterLayersWhereDimension",
429
- value: function filterLayersWhereDimension(layersData, whereTaxonomyPath) {
430
- var dimensionWhere = whereTaxonomyPath;
431
- if (!dimensionWhere) {
432
- return;
433
- }
434
- var whereFilters = [];
435
- whereFilters = [dimensionWhere];
436
- for (var index = 0; index < layersData.length; index += 1) {
437
- this.filterLayer(layersData[index], whereFilters);
298
+ console.log('whereFilters: ', whereFilters);
299
+ if (layersData.length > 0) {
300
+ for (let index = 0; index < layersData.length; index += 1) {
301
+ const layerID = layersData[index].id;
302
+ if (!this.ignoredLayers.includes(layerID)) {
303
+ this.filterLayer(layersData[index], whereFilters);
304
+ }
438
305
  }
439
- return layersData;
440
306
  }
441
- }, {
442
- key: "filterLayer",
443
- value: function filterLayer(layer, whereFilters) {
444
- var layerFilter = layer.filter;
445
- if (layerFilter) {
446
- var filterFound = false;
447
- for (var fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
448
- var field = layerFilter[fieldIndex];
449
- if (Array.isArray(field[1]) && field[1][1] === 'dimension_where') {
450
- //update already added where filter value
451
- field[0] = 'in';
452
- field[2] = ['literal', whereFilters];
453
- filterFound = true;
454
- break;
455
- }
456
- }
457
- if (!filterFound) {
458
- layerFilter.push(['in', ['get', 'dimension_where'], ['literal', whereFilters]]);
307
+ return layersData;
308
+ }
309
+ filterLayersWhereDimension(layersData, whereTaxonomyPath) {
310
+ let dimensionWhere = whereTaxonomyPath;
311
+ if (!dimensionWhere) {
312
+ return;
313
+ }
314
+ let whereFilters = [];
315
+ whereFilters = [dimensionWhere];
316
+ for (let index = 0; index < layersData.length; index += 1) {
317
+ this.filterLayer(layersData[index], whereFilters);
318
+ }
319
+ return layersData;
320
+ }
321
+ filterLayer(layer, whereFilters) {
322
+ const layerFilter = layer.filter;
323
+ if (layerFilter) {
324
+ let filterFound = false;
325
+ for (let fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
326
+ const field = layerFilter[fieldIndex];
327
+ if (Array.isArray(field[1]) && field[1][1] === 'dimension_where') {
328
+ //update already added where filter value
329
+ field[0] = 'in';
330
+ field[2] = ['literal', whereFilters];
331
+ filterFound = true;
332
+ break;
459
333
  }
460
334
  }
335
+ if (!filterFound) {
336
+ layerFilter.push(['in', ['get', 'dimension_where'], ['literal', whereFilters]]);
337
+ }
461
338
  }
462
- }, {
463
- key: "getLocationNameFromWhereTaxonomyPath",
464
- value: function getLocationNameFromWhereTaxonomyPath(whereTaxonomyPath) {
465
- if (whereTaxonomyPath.includes('where.')) {
466
- var splitstr = whereTaxonomyPath.split('.');
339
+ }
340
+ getLocationNameFromWhereTaxonomyPath(whereTaxonomyPath) {
341
+ if (whereTaxonomyPath.includes('where.')) {
342
+ const splitstr = whereTaxonomyPath.split('.');
467
343
 
468
- //if floor
469
- if (!this.nonFloorLayers.includes(whereTaxonomyPath)) {
470
- return splitstr[splitstr.length - 1];
471
- }
344
+ //if floor
345
+ if (!this.nonFloorLayers.includes(whereTaxonomyPath)) {
472
346
  return splitstr[splitstr.length - 1];
473
347
  }
348
+ return splitstr[splitstr.length - 1];
474
349
  }
475
- }, {
476
- key: "getFlyToLocation",
477
- value: function getFlyToLocation(whereTaxonomyPath) {
478
- var isMobile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
479
- var location = this.getLocationNameFromWhereTaxonomyPath(whereTaxonomyPath);
480
- var getConfigForNode = function getConfigForNode(node) {
481
- var cameraConfigs = isMobile ? node.mobile : node.web;
482
- return cameraConfigs;
483
- };
484
- if (this.getLocationNameFromWhereTaxonomyPath(_focustree["default"].site.taxonomyPath) === location) {
485
- return getConfigForNode(_focustree["default"].site.cameraConfigs);
486
- } else {
487
- for (var index = 0; index < _focustree["default"].site.buildings.length; index++) {
488
- var building = _focustree["default"].site.buildings[index];
489
- if (this.getLocationNameFromWhereTaxonomyPath(building.taxonomyPath) !== location) {
490
- for (var _index = 0; _index < building.floors.length; _index++) {
491
- var floor = building.floors[_index];
492
- if (this.getLocationNameFromWhereTaxonomyPath(floor.taxonomyPath) === location) {
493
- if (floor.cameraConfigs) {
494
- return getConfigForNode(floor.cameraConfigs);
495
- } else {
496
- return getConfigForNode(building.cameraConfigs);
497
- }
350
+ }
351
+ getFlyToLocation(whereTaxonomyPath) {
352
+ let isMobile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
353
+ let location = this.getLocationNameFromWhereTaxonomyPath(whereTaxonomyPath);
354
+ const getConfigForNode = node => {
355
+ const cameraConfigs = isMobile ? node.mobile : node.web;
356
+ return cameraConfigs;
357
+ };
358
+ if (this.getLocationNameFromWhereTaxonomyPath(_focustreeJson.default.site.taxonomyPath) === location) {
359
+ return getConfigForNode(_focustreeJson.default.site.cameraConfigs);
360
+ } else {
361
+ for (let index = 0; index < _focustreeJson.default.site.buildings.length; index++) {
362
+ const building = _focustreeJson.default.site.buildings[index];
363
+ if (this.getLocationNameFromWhereTaxonomyPath(building.taxonomyPath) !== location) {
364
+ for (let index = 0; index < building.floors.length; index++) {
365
+ const floor = building.floors[index];
366
+ if (this.getLocationNameFromWhereTaxonomyPath(floor.taxonomyPath) === location) {
367
+ if (floor.cameraConfigs) {
368
+ return getConfigForNode(floor.cameraConfigs);
369
+ } else {
370
+ return getConfigForNode(building.cameraConfigs);
498
371
  }
499
372
  }
500
- } else {
501
- return getConfigForNode(building.cameraConfigs);
502
373
  }
374
+ } else {
375
+ return getConfigForNode(building.cameraConfigs);
503
376
  }
504
377
  }
505
- console.warn('Invalid whereTaxonomy passed to getFlyToLocation');
506
- return {
507
- center: undefined,
508
- zoom: undefined,
509
- bearing: undefined
510
- };
511
378
  }
512
- }, {
513
- key: "filterLayersByCategories",
514
- value: function filterLayersByCategories(layersData, filterType, filterValues, geomType, dimensionWhat, map) {
515
- if (!filterValues) {
516
- return;
517
- }
518
- for (var index = 0; index < layersData.length; index += 1) {
519
- var layerID = layersData[index].id;
520
- var layer = layersData[index];
521
- var filter = void 0;
522
- var layerFilter = layer.filter;
523
- if (geomType) {
524
- filter = ['any', ['!', ['all', ['==', ['geometry-type'], geomType], ['==', ['get', 'dimension_what'], dimensionWhat]]]];
525
- for (var _index2 = 0; _index2 < filterValues.length; _index2++) {
526
- var filterValue = filterValues[_index2];
527
- filter[1][1].splice(1, 0, ['!', ['in', filterValue, ['get', filterType]]]);
528
- }
529
- } else {
530
- filter = ['all'];
531
- for (var _index3 = 0; _index3 < filterValues.length; _index3++) {
532
- var _filterValue = filterValues[_index3];
533
- filter.push(['all', ['in', _filterValue, ['get', filterType]]]);
534
- }
379
+ console.warn('Invalid whereTaxonomy passed to getFlyToLocation');
380
+ return {
381
+ center: undefined,
382
+ zoom: undefined,
383
+ bearing: undefined
384
+ };
385
+ }
386
+ filterLayersByCategories(layersData, filterType, filterValues, geomType, dimensionWhat, map) {
387
+ if (!filterValues) {
388
+ return;
389
+ }
390
+ for (let index = 0; index < layersData.length; index += 1) {
391
+ const layerID = layersData[index].id;
392
+ const layer = layersData[index];
393
+ let filter;
394
+ const layerFilter = layer.filter;
395
+ if (geomType) {
396
+ filter = ['any', ['!', ['all', ['==', ['geometry-type'], geomType], ['==', ['get', 'dimension_what'], dimensionWhat]]]];
397
+ for (let index = 0; index < filterValues.length; index++) {
398
+ const filterValue = filterValues[index];
399
+ filter[1][1].splice(1, 0, ['!', ['in', filterValue, ['get', filterType]]]);
400
+ }
401
+ } else {
402
+ filter = ['all'];
403
+ for (let index = 0; index < filterValues.length; index++) {
404
+ const filterValue = filterValues[index];
405
+ filter.push(['all', ['in', filterValue, ['get', filterType]]]);
535
406
  }
536
- if (layerFilter) {
537
- var filterFound = false;
538
- for (var fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
539
- var field = layerFilter[fieldIndex];
540
- if (geomType) {
541
- if (field[0] === 'any' && Array.isArray(field[1]) && Array.isArray(field[1][1]) &&
542
- // Array.isArray(field[3][1]) &&
543
- // Array.isArray(field[3][1]) &&
544
- // Array.isArray(field[3][1][1]) &&
545
- // Array.isArray(field[3][1][2]) &&
546
- // Array.isArray(field[3][2]) &&
547
- field[1][0] === '!' && field[1][1][0] === 'all') {
548
- //update already added where filter value
549
- var subField = field[1][1];
550
- if (subField.length > 3) {
551
- // purge all previous entries
552
- subField.splice(1, subField.length - 3);
553
- }
554
- for (var _index4 = 0; _index4 < filterValues.length; _index4++) {
555
- var _filterValue2 = filterValues[_index4];
556
- field[1][1].splice(1, 0, ['!', ['in', _filterValue2, ['get', filterType]]]);
557
- }
558
- filterFound = true;
559
- break;
407
+ }
408
+ if (layerFilter) {
409
+ let filterFound = false;
410
+ for (let fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
411
+ let field = layerFilter[fieldIndex];
412
+ if (geomType) {
413
+ if (field[0] === 'any' && Array.isArray(field[1]) && Array.isArray(field[1][1]) &&
414
+ // Array.isArray(field[3][1]) &&
415
+ // Array.isArray(field[3][1]) &&
416
+ // Array.isArray(field[3][1][1]) &&
417
+ // Array.isArray(field[3][1][2]) &&
418
+ // Array.isArray(field[3][2]) &&
419
+ field[1][0] === '!' && field[1][1][0] === 'all') {
420
+ //update already added where filter value
421
+ const subField = field[1][1];
422
+ if (subField.length > 3) {
423
+ // purge all previous entries
424
+ subField.splice(1, subField.length - 3);
560
425
  }
561
- } else {
562
- if (Array.isArray(field[1]) && Array.isArray(field[1][1]) && field[0] === '!' && field[1][1][1] === filterType) {
563
- //update already added where filter value
564
- field[0] = '!';
565
- field[1][2] = ['literal', filterValues];
566
- filterFound = true;
567
- break;
426
+ for (let index = 0; index < filterValues.length; index++) {
427
+ const filterValue = filterValues[index];
428
+ field[1][1].splice(1, 0, ['!', ['in', filterValue, ['get', filterType]]]);
568
429
  }
430
+ filterFound = true;
431
+ break;
432
+ }
433
+ } else {
434
+ if (Array.isArray(field[1]) && Array.isArray(field[1][1]) && field[0] === '!' && field[1][1][1] === filterType) {
435
+ //update already added where filter value
436
+ field[0] = '!';
437
+ field[1][2] = ['literal', filterValues];
438
+ filterFound = true;
439
+ break;
569
440
  }
570
- }
571
- if (!filterFound) {
572
- layerFilter.push(filter);
573
441
  }
574
442
  }
575
- if (layerID.includes('Retail')) {
576
- var layerStyle = layer.paint;
577
- var styleFilter = ['case'];
578
- for (var _index5 = 0; _index5 < filterValues.length; _index5++) {
579
- var _filterValue3 = filterValues[_index5];
580
- styleFilter.push(["boolean", ['in', _filterValue3, ['get', filterType]], true]); // the category is enabled?
581
- styleFilter.push(0.99); // when enabled
582
- }
583
- styleFilter.push(0.25); // when disabled
443
+ if (!filterFound) {
444
+ layerFilter.push(filter);
445
+ }
446
+ }
447
+ if (layerID.includes('Retail')) {
448
+ const layerStyle = layer.paint;
449
+ const styleFilter = ['case'];
450
+ for (let index = 0; index < filterValues.length; index++) {
451
+ const filterValue = filterValues[index];
452
+ styleFilter.push(["boolean", ['in', filterValue, ['get', filterType]], true]); // the category is enabled?
453
+ styleFilter.push(0.99); // when enabled
454
+ }
455
+ styleFilter.push(0.25); // when disabled
584
456
 
585
- if (layer.type === 'fill') {
586
- var property = 'fill-opacity';
587
- layerStyle['fill-opacity'] = styleFilter;
588
- map.setPaintProperty(layerID, property, layerStyle[property]);
589
- }
590
- if (layer.type === 'line') {
591
- var _property = 'line-opacity';
592
- layerStyle['line-opacity'] = styleFilter;
593
- map.setPaintProperty(layerID, _property, layerStyle[_property]);
594
- }
457
+ if (layer.type === 'fill') {
458
+ const property = 'fill-opacity';
459
+ layerStyle['fill-opacity'] = styleFilter;
460
+ map.setPaintProperty(layerID, property, layerStyle[property]);
461
+ }
462
+ if (layer.type === 'line') {
463
+ const property = 'line-opacity';
464
+ layerStyle['line-opacity'] = styleFilter;
465
+ map.setPaintProperty(layerID, property, layerStyle[property]);
595
466
  }
596
467
  }
597
- return layersData;
598
468
  }
599
- }, {
600
- key: "filterLayersByType",
601
- value: function filterLayersByType(layersData, filterType, filterValues, geomType) {
602
- if (!filterValues) {
603
- return;
469
+ return layersData;
470
+ }
471
+ filterLayersByType(layersData, filterType, filterValues, geomType) {
472
+ if (!filterValues) {
473
+ return;
474
+ }
475
+ for (let index = 0; index < layersData.length; index += 1) {
476
+ const layer = layersData[index];
477
+ let filter;
478
+ const layerFilter = layer.filter;
479
+ if (geomType) {
480
+ filter = ['case', ['!', ['in', ['get', filterType], ['literal', filterValues]]], true, ['all', ['in', ['get', filterType], ['literal', filterValues]], ['!=', ['geometry-type'], geomType]], true, false];
481
+ } else {
482
+ filter = ['in', ['get', filterType], ['literal', filterValues]];
604
483
  }
605
- for (var index = 0; index < layersData.length; index += 1) {
606
- var layer = layersData[index];
607
- var filter = void 0;
608
- var layerFilter = layer.filter;
609
- if (geomType) {
610
- filter = ['case', ['!', ['in', ['get', filterType], ['literal', filterValues]]], true, ['all', ['in', ['get', filterType], ['literal', filterValues]], ['!=', ['geometry-type'], geomType]], true, false];
611
- } else {
612
- filter = ['in', ['get', filterType], ['literal', filterValues]];
613
- }
614
- if (layerFilter) {
615
- var filterFound = false;
616
- console.log('layerFilter: ', layerFilter);
617
- for (var fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
618
- var field = layerFilter[fieldIndex];
619
- if (geomType) {
620
- if (field[0] === 'case' && Array.isArray(field[1]) && Array.isArray(field[3]) && Array.isArray(field[3][1]) && Array.isArray(field[3][1]) && Array.isArray(field[3][1][1]) && Array.isArray(field[3][1][2]) && Array.isArray(field[3][2]) && field[3][1][1][1] === filterType && field[3][2][2] === geomType) {
621
- //update already added where filter value
622
- field[1][1][2] = ['literal', filterValues];
623
- field[1][1][1] = ['get', filterType];
624
- field[3][1][2] = ['literal', filterValues];
625
- field[3][1][1] = ['get', filterType];
626
- field[3][2][2] = geomType;
627
- filterFound = true;
628
- break;
629
- }
630
- } else {
631
- if (Array.isArray(field[1]) && field[0] === '!' && field[1][1] === filterType) {
632
- //update already added where filter value
633
- field[2] = ['literal', filterValues];
634
- filterFound = true;
635
- break;
636
- }
484
+ if (layerFilter) {
485
+ let filterFound = false;
486
+ console.log('layerFilter: ', layerFilter);
487
+ for (let fieldIndex = 0; fieldIndex < layerFilter.length; fieldIndex += 1) {
488
+ let field = layerFilter[fieldIndex];
489
+ if (geomType) {
490
+ if (field[0] === 'case' && Array.isArray(field[1]) && Array.isArray(field[3]) && Array.isArray(field[3][1]) && Array.isArray(field[3][1]) && Array.isArray(field[3][1][1]) && Array.isArray(field[3][1][2]) && Array.isArray(field[3][2]) && field[3][1][1][1] === filterType && field[3][2][2] === geomType) {
491
+ //update already added where filter value
492
+ field[1][1][2] = ['literal', filterValues];
493
+ field[1][1][1] = ['get', filterType];
494
+ field[3][1][2] = ['literal', filterValues];
495
+ field[3][1][1] = ['get', filterType];
496
+ field[3][2][2] = geomType;
497
+ filterFound = true;
498
+ break;
499
+ }
500
+ } else {
501
+ if (Array.isArray(field[1]) && field[0] === '!' && field[1][1] === filterType) {
502
+ //update already added where filter value
503
+ field[2] = ['literal', filterValues];
504
+ filterFound = true;
505
+ break;
637
506
  }
638
507
  }
639
- if (!filterFound) {
640
- console.log('pushing: ', filterValues, filterType);
641
- layerFilter.push(filter);
642
- }
508
+ }
509
+ if (!filterFound) {
510
+ console.log('pushing: ', filterValues, filterType);
511
+ layerFilter.push(filter);
643
512
  }
644
513
  }
645
- return layersData;
646
514
  }
647
- }, {
648
- key: "createFilterForStyle",
649
- value: function createFilterForStyle(defValue, filterType, filterValues, value) {
650
- function setRowForField(defCopy) {
651
- if (Array.isArray(defCopy) && defCopy[0] === 'match') {
652
- var defClone = _toConsumableArray(defCopy);
653
- if (Array.isArray(defClone[1]) && defClone[1][1] === filterType) {
654
- setRowForValue(defClone, defCopy);
655
- } else {
656
- defClone[defClone.length - 1] = setRowForField(defClone[defClone.length - 1]);
657
- }
658
- return defClone;
515
+ return layersData;
516
+ }
517
+ createFilterForStyle(defValue, filterType, filterValues, value) {
518
+ function setRowForField(defCopy) {
519
+ if (Array.isArray(defCopy) && defCopy[0] === 'match') {
520
+ let defClone = [...defCopy];
521
+ if (Array.isArray(defClone[1]) && defClone[1][1] === filterType) {
522
+ setRowForValue(defClone, defCopy);
659
523
  } else {
660
- return ['match', ['get', filterType], filterValues, value, defCopy];
524
+ defClone[defClone.length - 1] = setRowForField(defClone[defClone.length - 1]);
661
525
  }
526
+ return defClone;
527
+ } else {
528
+ return ['match', ['get', filterType], filterValues, value, defCopy];
662
529
  }
663
- function setRowForValue(defClone, defCopy) {
664
- for (var i = 3; i < defCopy.length; i += 2) {
665
- if (defClone[i] === value) {
666
- var newFilterValues = pushArray(defClone[i - 1], filterValues);
667
- defClone[i - 1] = newFilterValues;
668
- return;
669
- } else if (i + 2 === defCopy.length) {
670
- defClone.splice(i + 1, 0, filterValues, value);
671
- }
530
+ }
531
+ function setRowForValue(defClone, defCopy) {
532
+ for (let i = 3; i < defCopy.length; i += 2) {
533
+ if (defClone[i] === value) {
534
+ const newFilterValues = pushArray(defClone[i - 1], filterValues);
535
+ defClone[i - 1] = newFilterValues;
536
+ return;
537
+ } else if (i + 2 === defCopy.length) {
538
+ defClone.splice(i + 1, 0, filterValues, value);
672
539
  }
673
540
  }
674
- function pushArray(originalArray, newArray) {
675
- var filteredArray = newArray.filter(function (item) {
676
- return !originalArray.includes(item);
677
- });
678
- originalArray.push.apply(originalArray, _toConsumableArray(filteredArray));
679
- return originalArray;
680
- }
681
- return setRowForField(defValue);
682
541
  }
683
- }, {
684
- key: "styleLayersByType",
685
- value: function styleLayersByType(layersData, filterType, filterValues, property, value) {
686
- if (!filterValues) {
687
- return;
688
- }
689
- for (var index = 0; index < layersData.length; index += 1) {
690
- // if (layersData[index].isFireAlarmLayer) {
691
- var layer = layersData[index];
692
- var layerStyle = layer.paint;
693
- var layerType = layer.type;
542
+ function pushArray(originalArray, newArray) {
543
+ const filteredArray = newArray.filter(item => !originalArray.includes(item));
544
+ originalArray.push(...filteredArray);
545
+ return originalArray;
546
+ }
547
+ return setRowForField(defValue);
548
+ }
549
+ styleLayersByType(layersData, filterType, filterValues, property, value) {
550
+ if (!filterValues) {
551
+ return;
552
+ }
553
+ for (let index = 0; index < layersData.length; index += 1) {
554
+ // if (layersData[index].isFireAlarmLayer) {
555
+ const layer = layersData[index];
556
+ const layerStyle = layer.paint;
557
+ const layerType = layer.type;
694
558
 
695
- // TODO: add support for other layers later
696
- if (layerType && layerType === 'fill' || layerType === 'line') {
697
- if (layerStyle[property]) {
698
- var defValue = layerStyle[property];
699
- if (defValue) {
700
- var filter = this.createFilterForStyle(defValue, filterType, filterValues, value);
701
- layerStyle[property] = filter;
702
- }
559
+ // TODO: add support for other layers later
560
+ if (layerType && layerType === 'fill' || layerType === 'line') {
561
+ if (layerStyle[property]) {
562
+ let defValue = layerStyle[property];
563
+ if (defValue) {
564
+ const filter = this.createFilterForStyle(defValue, filterType, filterValues, value);
565
+ layerStyle[property] = filter;
703
566
  }
704
567
  }
705
- // }
706
568
  }
707
- return layersData;
569
+ // }
708
570
  }
709
- }, {
710
- key: "createFilterForClearStyle",
711
- value: function createFilterForClearStyle(defValue, filterType, filterValues) {
712
- function setRowForField(defCopy) {
713
- if (Array.isArray(defCopy) && defCopy[0] === 'match') {
714
- var defClone = _toConsumableArray(defCopy);
715
- if (Array.isArray(defClone[1]) && defClone[1][1] === filterType) {
716
- if (filterValues.length > 0) {
717
- setRowForValue(defClone, defCopy);
718
- } else {
719
- defClone = defClone[defClone.length - 1];
720
- }
571
+ return layersData;
572
+ }
573
+ createFilterForClearStyle(defValue, filterType, filterValues) {
574
+ function setRowForField(defCopy) {
575
+ if (Array.isArray(defCopy) && defCopy[0] === 'match') {
576
+ let defClone = [...defCopy];
577
+ if (Array.isArray(defClone[1]) && defClone[1][1] === filterType) {
578
+ if (filterValues.length > 0) {
579
+ setRowForValue(defClone, defCopy);
721
580
  } else {
722
- defClone[defClone.length - 1] = setRowForField(defClone[defClone.length - 1]);
581
+ defClone = defClone[defClone.length - 1];
723
582
  }
724
- return defClone;
583
+ } else {
584
+ defClone[defClone.length - 1] = setRowForField(defClone[defClone.length - 1]);
725
585
  }
586
+ return defClone;
726
587
  }
727
- function setRowForValue(defClone, defCopy) {
728
- var _loop = function _loop(i) {
729
- if (Array.isArray(defClone[i])) {
730
- filterValues.forEach(function (filterValue) {
731
- var index = defClone[i].indexOf(filterValue);
732
- if (index > -1) {
733
- if (defClone[i].length > 1) {
734
- defClone[i].splice(index, 1);
735
- } else {
736
- defClone[i] = [''];
737
- }
588
+ }
589
+ function setRowForValue(defClone, defCopy) {
590
+ for (let i = 2; i < defCopy.length; i += 2) {
591
+ if (Array.isArray(defClone[i])) {
592
+ filterValues.forEach(filterValue => {
593
+ const index = defClone[i].indexOf(filterValue);
594
+ if (index > -1) {
595
+ if (defClone[i].length > 1) {
596
+ defClone[i].splice(index, 1);
597
+ } else {
598
+ defClone[i] = [''];
738
599
  }
739
- });
740
- }
741
- };
742
- for (var i = 2; i < defCopy.length; i += 2) {
743
- _loop(i);
600
+ }
601
+ });
744
602
  }
745
603
  }
746
- return setRowForField(defValue);
747
604
  }
748
- }, {
749
- key: "clearStyleLayersByType",
750
- value: function clearStyleLayersByType(layersData, filterType, filterValues, property) {
751
- for (var index = 0; index < layersData.length; index += 1) {
752
- // if (layersData[index].isFireAlarmLayer) {
753
- var layer = layersData[index];
754
- var layerStyle = layer.paint;
755
- var layerType = layer.type;
605
+ return setRowForField(defValue);
606
+ }
607
+ clearStyleLayersByType(layersData, filterType, filterValues, property) {
608
+ for (let index = 0; index < layersData.length; index += 1) {
609
+ // if (layersData[index].isFireAlarmLayer) {
610
+ const layer = layersData[index];
611
+ const layerStyle = layer.paint;
612
+ const layerType = layer.type;
756
613
 
757
- // TODO: add support for other layers later
758
- if (layerType && layerType === 'fill' || layerType === 'line') {
759
- if (layerStyle[property]) {
760
- var defValue = layerStyle[property];
761
- if (defValue) {
762
- var filter = this.createFilterForClearStyle(defValue, filterType, filterValues);
763
- layerStyle[property] = filter;
764
- }
614
+ // TODO: add support for other layers later
615
+ if (layerType && layerType === 'fill' || layerType === 'line') {
616
+ if (layerStyle[property]) {
617
+ let defValue = layerStyle[property];
618
+ if (defValue) {
619
+ const filter = this.createFilterForClearStyle(defValue, filterType, filterValues);
620
+ layerStyle[property] = filter;
765
621
  }
766
622
  }
767
- // }
768
623
  }
769
- return layersData;
770
- }
771
- }, {
772
- key: "normalize",
773
- value: function normalize(string) {
774
- return string.trim().toLowerCase();
624
+ // }
775
625
  }
776
- }, {
777
- key: "relevanceSort",
778
- value: function relevanceSort(metaFeatures, query) {
779
- var isStrict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
780
- function score(metaFeature) {
781
- var noMatch = [-1, 0, metaFeature.name];
782
- if (metaFeature.name) {
783
- var lowerStr = metaFeature.name.toLowerCase();
784
- var lowerQuery = query.toLowerCase();
626
+ return layersData;
627
+ }
628
+ normalize(string) {
629
+ return string.trim().toLowerCase();
630
+ }
631
+ relevanceSort(metaFeatures, query) {
632
+ let isStrict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
633
+ function score(metaFeature) {
634
+ const noMatch = [-1, 0, metaFeature.name];
635
+ if (metaFeature.name) {
636
+ const lowerStr = metaFeature.name.toLowerCase();
637
+ const lowerQuery = query.toLowerCase();
785
638
 
786
- // 1. If the string is the same as the query
787
- if (lowerStr === lowerQuery) {
788
- return [1000, -metaFeature.name.length, lowerStr];
789
- }
790
- // 2. If the string starts with the query
791
- else if (lowerStr.startsWith(lowerQuery)) {
792
- return [500, -metaFeature.name.length, lowerStr];
793
- }
794
- // 3. If one of the words in the string starts with the query
795
- else if (lowerStr.split(' ').some(function (word) {
796
- return word.startsWith(lowerQuery);
797
- })) {
798
- return [200, -metaFeature.name.length, lowerStr];
799
- }
800
- // 4. The string contains the query
801
- else if (!isStrict) {
802
- if (lowerStr.includes(lowerQuery)) {
803
- return [0, -metaFeature.name.length, lowerStr];
804
- } else {
805
- return noMatch;
806
- }
639
+ // 1. If the string is the same as the query
640
+ if (lowerStr === lowerQuery) {
641
+ return [1000, -metaFeature.name.length, lowerStr];
642
+ }
643
+ // 2. If the string starts with the query
644
+ else if (lowerStr.startsWith(lowerQuery)) {
645
+ return [500, -metaFeature.name.length, lowerStr];
646
+ }
647
+ // 3. If one of the words in the string starts with the query
648
+ else if (lowerStr.split(' ').some(word => word.startsWith(lowerQuery))) {
649
+ return [200, -metaFeature.name.length, lowerStr];
650
+ }
651
+ // 4. The string contains the query
652
+ else if (!isStrict) {
653
+ if (lowerStr.includes(lowerQuery)) {
654
+ return [0, -metaFeature.name.length, lowerStr];
807
655
  } else {
808
656
  return noMatch;
809
657
  }
810
658
  } else {
811
659
  return noMatch;
812
660
  }
661
+ } else {
662
+ return noMatch;
813
663
  }
814
- return metaFeatures.sort(function (a, b) {
815
- var scoreA = score(a);
816
- var scoreB = score(b);
817
- return scoreB[0] - scoreA[0] || scoreB[1] - scoreA[1] || scoreA[2].localeCompare(scoreB[2]);
818
- }).filter(function (s) {
819
- return score(s)[0] >= 0;
820
- });
821
664
  }
822
- }, {
823
- key: "sort",
824
- value: function sort(metaFeatures, sortType) {
825
- var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
826
- var compare = function compare(a, b) {
827
- if (!a || !b) {
828
- return 0;
829
- }
830
- return a.localeCompare(b);
831
- };
832
- if (sortType === SortType.Name) {
833
- return metaFeatures.sort(function (a, b) {
665
+ return metaFeatures.sort((a, b) => {
666
+ const scoreA = score(a);
667
+ const scoreB = score(b);
668
+ return scoreB[0] - scoreA[0] || scoreB[1] - scoreA[1] || scoreA[2].localeCompare(scoreB[2]);
669
+ }).filter(s => score(s)[0] >= 0);
670
+ }
671
+ sort(metaFeatures, sortType) {
672
+ let query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
673
+ const compare = (a, b) => {
674
+ if (!a || !b) {
675
+ return 0;
676
+ }
677
+ return a.localeCompare(b);
678
+ };
679
+ if (sortType === SortType.Name) {
680
+ return metaFeatures.sort((a, b) => {
681
+ return compare(a.name, b.name);
682
+ });
683
+ } else if (sortType === SortType.WhereDimension) {
684
+ return metaFeatures.sort((a, b) => {
685
+ const whereComparison = compare(a.whereDimension, b.whereDimension);
686
+ if (whereComparison === 0) {
834
687
  return compare(a.name, b.name);
835
- });
836
- } else if (sortType === SortType.WhereDimension) {
837
- return metaFeatures.sort(function (a, b) {
838
- var whereComparison = compare(a.whereDimension, b.whereDimension);
839
- if (whereComparison === 0) {
840
- return compare(a.name, b.name);
841
- } else {
842
- return whereComparison;
688
+ } else {
689
+ return whereComparison;
690
+ }
691
+ });
692
+ } else if (sortType === SortType.Relevance) {
693
+ return this.relevanceSort(metaFeatures, query);
694
+ } else if (sortType === SortType.RelevanceStrict) {
695
+ return this.relevanceSort(metaFeatures, query, true);
696
+ }
697
+ }
698
+ async setupMapObjectSearch(onSearchStatusUpdateCallback) {
699
+ const status = await (0, _fetchPublishedJson.getPublishedData)({
700
+ URL: this.empApi,
701
+ accessToken: this.atomsAPIAccessToken,
702
+ secretKey: this.secretKeyForDecryption,
703
+ publishedDataType: _fetchPublishedJson.PublishedDataType.MapObjects
704
+ }, this.storage);
705
+ this.searchStatus = status;
706
+ console.log('search status: ', status);
707
+ const mapObjects = _mapobjectsStore.default.getState().data;
708
+ for (let index = 0; index < mapObjects.length; index++) {
709
+ const mapObject = mapObjects[index];
710
+ if (mapObject) {
711
+ // Decide geometry type based on coordinates format:
712
+ // - Point: [lng, lat]
713
+ // - LineString: [[lng, lat], [lng, lat], ...]
714
+ const coords = mapObject.lngLat;
715
+ const geometry = Array.isArray(coords) && Array.isArray(coords[0]) ? {
716
+ type: 'LineString',
717
+ coordinates: coords
718
+ } : {
719
+ type: 'Point',
720
+ coordinates: coords
721
+ };
722
+
723
+ // Re-create geojson
724
+ const moJSON = {
725
+ mapObjectId: mapObject.mID,
726
+ coordinates: mapObject.lngLat,
727
+ name: mapObject.name,
728
+ whatDimension: mapObject.what,
729
+ whereDimension: mapObject.where,
730
+ geometry,
731
+ properties: {
732
+ myMapObjectId: mapObject.mID,
733
+ title: mapObject.name,
734
+ localRef: mapObject.localRef,
735
+ dimension_what: mapObject.what,
736
+ dimension_where: mapObject.where,
737
+ booth_info: {
738
+ overview: mapObject.overview,
739
+ images: mapObject.images,
740
+ videos: mapObject.videos,
741
+ files: mapObject.files,
742
+ products: mapObject.products,
743
+ logos: mapObject.logos
744
+ },
745
+ metadata: mapObject.metadata ? JSON.parse(mapObject.metadata) : null
843
746
  }
844
- });
845
- } else if (sortType === SortType.Relevance) {
846
- return this.relevanceSort(metaFeatures, query);
847
- } else if (sortType === SortType.RelevanceStrict) {
848
- return this.relevanceSort(metaFeatures, query, true);
747
+ };
748
+ this.searchableGeoJsonFeatures.push(moJSON);
849
749
  }
850
750
  }
851
- }, {
852
- key: "setupMapObjectSearch",
853
- value: function () {
854
- var _setupMapObjectSearch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(onSearchStatusUpdateCallback) {
855
- var status, mapObjects, index, mapObject, coords, geometry, moJSON;
856
- return _regenerator().w(function (_context3) {
857
- while (1) switch (_context3.n) {
858
- case 0:
859
- _context3.n = 1;
860
- return (0, _fetchPublishedJson.getPublishedData)({
861
- URL: this.empApi,
862
- accessToken: this.atomsAPIAccessToken,
863
- secretKey: this.secretKeyForDecryption,
864
- publishedDataType: _fetchPublishedJson.PublishedDataType.MapObjects
865
- }, this.storage);
866
- case 1:
867
- status = _context3.v;
868
- this.searchStatus = status;
869
- console.log('search status: ', status);
870
- mapObjects = _mapobjectsStore["default"].getState().data;
871
- for (index = 0; index < mapObjects.length; index++) {
872
- mapObject = mapObjects[index];
873
- if (mapObject) {
874
- // Decide geometry type based on coordinates format:
875
- // - Point: [lng, lat]
876
- // - LineString: [[lng, lat], [lng, lat], ...]
877
- coords = mapObject.lngLat;
878
- geometry = Array.isArray(coords) && Array.isArray(coords[0]) ? {
879
- type: 'LineString',
880
- coordinates: coords
881
- } : {
882
- type: 'Point',
883
- coordinates: coords
884
- }; // Re-create geojson
885
- moJSON = {
886
- mapObjectId: mapObject.mID,
887
- coordinates: mapObject.lngLat,
888
- name: mapObject.name,
889
- whatDimension: mapObject.what,
890
- whereDimension: mapObject.where,
891
- geometry: geometry,
892
- properties: {
893
- myMapObjectId: mapObject.mID,
894
- title: mapObject.name,
895
- localRef: mapObject.localRef,
896
- dimension_what: mapObject.what,
897
- dimension_where: mapObject.where,
898
- booth_info: {
899
- overview: mapObject.overview,
900
- images: mapObject.images,
901
- videos: mapObject.videos,
902
- files: mapObject.files,
903
- products: mapObject.products,
904
- logos: mapObject.logos
905
- },
906
- metadata: mapObject.metadata ? JSON.parse(mapObject.metadata) : null
907
- }
908
- };
909
- this.searchableGeoJsonFeatures.push(moJSON);
910
- }
911
- }
912
- if (onSearchStatusUpdateCallback) {
913
- onSearchStatusUpdateCallback(status === _fetchPublishedJson.Status.Ready ? true : false);
914
- }
915
- case 2:
916
- return _context3.a(2);
917
- }
918
- }, _callee3, this);
919
- }));
920
- function setupMapObjectSearch(_x3) {
921
- return _setupMapObjectSearch.apply(this, arguments);
751
+ if (onSearchStatusUpdateCallback) {
752
+ onSearchStatusUpdateCallback(status === _fetchPublishedJson.Status.Ready ? true : false);
753
+ }
754
+ }
755
+ getMapObjectsByFilteredLocalRef(boothId) {
756
+ let searchSubString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
757
+ let sortType = arguments.length > 2 ? arguments[2] : undefined;
758
+ let onResponseCallback = arguments.length > 3 ? arguments[3] : undefined;
759
+ const uniqueIds = new Set();
760
+ const metaFeatures = [];
761
+ const boothIdToSearch = this.normalize(String(boothId));
762
+ for (const feature of this.searchableGeoJsonFeatures) {
763
+ const id = feature.properties.myMapObjectId;
764
+ const localRef = this.normalize(String(feature.properties.localRef));
765
+ if (searchSubString && !localRef.includes(boothIdToSearch)) {
766
+ continue;
922
767
  }
923
- return setupMapObjectSearch;
924
- }()
925
- }, {
926
- key: "getMapObjectsByFilteredLocalRef",
927
- value: function getMapObjectsByFilteredLocalRef(boothId) {
928
- var searchSubString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
929
- var sortType = arguments.length > 2 ? arguments[2] : undefined;
930
- var onResponseCallback = arguments.length > 3 ? arguments[3] : undefined;
931
- var uniqueIds = new Set();
932
- var metaFeatures = [];
933
- var boothIdToSearch = this.normalize(String(boothId));
934
- var _iterator5 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
935
- _step5;
936
- try {
937
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
938
- var feature = _step5.value;
939
- var id = feature.properties.myMapObjectId;
940
- var localRef = this.normalize(String(feature.properties.localRef));
941
- if (searchSubString && !localRef.includes(boothIdToSearch)) {
942
- continue;
943
- }
944
- if (!searchSubString && localRef !== boothIdToSearch) {
945
- continue;
946
- }
947
- if (uniqueIds.has(id)) {
948
- continue;
949
- }
950
- uniqueIds.add(id);
951
- var objFeature = {
952
- mapObjectId: String(feature.properties.myMapObjectId),
953
- coordinates: null,
954
- name: feature.properties.title,
955
- whatDimension: feature.properties.dimension_what,
956
- whereDimension: feature.properties.dimension_where,
957
- geometry: feature.geometry,
958
- properties: feature.properties
959
- };
960
- metaFeatures.push(objFeature);
961
- }
962
- } catch (err) {
963
- _iterator5.e(err);
964
- } finally {
965
- _iterator5.f();
768
+ if (!searchSubString && localRef !== boothIdToSearch) {
769
+ continue;
966
770
  }
967
- var sortedFeatures = this.sort(metaFeatures, sortType, boothId);
968
- onResponseCallback(sortedFeatures);
771
+ if (uniqueIds.has(id)) {
772
+ continue;
773
+ }
774
+ uniqueIds.add(id);
775
+ const objFeature = {
776
+ mapObjectId: String(feature.properties.myMapObjectId),
777
+ coordinates: null,
778
+ name: feature.properties.title,
779
+ whatDimension: feature.properties.dimension_what,
780
+ whereDimension: feature.properties.dimension_where,
781
+ geometry: feature.geometry,
782
+ properties: feature.properties
783
+ };
784
+ metaFeatures.push(objFeature);
969
785
  }
970
- }, {
971
- key: "getMapObjectsByName",
972
- value: function getMapObjectsByName(name) {
973
- var searchSubString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
974
- var sortType = arguments.length > 2 ? arguments[2] : undefined;
975
- var onResponseCallback = arguments.length > 3 ? arguments[3] : undefined;
976
- var uniqueIds = new Set();
977
- var metaFeatures = [];
978
- var nameToSearch = this.normalize(String(name));
979
- var _iterator6 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
980
- _step6;
981
- try {
982
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
983
- var feature = _step6.value;
984
- var id = feature.properties.myMapObjectId;
985
- var title = this.normalize(String(feature.properties.title));
986
- if (searchSubString && !title.includes(nameToSearch)) {
987
- continue;
988
- }
989
- if (!searchSubString && title !== nameToSearch) {
990
- continue;
991
- }
992
- if (uniqueIds.has(id)) {
993
- continue;
994
- }
995
- uniqueIds.add(id);
996
- var objFeature = {
997
- mapObjectId: String(feature.properties.myMapObjectId),
998
- coordinates: null,
999
- name: feature.properties.title,
1000
- whatDimension: feature.properties.dimension_what,
1001
- whereDimension: feature.properties.dimension_where,
1002
- geometry: feature.geometry,
1003
- properties: feature.properties
1004
- };
1005
- metaFeatures.push(objFeature);
1006
- }
1007
- } catch (err) {
1008
- _iterator6.e(err);
1009
- } finally {
1010
- _iterator6.f();
786
+ const sortedFeatures = this.sort(metaFeatures, sortType, boothId);
787
+ onResponseCallback(sortedFeatures);
788
+ }
789
+ getMapObjectsByName(name) {
790
+ let searchSubString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
791
+ let sortType = arguments.length > 2 ? arguments[2] : undefined;
792
+ let onResponseCallback = arguments.length > 3 ? arguments[3] : undefined;
793
+ const uniqueIds = new Set();
794
+ const metaFeatures = [];
795
+ const nameToSearch = this.normalize(String(name));
796
+ for (const feature of this.searchableGeoJsonFeatures) {
797
+ const id = feature.properties.myMapObjectId;
798
+ const title = this.normalize(String(feature.properties.title));
799
+ if (searchSubString && !title.includes(nameToSearch)) {
800
+ continue;
801
+ }
802
+ if (!searchSubString && title !== nameToSearch) {
803
+ continue;
804
+ }
805
+ if (uniqueIds.has(id)) {
806
+ continue;
1011
807
  }
1012
- var sortedFeatures = this.sort(metaFeatures, sortType, name);
1013
- onResponseCallback(sortedFeatures);
808
+ uniqueIds.add(id);
809
+ const objFeature = {
810
+ mapObjectId: String(feature.properties.myMapObjectId),
811
+ coordinates: null,
812
+ name: feature.properties.title,
813
+ whatDimension: feature.properties.dimension_what,
814
+ whereDimension: feature.properties.dimension_where,
815
+ geometry: feature.geometry,
816
+ properties: feature.properties
817
+ };
818
+ metaFeatures.push(objFeature);
1014
819
  }
1015
- }, {
1016
- key: "getMapObjectById",
1017
- value: function getMapObjectById(idToSearch, onResponseCallback) {
1018
- var metaFeatures = [];
1019
- var _iterator7 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1020
- _step7;
1021
- try {
1022
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1023
- var feature = _step7.value;
1024
- var id = String(feature.properties.myMapObjectId);
1025
- if (id === String(idToSearch)) {
1026
- var objFeature = {
1027
- mapObjectId: String(feature.properties.myMapObjectId),
1028
- coordinates: feature.coordinates,
1029
- name: feature.properties.title,
1030
- whatDimension: feature.properties.dimension_what,
1031
- whereDimension: feature.properties.dimension_where,
1032
- geometry: feature.geometry,
1033
- properties: feature.properties
1034
- };
1035
- metaFeatures.push(objFeature);
1036
- }
1037
- }
1038
- } catch (err) {
1039
- _iterator7.e(err);
1040
- } finally {
1041
- _iterator7.f();
820
+ const sortedFeatures = this.sort(metaFeatures, sortType, name);
821
+ onResponseCallback(sortedFeatures);
822
+ }
823
+ getMapObjectById(idToSearch, onResponseCallback) {
824
+ let metaFeatures = [];
825
+ for (const feature of this.searchableGeoJsonFeatures) {
826
+ const id = String(feature.properties.myMapObjectId);
827
+ if (id === String(idToSearch)) {
828
+ const objFeature = {
829
+ mapObjectId: String(feature.properties.myMapObjectId),
830
+ coordinates: feature.coordinates,
831
+ name: feature.properties.title,
832
+ whatDimension: feature.properties.dimension_what,
833
+ whereDimension: feature.properties.dimension_where,
834
+ geometry: feature.geometry,
835
+ properties: feature.properties
836
+ };
837
+ metaFeatures.push(objFeature);
1042
838
  }
1043
- onResponseCallback(metaFeatures);
1044
839
  }
1045
- }, {
1046
- key: "getMapObjectByLocalRef",
1047
- value: function getMapObjectByLocalRef(localRefToSearch, onResponseCallback) {
1048
- var metaFeatures = [];
1049
- var _iterator8 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1050
- _step8;
1051
- try {
1052
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1053
- var feature = _step8.value;
1054
- var localRef = String(feature.properties.localRef);
1055
- if (localRef === String(localRefToSearch)) {
1056
- var objFeature = {
1057
- mapObjectId: String(feature.properties.myMapObjectId),
1058
- coordinates: feature.coordinates,
1059
- name: feature.properties.title,
1060
- whatDimension: feature.properties.dimension_what,
1061
- whereDimension: feature.properties.dimension_where,
1062
- geometry: feature.geometry,
1063
- properties: feature.properties
1064
- };
1065
- metaFeatures.push(objFeature);
1066
- }
1067
- }
1068
- } catch (err) {
1069
- _iterator8.e(err);
1070
- } finally {
1071
- _iterator8.f();
840
+ onResponseCallback(metaFeatures);
841
+ }
842
+ getMapObjectByLocalRef(localRefToSearch, onResponseCallback) {
843
+ let metaFeatures = [];
844
+ for (const feature of this.searchableGeoJsonFeatures) {
845
+ const localRef = String(feature.properties.localRef);
846
+ if (localRef === String(localRefToSearch)) {
847
+ const objFeature = {
848
+ mapObjectId: String(feature.properties.myMapObjectId),
849
+ coordinates: feature.coordinates,
850
+ name: feature.properties.title,
851
+ whatDimension: feature.properties.dimension_what,
852
+ whereDimension: feature.properties.dimension_where,
853
+ geometry: feature.geometry,
854
+ properties: feature.properties
855
+ };
856
+ metaFeatures.push(objFeature);
1072
857
  }
1073
- onResponseCallback(metaFeatures);
1074
858
  }
1075
- }, {
1076
- key: "getMapObjectMatchingLocalRef",
1077
- value: function getMapObjectMatchingLocalRef(localRefToSearch, onResponseCallback) {
1078
- var metaFeatures = [];
1079
- var _iterator9 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1080
- _step9;
1081
- try {
1082
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1083
- var feature = _step9.value;
1084
- var localRef = String(feature.properties.localRef);
1085
- if (localRef.includes(String(localRefToSearch))) {
1086
- var objFeature = {
1087
- mapObjectId: String(feature.properties.myMapObjectId),
1088
- coordinates: feature.coordinates,
1089
- name: feature.properties.title,
1090
- whatDimension: feature.properties.dimension_what,
1091
- whereDimension: feature.properties.dimension_where,
1092
- geometry: feature.geometry,
1093
- properties: feature.properties
1094
- };
1095
- metaFeatures.push(objFeature);
1096
- }
1097
- }
1098
- } catch (err) {
1099
- _iterator9.e(err);
1100
- } finally {
1101
- _iterator9.f();
859
+ onResponseCallback(metaFeatures);
860
+ }
861
+ getMapObjectMatchingLocalRef(localRefToSearch, onResponseCallback) {
862
+ let metaFeatures = [];
863
+ for (const feature of this.searchableGeoJsonFeatures) {
864
+ const localRef = String(feature.properties.localRef);
865
+ if (localRef.includes(String(localRefToSearch))) {
866
+ const objFeature = {
867
+ mapObjectId: String(feature.properties.myMapObjectId),
868
+ coordinates: feature.coordinates,
869
+ name: feature.properties.title,
870
+ whatDimension: feature.properties.dimension_what,
871
+ whereDimension: feature.properties.dimension_where,
872
+ geometry: feature.geometry,
873
+ properties: feature.properties
874
+ };
875
+ metaFeatures.push(objFeature);
1102
876
  }
1103
- onResponseCallback(metaFeatures);
1104
877
  }
1105
- }, {
1106
- key: "getMapObjectsMatchingLocalRefs",
1107
- value: function getMapObjectsMatchingLocalRefs(localRefsToSearch, onResponseCallback) {
1108
- var metaFeatures = [];
1109
- var localRefsArray = Array.isArray(localRefsToSearch) ? localRefsToSearch : [localRefsToSearch];
1110
- var _iterator0 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1111
- _step0;
1112
- try {
1113
- var _loop2 = function _loop2() {
1114
- var feature = _step0.value;
1115
- var localRef = String(feature.properties.localRef);
1116
- if (localRefsArray.some(function (ref) {
1117
- return localRef.includes(String(ref));
1118
- })) {
1119
- var objFeature = {
1120
- mapObjectId: String(feature.properties.myMapObjectId),
1121
- coordinates: feature.coordinates,
1122
- name: feature.properties.title,
1123
- whatDimension: feature.properties.dimension_what,
1124
- whereDimension: feature.properties.dimension_where,
1125
- geometry: feature.geometry,
1126
- properties: feature.properties
1127
- };
1128
- metaFeatures.push(objFeature);
1129
- }
878
+ onResponseCallback(metaFeatures);
879
+ }
880
+ getMapObjectsMatchingLocalRefs(localRefsToSearch, onResponseCallback) {
881
+ let metaFeatures = [];
882
+ const localRefsArray = Array.isArray(localRefsToSearch) ? localRefsToSearch : [localRefsToSearch];
883
+ for (const feature of this.searchableGeoJsonFeatures) {
884
+ const localRef = String(feature.properties.localRef);
885
+ if (localRefsArray.some(ref => localRef.includes(String(ref)))) {
886
+ const objFeature = {
887
+ mapObjectId: String(feature.properties.myMapObjectId),
888
+ coordinates: feature.coordinates,
889
+ name: feature.properties.title,
890
+ whatDimension: feature.properties.dimension_what,
891
+ whereDimension: feature.properties.dimension_where,
892
+ geometry: feature.geometry,
893
+ properties: feature.properties
1130
894
  };
1131
- for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
1132
- _loop2();
1133
- }
1134
- } catch (err) {
1135
- _iterator0.e(err);
1136
- } finally {
1137
- _iterator0.f();
895
+ metaFeatures.push(objFeature);
1138
896
  }
1139
- onResponseCallback(metaFeatures);
1140
897
  }
1141
- }, {
1142
- key: "getMapObjectsByWhatTaxonomy",
1143
- value: function getMapObjectsByWhatTaxonomy(whatTaxonomyPath, onResponseCallback) {
1144
- var metaFeatures = [];
1145
- var _iterator1 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1146
- _step1;
1147
- try {
1148
- for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
1149
- var feature = _step1.value;
1150
- var whatTaxonomy = String(feature.properties.dimension_what);
1151
- if (!whatTaxonomyPath || whatTaxonomy === String(whatTaxonomyPath)) {
1152
- var objFeature = {
1153
- mapObjectId: String(feature.properties.myMapObjectId),
1154
- coordinates: feature.coordinates,
1155
- name: feature.properties.title,
1156
- whatDimension: feature.properties.dimension_what,
1157
- whereDimension: feature.properties.dimension_where,
1158
- geometry: feature.geometry,
1159
- properties: feature.properties
1160
- };
1161
- metaFeatures.push(objFeature);
1162
- }
1163
- }
1164
- } catch (err) {
1165
- _iterator1.e(err);
1166
- } finally {
1167
- _iterator1.f();
898
+ onResponseCallback(metaFeatures);
899
+ }
900
+ getMapObjectsByWhatTaxonomy(whatTaxonomyPath, onResponseCallback) {
901
+ let metaFeatures = [];
902
+ for (const feature of this.searchableGeoJsonFeatures) {
903
+ const whatTaxonomy = String(feature.properties.dimension_what);
904
+ if (!whatTaxonomyPath || whatTaxonomy === String(whatTaxonomyPath)) {
905
+ const objFeature = {
906
+ mapObjectId: String(feature.properties.myMapObjectId),
907
+ coordinates: feature.coordinates,
908
+ name: feature.properties.title,
909
+ whatDimension: feature.properties.dimension_what,
910
+ whereDimension: feature.properties.dimension_where,
911
+ geometry: feature.geometry,
912
+ properties: feature.properties
913
+ };
914
+ metaFeatures.push(objFeature);
1168
915
  }
1169
- onResponseCallback(metaFeatures);
1170
916
  }
1171
- }, {
1172
- key: "getMapObjectsByWhereTaxonomy",
1173
- value: function getMapObjectsByWhereTaxonomy(whereTaxonomyPath, onResponseCallback) {
1174
- var metaFeatures = [];
1175
- var _iterator10 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1176
- _step10;
1177
- try {
1178
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1179
- var feature = _step10.value;
1180
- var whereTaxonomy = String(feature.properties.dimension_where);
1181
- if (whereTaxonomy === String(whereTaxonomyPath)) {
1182
- var objFeature = {
1183
- mapObjectId: String(feature.properties.myMapObjectId),
1184
- coordinates: feature.coordinates,
1185
- name: feature.properties.title,
1186
- whatDimension: feature.properties.dimension_what,
1187
- whereDimension: feature.properties.dimension_where,
1188
- geometry: feature.geometry,
1189
- properties: feature.properties
1190
- };
1191
- metaFeatures.push(objFeature);
1192
- }
1193
- }
1194
- } catch (err) {
1195
- _iterator10.e(err);
1196
- } finally {
1197
- _iterator10.f();
917
+ onResponseCallback(metaFeatures);
918
+ }
919
+ getMapObjectsByWhereTaxonomy(whereTaxonomyPath, onResponseCallback) {
920
+ let metaFeatures = [];
921
+ for (const feature of this.searchableGeoJsonFeatures) {
922
+ const whereTaxonomy = String(feature.properties.dimension_where);
923
+ if (whereTaxonomy === String(whereTaxonomyPath)) {
924
+ const objFeature = {
925
+ mapObjectId: String(feature.properties.myMapObjectId),
926
+ coordinates: feature.coordinates,
927
+ name: feature.properties.title,
928
+ whatDimension: feature.properties.dimension_what,
929
+ whereDimension: feature.properties.dimension_where,
930
+ geometry: feature.geometry,
931
+ properties: feature.properties
932
+ };
933
+ metaFeatures.push(objFeature);
1198
934
  }
1199
- onResponseCallback(metaFeatures);
1200
935
  }
1201
- }, {
1202
- key: "getMapObjectsByWhatAndWhereTaxonomy",
1203
- value: function getMapObjectsByWhatAndWhereTaxonomy(whatTaxonomyPath, whereTaxonomyPath, onResponseCallback) {
1204
- var metaFeatures = [];
1205
- var _iterator11 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1206
- _step11;
1207
- try {
1208
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1209
- var feature = _step11.value;
1210
- var whereTaxonomy = String(feature.properties.dimension_where);
1211
- var whatTaxonomy = String(feature.properties.dimension_what);
1212
- if (whereTaxonomy === String(whereTaxonomyPath) && whatTaxonomy === String(whatTaxonomyPath)) {
1213
- var objFeature = {
1214
- mapObjectId: String(feature.properties.myMapObjectId),
1215
- coordinates: feature.coordinates,
1216
- name: feature.properties.title,
1217
- whatDimension: feature.properties.dimension_what,
1218
- whereDimension: feature.properties.dimension_where,
1219
- geometry: feature.geometry,
1220
- properties: feature.properties
1221
- };
1222
- metaFeatures.push(objFeature);
1223
- }
1224
- }
1225
- } catch (err) {
1226
- _iterator11.e(err);
1227
- } finally {
1228
- _iterator11.f();
936
+ onResponseCallback(metaFeatures);
937
+ }
938
+ getMapObjectsByWhatAndWhereTaxonomy(whatTaxonomyPath, whereTaxonomyPath, onResponseCallback) {
939
+ let metaFeatures = [];
940
+ for (const feature of this.searchableGeoJsonFeatures) {
941
+ const whereTaxonomy = String(feature.properties.dimension_where);
942
+ const whatTaxonomy = String(feature.properties.dimension_what);
943
+ if (whereTaxonomy === String(whereTaxonomyPath) && whatTaxonomy === String(whatTaxonomyPath)) {
944
+ const objFeature = {
945
+ mapObjectId: String(feature.properties.myMapObjectId),
946
+ coordinates: feature.coordinates,
947
+ name: feature.properties.title,
948
+ whatDimension: feature.properties.dimension_what,
949
+ whereDimension: feature.properties.dimension_where,
950
+ geometry: feature.geometry,
951
+ properties: feature.properties
952
+ };
953
+ metaFeatures.push(objFeature);
1229
954
  }
1230
- onResponseCallback(metaFeatures);
1231
955
  }
1232
- }, {
1233
- key: "getMapObjectsInWhatTaxonomy",
1234
- value: function getMapObjectsInWhatTaxonomy(whatTaxonomyPaths, onResponseCallback) {
1235
- var metaFeatures = [];
1236
- var _iterator12 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1237
- _step12;
1238
- try {
1239
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
1240
- var feature = _step12.value;
1241
- var whatTaxonomy = String(feature.properties.dimension_what);
1242
- if (whatTaxonomyPaths.includes(whatTaxonomy)) {
1243
- var objFeature = {
1244
- mapObjectId: String(feature.properties.myMapObjectId),
1245
- coordinates: feature.coordinates,
1246
- name: feature.properties.title,
1247
- whatDimension: feature.properties.dimension_what,
1248
- whereDimension: feature.properties.dimension_where,
1249
- geometry: feature.geometry,
1250
- properties: feature.properties
1251
- };
1252
- metaFeatures.push(objFeature);
1253
- }
1254
- }
1255
- } catch (err) {
1256
- _iterator12.e(err);
1257
- } finally {
1258
- _iterator12.f();
956
+ onResponseCallback(metaFeatures);
957
+ }
958
+ getMapObjectsInWhatTaxonomy(whatTaxonomyPaths, onResponseCallback) {
959
+ let metaFeatures = [];
960
+ for (const feature of this.searchableGeoJsonFeatures) {
961
+ const whatTaxonomy = String(feature.properties.dimension_what);
962
+ if (whatTaxonomyPaths.includes(whatTaxonomy)) {
963
+ const objFeature = {
964
+ mapObjectId: String(feature.properties.myMapObjectId),
965
+ coordinates: feature.coordinates,
966
+ name: feature.properties.title,
967
+ whatDimension: feature.properties.dimension_what,
968
+ whereDimension: feature.properties.dimension_where,
969
+ geometry: feature.geometry,
970
+ properties: feature.properties
971
+ };
972
+ metaFeatures.push(objFeature);
1259
973
  }
1260
- onResponseCallback(metaFeatures);
1261
974
  }
1262
- }, {
1263
- key: "getMapObjectsInWhereTaxonomy",
1264
- value: function getMapObjectsInWhereTaxonomy(whereTaxonomyPaths, onResponseCallback) {
1265
- var metaFeatures = [];
1266
- var _iterator13 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1267
- _step13;
1268
- try {
1269
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
1270
- var feature = _step13.value;
1271
- var whereTaxonomy = String(feature.properties.dimension_where);
1272
- if (whereTaxonomyPaths.includes(whereTaxonomy)) {
1273
- var objFeature = {
1274
- mapObjectId: String(feature.properties.myMapObjectId),
1275
- coordinates: feature.coordinates,
1276
- name: feature.properties.title,
1277
- whatDimension: feature.properties.dimension_what,
1278
- whereDimension: feature.properties.dimension_where,
1279
- geometry: feature.geometry,
1280
- properties: feature.properties
1281
- };
1282
- metaFeatures.push(objFeature);
1283
- }
1284
- }
1285
- } catch (err) {
1286
- _iterator13.e(err);
1287
- } finally {
1288
- _iterator13.f();
975
+ onResponseCallback(metaFeatures);
976
+ }
977
+ getMapObjectsInWhereTaxonomy(whereTaxonomyPaths, onResponseCallback) {
978
+ let metaFeatures = [];
979
+ for (const feature of this.searchableGeoJsonFeatures) {
980
+ const whereTaxonomy = String(feature.properties.dimension_where);
981
+ if (whereTaxonomyPaths.includes(whereTaxonomy)) {
982
+ const objFeature = {
983
+ mapObjectId: String(feature.properties.myMapObjectId),
984
+ coordinates: feature.coordinates,
985
+ name: feature.properties.title,
986
+ whatDimension: feature.properties.dimension_what,
987
+ whereDimension: feature.properties.dimension_where,
988
+ geometry: feature.geometry,
989
+ properties: feature.properties
990
+ };
991
+ metaFeatures.push(objFeature);
1289
992
  }
1290
- onResponseCallback(metaFeatures);
1291
993
  }
1292
- }, {
1293
- key: "getMapObjectsInWhatAndWhereTaxonomy",
1294
- value: function getMapObjectsInWhatAndWhereTaxonomy(whatTaxonomyPaths, whereTaxonomyPaths, onResponseCallback) {
1295
- var metaFeatures = [];
1296
- var _iterator14 = _createForOfIteratorHelper(this.searchableGeoJsonFeatures),
1297
- _step14;
1298
- try {
1299
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
1300
- var feature = _step14.value;
1301
- var whereTaxonomy = String(feature.properties.dimension_where);
1302
- var whatTaxonomy = String(feature.properties.dimension_what);
1303
- if (whereTaxonomyPaths.includes(whereTaxonomy) && whatTaxonomyPaths.includes(whatTaxonomy)) {
1304
- var objFeature = {
1305
- mapObjectId: String(feature.properties.myMapObjectId),
1306
- coordinates: feature.coordinates,
1307
- name: feature.properties.title,
1308
- whatDimension: feature.properties.dimension_what,
1309
- whereDimension: feature.properties.dimension_where,
1310
- geometry: feature.geometry,
1311
- properties: feature.properties
1312
- };
1313
- metaFeatures.push(objFeature);
1314
- }
1315
- }
1316
- } catch (err) {
1317
- _iterator14.e(err);
1318
- } finally {
1319
- _iterator14.f();
994
+ onResponseCallback(metaFeatures);
995
+ }
996
+ getMapObjectsInWhatAndWhereTaxonomy(whatTaxonomyPaths, whereTaxonomyPaths, onResponseCallback) {
997
+ let metaFeatures = [];
998
+ for (const feature of this.searchableGeoJsonFeatures) {
999
+ const whereTaxonomy = String(feature.properties.dimension_where);
1000
+ const whatTaxonomy = String(feature.properties.dimension_what);
1001
+ if (whereTaxonomyPaths.includes(whereTaxonomy) && whatTaxonomyPaths.includes(whatTaxonomy)) {
1002
+ const objFeature = {
1003
+ mapObjectId: String(feature.properties.myMapObjectId),
1004
+ coordinates: feature.coordinates,
1005
+ name: feature.properties.title,
1006
+ whatDimension: feature.properties.dimension_what,
1007
+ whereDimension: feature.properties.dimension_where,
1008
+ geometry: feature.geometry,
1009
+ properties: feature.properties
1010
+ };
1011
+ metaFeatures.push(objFeature);
1320
1012
  }
1321
- onResponseCallback(metaFeatures);
1322
1013
  }
1323
- }, {
1324
- key: "getMapObjectsApi",
1325
- value: function getMapObjectsApi() {
1326
- var _this3 = this;
1327
- var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1328
- return new Promise(function (resolve, reject) {
1329
- (0, _axios["default"])({
1330
- url: "".concat(_this3.empApi, "/map-objects").concat(query),
1331
- headers: {
1332
- Authorization: "Bearer ".concat(_this3.atomsAPIAccessToken)
1333
- },
1334
- method: 'get'
1335
- }).then(function (response) {
1336
- var data = response.data.data;
1337
- var uniqueFeatures = data;
1338
- resolve(uniqueFeatures);
1339
- })["catch"](function (error) {
1340
- reject(error);
1341
- });
1014
+ onResponseCallback(metaFeatures);
1015
+ }
1016
+ getMapObjectsApi() {
1017
+ let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1018
+ return new Promise((resolve, reject) => {
1019
+ (0, _axios.default)({
1020
+ url: `${this.empApi}/map-objects${query}`,
1021
+ headers: {
1022
+ Authorization: `Bearer ${this.atomsAPIAccessToken}`
1023
+ },
1024
+ method: 'get'
1025
+ }).then(response => {
1026
+ const data = response.data.data;
1027
+ let uniqueFeatures = data;
1028
+ resolve(uniqueFeatures);
1029
+ }).catch(function (error) {
1030
+ reject(error);
1342
1031
  });
1343
- }
1344
- }, {
1345
- key: "getMapObjectsByWhatTaxonomyAPI",
1346
- value: function getMapObjectsByWhatTaxonomyAPI(whatTaxonomyPath, onResponseCallback) {
1347
- var query = "?$limit=".concat(this.apiRequestLimit);
1348
- if (whatTaxonomyPath) query += "&taxonomy2Path=".concat(whatTaxonomyPath);
1349
- this.getMapObjectsApi(query).then(onResponseCallback)["catch"](onResponseCallback);
1350
- }
1351
- }]);
1352
- }();
1032
+ });
1033
+ }
1034
+ getMapObjectsByWhatTaxonomyAPI(whatTaxonomyPath, onResponseCallback) {
1035
+ let query = `?$limit=${this.apiRequestLimit}`;
1036
+ if (whatTaxonomyPath) query += `&taxonomy2Path=${whatTaxonomyPath}`;
1037
+ this.getMapObjectsApi(query).then(onResponseCallback).catch(onResponseCallback);
1038
+ }
1039
+ }
1040
+ exports.MetaAtlasCore = MetaAtlasCore;
1353
1041
  //# sourceMappingURL=meta-atlas-sdk-core.js.map