bruce-models 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/bruce-models.es5.js +167 -8
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +165 -7
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account.js +244 -244
  6. package/dist/lib/ann-document/ann-document.js +116 -116
  7. package/dist/lib/api/abstract-api.js +269 -269
  8. package/dist/lib/api/api.js +85 -85
  9. package/dist/lib/api/bruce-api.js +243 -228
  10. package/dist/lib/api/bruce-api.js.map +1 -1
  11. package/dist/lib/api/cam-api.js +132 -132
  12. package/dist/lib/api/global-api.js +131 -131
  13. package/dist/lib/api/idm-api.js +132 -132
  14. package/dist/lib/bruce-models.js +85 -84
  15. package/dist/lib/bruce-models.js.map +1 -1
  16. package/dist/lib/calculator/calculator.js +159 -158
  17. package/dist/lib/calculator/calculator.js.map +1 -1
  18. package/dist/lib/client-file/client-file.js +188 -188
  19. package/dist/lib/common/bounds.js +2 -2
  20. package/dist/lib/common/bruce-event.js +48 -48
  21. package/dist/lib/common/bruce-variable.js +54 -54
  22. package/dist/lib/common/cache.js +86 -86
  23. package/dist/lib/common/camera.js +11 -11
  24. package/dist/lib/common/cartes.js +55 -55
  25. package/dist/lib/common/carto.js +60 -60
  26. package/dist/lib/common/color.js +86 -86
  27. package/dist/lib/common/delay-queue.js +60 -60
  28. package/dist/lib/common/dictionary.js +2 -2
  29. package/dist/lib/common/geometry.js +120 -120
  30. package/dist/lib/common/transform.js +2 -2
  31. package/dist/lib/common/utc.js +39 -39
  32. package/dist/lib/custom-form/custom-form.js +136 -136
  33. package/dist/lib/data-lab/data-lab.js +90 -90
  34. package/dist/lib/entity/entity-attachment-type.js +132 -132
  35. package/dist/lib/entity/entity-attachment.js +208 -208
  36. package/dist/lib/entity/entity-comment.js +132 -132
  37. package/dist/lib/entity/entity-coords.js +181 -181
  38. package/dist/lib/entity/entity-link.js +132 -132
  39. package/dist/lib/entity/entity-lod.js +189 -189
  40. package/dist/lib/entity/entity-relation-type.js +150 -150
  41. package/dist/lib/entity/entity-relation.js +189 -189
  42. package/dist/lib/entity/entity-source.js +176 -176
  43. package/dist/lib/entity/entity-tag.js +229 -229
  44. package/dist/lib/entity/entity-type.js +163 -163
  45. package/dist/lib/entity/entity.js +358 -358
  46. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  47. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  48. package/dist/lib/entity/getters/entity-globe.js +135 -135
  49. package/dist/lib/entity/getters/view-monitor.js +2 -2
  50. package/dist/lib/import/import-cad.js +82 -82
  51. package/dist/lib/import/import-csv.js +51 -51
  52. package/dist/lib/import/import-json.js +51 -51
  53. package/dist/lib/import/import-kml.js +51 -51
  54. package/dist/lib/import/imported-file.js +121 -121
  55. package/dist/lib/import/imported-file.js.map +1 -1
  56. package/dist/lib/markup/markup.js +40 -40
  57. package/dist/lib/program-key/program-key.js +152 -152
  58. package/dist/lib/project/menu-item.js +115 -115
  59. package/dist/lib/project/project-view-bookmark.js +183 -183
  60. package/dist/lib/project/project-view-legacy-tile.js +115 -115
  61. package/dist/lib/project/project-view-tile.js +119 -119
  62. package/dist/lib/project/project-view-tile.js.map +1 -1
  63. package/dist/lib/project/project-view.js +177 -177
  64. package/dist/lib/project/zoom-control.js +17 -17
  65. package/dist/lib/server/message-broker.js +159 -0
  66. package/dist/lib/server/message-broker.js.map +1 -0
  67. package/dist/lib/server/pending-action.js +106 -106
  68. package/dist/lib/server/task.js +113 -113
  69. package/dist/lib/style/style.js +152 -152
  70. package/dist/lib/tileset/tileset-cad.js +2 -2
  71. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  72. package/dist/lib/tileset/tileset-entities.js +2 -2
  73. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  74. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  75. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  76. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  77. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  78. package/dist/lib/tileset/tileset.js +403 -403
  79. package/dist/lib/user/permission.js +20 -20
  80. package/dist/lib/user/session.js +160 -160
  81. package/dist/lib/user/user-group.js +139 -139
  82. package/dist/lib/user/user.js +451 -451
  83. package/dist/lib/util/encrypt-utils.js +20 -20
  84. package/dist/lib/util/math-utils.js +41 -41
  85. package/dist/lib/util/object-utils.js +17 -17
  86. package/dist/lib/util/path-utils.js +61 -61
  87. package/dist/lib/util/url-utils.js +107 -107
  88. package/dist/types/api/bruce-api.d.ts +9 -1
  89. package/dist/types/bruce-models.d.ts +1 -0
  90. package/dist/types/project/project-view-tile.d.ts +2 -6
  91. package/dist/types/server/message-broker.d.ts +108 -0
  92. package/package.json +1 -1
@@ -1,133 +1,133 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.EntityComment = void 0;
40
- var api_1 = require("../api/api");
41
- /**
42
- * Describes the "Entity Comment" concept within Bruce.
43
- * An entity comment is a user written message that is linked to an entity record.
44
- */
45
- var EntityComment;
46
- (function (EntityComment) {
47
- function GetCacheKey(id) {
48
- return api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Id + id;
49
- }
50
- EntityComment.GetCacheKey = GetCacheKey;
51
- function GetListCacheKey(entityId) {
52
- return api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity + api_1.Api.ECacheKey.Id + entityId;
53
- }
54
- EntityComment.GetListCacheKey = GetListCacheKey;
55
- function Update(api, data) {
56
- return __awaiter(this, void 0, void 0, function () {
57
- var url;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- if (!(data === null || data === void 0 ? void 0 : data["TargetObject.ID"])) {
62
- throw ("TargetObject.ID (entity id) is required.");
63
- }
64
- url = "entity/" + data["TargetObject.ID"] + "/comment" + (data.ID == null ? "" : "/" + data.ID);
65
- return [4 /*yield*/, api.POST(url, data, api_1.Api.PrepReqParams())];
66
- case 1:
67
- data = _a.sent();
68
- api.Cache.Remove(GetCacheKey(data.ID));
69
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity);
70
- return [2 /*return*/, data];
71
- }
72
- });
73
- });
74
- }
75
- EntityComment.Update = Update;
76
- function Delete(api, entityId, commentId) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- return __generator(this, function (_a) {
79
- switch (_a.label) {
80
- case 0:
81
- if (!commentId) {
82
- throw ("Comment ID is required.");
83
- }
84
- return [4 /*yield*/, api.DELETE("entity/" + entityId + "/comment/" + commentId, api_1.Api.PrepReqParams())];
85
- case 1:
86
- _a.sent();
87
- api.Cache.Remove(GetCacheKey(commentId));
88
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity);
89
- return [2 /*return*/];
90
- }
91
- });
92
- });
93
- }
94
- EntityComment.Delete = Delete;
95
- function GetListByEntityId(api, entityId) {
96
- return __awaiter(this, void 0, void 0, function () {
97
- var cacheData, req;
98
- var _this = this;
99
- return __generator(this, function (_a) {
100
- if (!entityId) {
101
- throw ("Entity ID is required.");
102
- }
103
- cacheData = api.Cache.Get(GetListCacheKey(entityId));
104
- if (cacheData) {
105
- return [2 /*return*/, cacheData];
106
- }
107
- req = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
108
- var data, e_1;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- _a.trys.push([0, 2, , 3]);
113
- return [4 /*yield*/, api.GET("entity/" + entityId + "/comments", api_1.Api.PrepReqParams())];
114
- case 1:
115
- data = _a.sent();
116
- res(data.Items);
117
- return [3 /*break*/, 3];
118
- case 2:
119
- e_1 = _a.sent();
120
- rej(e_1);
121
- return [3 /*break*/, 3];
122
- case 3: return [2 /*return*/];
123
- }
124
- });
125
- }); });
126
- api.Cache.Set(GetListCacheKey(entityId), req);
127
- return [2 /*return*/, req];
128
- });
129
- });
130
- }
131
- EntityComment.GetListByEntityId = GetListByEntityId;
132
- })(EntityComment = exports.EntityComment || (exports.EntityComment = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.EntityComment = void 0;
40
+ var api_1 = require("../api/api");
41
+ /**
42
+ * Describes the "Entity Comment" concept within Bruce.
43
+ * An entity comment is a user written message that is linked to an entity record.
44
+ */
45
+ var EntityComment;
46
+ (function (EntityComment) {
47
+ function GetCacheKey(id) {
48
+ return api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Id + id;
49
+ }
50
+ EntityComment.GetCacheKey = GetCacheKey;
51
+ function GetListCacheKey(entityId) {
52
+ return api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity + api_1.Api.ECacheKey.Id + entityId;
53
+ }
54
+ EntityComment.GetListCacheKey = GetListCacheKey;
55
+ function Update(api, data) {
56
+ return __awaiter(this, void 0, void 0, function () {
57
+ var url;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0:
61
+ if (!(data === null || data === void 0 ? void 0 : data["TargetObject.ID"])) {
62
+ throw ("TargetObject.ID (entity id) is required.");
63
+ }
64
+ url = "entity/" + data["TargetObject.ID"] + "/comment" + (data.ID == null ? "" : "/" + data.ID);
65
+ return [4 /*yield*/, api.POST(url, data, api_1.Api.PrepReqParams())];
66
+ case 1:
67
+ data = _a.sent();
68
+ api.Cache.Remove(GetCacheKey(data.ID));
69
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity);
70
+ return [2 /*return*/, data];
71
+ }
72
+ });
73
+ });
74
+ }
75
+ EntityComment.Update = Update;
76
+ function Delete(api, entityId, commentId) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ if (!commentId) {
82
+ throw ("Comment ID is required.");
83
+ }
84
+ return [4 /*yield*/, api.DELETE("entity/" + entityId + "/comment/" + commentId, api_1.Api.PrepReqParams())];
85
+ case 1:
86
+ _a.sent();
87
+ api.Cache.Remove(GetCacheKey(commentId));
88
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Comment + api_1.Api.ECacheKey.Entity);
89
+ return [2 /*return*/];
90
+ }
91
+ });
92
+ });
93
+ }
94
+ EntityComment.Delete = Delete;
95
+ function GetListByEntityId(api, entityId) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ var cacheData, req;
98
+ var _this = this;
99
+ return __generator(this, function (_a) {
100
+ if (!entityId) {
101
+ throw ("Entity ID is required.");
102
+ }
103
+ cacheData = api.Cache.Get(GetListCacheKey(entityId));
104
+ if (cacheData) {
105
+ return [2 /*return*/, cacheData];
106
+ }
107
+ req = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
108
+ var data, e_1;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ _a.trys.push([0, 2, , 3]);
113
+ return [4 /*yield*/, api.GET("entity/" + entityId + "/comments", api_1.Api.PrepReqParams())];
114
+ case 1:
115
+ data = _a.sent();
116
+ res(data.Items);
117
+ return [3 /*break*/, 3];
118
+ case 2:
119
+ e_1 = _a.sent();
120
+ rej(e_1);
121
+ return [3 /*break*/, 3];
122
+ case 3: return [2 /*return*/];
123
+ }
124
+ });
125
+ }); });
126
+ api.Cache.Set(GetListCacheKey(entityId), req);
127
+ return [2 /*return*/, req];
128
+ });
129
+ });
130
+ }
131
+ EntityComment.GetListByEntityId = GetListByEntityId;
132
+ })(EntityComment = exports.EntityComment || (exports.EntityComment = {}));
133
133
  //# sourceMappingURL=entity-comment.js.map
@@ -1,182 +1,182 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.EntityCoords = void 0;
40
- var api_1 = require("../api/api");
41
- var math_utils_1 = require("../util/math-utils");
42
- var EntityCoords;
43
- (function (EntityCoords) {
44
- EntityCoords.UCS_ENTITY_TYPE_ID = "Bruce_UCS_Type";
45
- function GetCacheKey(entityId) {
46
- return api_1.Api.ECacheKey.EntityCoords + api_1.Api.ECacheKey.Entity + api_1.Api.ECacheKey.Id + entityId;
47
- }
48
- EntityCoords.GetCacheKey = GetCacheKey;
49
- function GetEntityCoords(api, entityId) {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var cacheData, req;
52
- return __generator(this, function (_a) {
53
- cacheData = api.Cache.Get(GetCacheKey(entityId));
54
- if (cacheData) {
55
- return [2 /*return*/, cacheData];
56
- }
57
- req = api.GET("entity/" + entityId + "/ucs");
58
- api.Cache.Set(GetCacheKey(entityId), req, api_1.Api.DEFAULT_CACHE_DURATION);
59
- return [2 /*return*/, req];
60
- });
61
- });
62
- }
63
- EntityCoords.GetEntityCoords = GetEntityCoords;
64
- function EntityRelativeToPoint(api, entityId, params) {
65
- return __awaiter(this, void 0, void 0, function () {
66
- var point, name, res;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0:
70
- if (!!params.test) return [3 /*break*/, 2];
71
- return [4 /*yield*/, UnlinkCoords(api, entityId)];
72
- case 1:
73
- _a.sent();
74
- _a.label = 2;
75
- case 2:
76
- point = params.point;
77
- name = params.name || math_utils_1.MathUtils.Round(point.latitude, 4) + ", " + math_utils_1.MathUtils.Round(point.longitude, 4);
78
- return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
79
- "ucs": {
80
- "Entity.ID": null,
81
- "name": name,
82
- "location": {
83
- "latitude": point.latitude,
84
- "longitude": point.longitude,
85
- "altitude": point.altitude,
86
- "coordinates": {
87
- "Entity.ID": entityId
88
- }
89
- }
90
- },
91
- "test": params.test
92
- })];
93
- case 3:
94
- res = _a.sent();
95
- if (!params.test) {
96
- api.Cache.Remove(GetCacheKey(entityId));
97
- }
98
- return [2 /*return*/, res];
99
- }
100
- });
101
- });
102
- }
103
- EntityCoords.EntityRelativeToPoint = EntityRelativeToPoint;
104
- function EntityRelativeToEpsg(api, entityId, params) {
105
- var _a;
106
- return __awaiter(this, void 0, void 0, function () {
107
- var epsg, name, res;
108
- return __generator(this, function (_b) {
109
- switch (_b.label) {
110
- case 0:
111
- if (!!params.test) return [3 /*break*/, 2];
112
- return [4 /*yield*/, UnlinkCoords(api, entityId)];
113
- case 1:
114
- _b.sent();
115
- _b.label = 2;
116
- case 2:
117
- epsg = params.epsg;
118
- name = (_a = params.name) !== null && _a !== void 0 ? _a : "EPSG: " + epsg;
119
- return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
120
- "ucs": {
121
- "Entity.ID": null,
122
- "name": name,
123
- "location": {
124
- "coordinates": {
125
- "SRID": "EPSG:" + epsg,
126
- "Entity.ID": entityId
127
- }
128
- }
129
- },
130
- "test": params.test
131
- })];
132
- case 3:
133
- res = _b.sent();
134
- if (!params.test) {
135
- api.Cache.Remove(GetCacheKey(entityId));
136
- }
137
- return [2 /*return*/, res];
138
- }
139
- });
140
- });
141
- }
142
- EntityCoords.EntityRelativeToEpsg = EntityRelativeToEpsg;
143
- function EntityRelativeToUcs(api, entityId, params) {
144
- return __awaiter(this, void 0, void 0, function () {
145
- var ucsId, res;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- if (!!params.test) return [3 /*break*/, 2];
150
- return [4 /*yield*/, UnlinkCoords(api, entityId)];
151
- case 1:
152
- _a.sent();
153
- _a.label = 2;
154
- case 2:
155
- ucsId = params.ucsId;
156
- return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
157
- "ucs": {
158
- "Entity.ID": ucsId
159
- },
160
- "test": params.test
161
- })];
162
- case 3:
163
- res = _a.sent();
164
- if (!params.test) {
165
- api.Cache.Remove(GetCacheKey(entityId));
166
- }
167
- return [2 /*return*/, res];
168
- }
169
- });
170
- });
171
- }
172
- EntityCoords.EntityRelativeToUcs = EntityRelativeToUcs;
173
- function UnlinkCoords(api, entityId) {
174
- return __awaiter(this, void 0, void 0, function () {
175
- return __generator(this, function (_a) {
176
- return [2 /*return*/, api.DELETE("entity/" + entityId + "/ucs")];
177
- });
178
- });
179
- }
180
- EntityCoords.UnlinkCoords = UnlinkCoords;
181
- })(EntityCoords = exports.EntityCoords || (exports.EntityCoords = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.EntityCoords = void 0;
40
+ var api_1 = require("../api/api");
41
+ var math_utils_1 = require("../util/math-utils");
42
+ var EntityCoords;
43
+ (function (EntityCoords) {
44
+ EntityCoords.UCS_ENTITY_TYPE_ID = "Bruce_UCS_Type";
45
+ function GetCacheKey(entityId) {
46
+ return api_1.Api.ECacheKey.EntityCoords + api_1.Api.ECacheKey.Entity + api_1.Api.ECacheKey.Id + entityId;
47
+ }
48
+ EntityCoords.GetCacheKey = GetCacheKey;
49
+ function GetEntityCoords(api, entityId) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var cacheData, req;
52
+ return __generator(this, function (_a) {
53
+ cacheData = api.Cache.Get(GetCacheKey(entityId));
54
+ if (cacheData) {
55
+ return [2 /*return*/, cacheData];
56
+ }
57
+ req = api.GET("entity/" + entityId + "/ucs");
58
+ api.Cache.Set(GetCacheKey(entityId), req, api_1.Api.DEFAULT_CACHE_DURATION);
59
+ return [2 /*return*/, req];
60
+ });
61
+ });
62
+ }
63
+ EntityCoords.GetEntityCoords = GetEntityCoords;
64
+ function EntityRelativeToPoint(api, entityId, params) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var point, name, res;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ if (!!params.test) return [3 /*break*/, 2];
71
+ return [4 /*yield*/, UnlinkCoords(api, entityId)];
72
+ case 1:
73
+ _a.sent();
74
+ _a.label = 2;
75
+ case 2:
76
+ point = params.point;
77
+ name = params.name || math_utils_1.MathUtils.Round(point.latitude, 4) + ", " + math_utils_1.MathUtils.Round(point.longitude, 4);
78
+ return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
79
+ "ucs": {
80
+ "Entity.ID": null,
81
+ "name": name,
82
+ "location": {
83
+ "latitude": point.latitude,
84
+ "longitude": point.longitude,
85
+ "altitude": point.altitude,
86
+ "coordinates": {
87
+ "Entity.ID": entityId
88
+ }
89
+ }
90
+ },
91
+ "test": params.test
92
+ })];
93
+ case 3:
94
+ res = _a.sent();
95
+ if (!params.test) {
96
+ api.Cache.Remove(GetCacheKey(entityId));
97
+ }
98
+ return [2 /*return*/, res];
99
+ }
100
+ });
101
+ });
102
+ }
103
+ EntityCoords.EntityRelativeToPoint = EntityRelativeToPoint;
104
+ function EntityRelativeToEpsg(api, entityId, params) {
105
+ var _a;
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var epsg, name, res;
108
+ return __generator(this, function (_b) {
109
+ switch (_b.label) {
110
+ case 0:
111
+ if (!!params.test) return [3 /*break*/, 2];
112
+ return [4 /*yield*/, UnlinkCoords(api, entityId)];
113
+ case 1:
114
+ _b.sent();
115
+ _b.label = 2;
116
+ case 2:
117
+ epsg = params.epsg;
118
+ name = (_a = params.name) !== null && _a !== void 0 ? _a : "EPSG: " + epsg;
119
+ return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
120
+ "ucs": {
121
+ "Entity.ID": null,
122
+ "name": name,
123
+ "location": {
124
+ "coordinates": {
125
+ "SRID": "EPSG:" + epsg,
126
+ "Entity.ID": entityId
127
+ }
128
+ }
129
+ },
130
+ "test": params.test
131
+ })];
132
+ case 3:
133
+ res = _b.sent();
134
+ if (!params.test) {
135
+ api.Cache.Remove(GetCacheKey(entityId));
136
+ }
137
+ return [2 /*return*/, res];
138
+ }
139
+ });
140
+ });
141
+ }
142
+ EntityCoords.EntityRelativeToEpsg = EntityRelativeToEpsg;
143
+ function EntityRelativeToUcs(api, entityId, params) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var ucsId, res;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0:
149
+ if (!!params.test) return [3 /*break*/, 2];
150
+ return [4 /*yield*/, UnlinkCoords(api, entityId)];
151
+ case 1:
152
+ _a.sent();
153
+ _a.label = 2;
154
+ case 2:
155
+ ucsId = params.ucsId;
156
+ return [4 /*yield*/, api.POST("entity/" + entityId + "/ucs", {
157
+ "ucs": {
158
+ "Entity.ID": ucsId
159
+ },
160
+ "test": params.test
161
+ })];
162
+ case 3:
163
+ res = _a.sent();
164
+ if (!params.test) {
165
+ api.Cache.Remove(GetCacheKey(entityId));
166
+ }
167
+ return [2 /*return*/, res];
168
+ }
169
+ });
170
+ });
171
+ }
172
+ EntityCoords.EntityRelativeToUcs = EntityRelativeToUcs;
173
+ function UnlinkCoords(api, entityId) {
174
+ return __awaiter(this, void 0, void 0, function () {
175
+ return __generator(this, function (_a) {
176
+ return [2 /*return*/, api.DELETE("entity/" + entityId + "/ucs")];
177
+ });
178
+ });
179
+ }
180
+ EntityCoords.UnlinkCoords = UnlinkCoords;
181
+ })(EntityCoords = exports.EntityCoords || (exports.EntityCoords = {}));
182
182
  //# sourceMappingURL=entity-coords.js.map