bruce-models 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account.js +244 -244
- package/dist/lib/ann-document/ann-document.js +116 -116
- package/dist/lib/api/abstract-api.js +267 -267
- package/dist/lib/api/api.js +85 -85
- package/dist/lib/api/bruce-api.js +202 -202
- package/dist/lib/api/cam-api.js +132 -132
- package/dist/lib/api/global-api.js +131 -131
- package/dist/lib/api/idm-api.js +132 -132
- package/dist/lib/bruce-models.js +83 -83
- package/dist/lib/calculator/calculator.js +158 -158
- package/dist/lib/client-file/client-file.js +188 -188
- package/dist/lib/common/bounds.js +2 -2
- package/dist/lib/common/bruce-event.js +48 -48
- package/dist/lib/common/bruce-variable.js +54 -54
- package/dist/lib/common/cache.js +86 -86
- package/dist/lib/common/camera.js +11 -11
- package/dist/lib/common/cartes.js +55 -55
- package/dist/lib/common/carto.js +60 -60
- package/dist/lib/common/color.js +86 -86
- package/dist/lib/common/delay-queue.js +60 -60
- package/dist/lib/common/dictionary.js +2 -2
- package/dist/lib/common/geometry.js +120 -120
- package/dist/lib/common/transform.js +2 -2
- package/dist/lib/common/utc.js +39 -39
- package/dist/lib/custom-form/custom-form.js +136 -136
- package/dist/lib/data-lab/data-lab.js +90 -90
- package/dist/lib/entity/entity-attachment-type.js +132 -132
- package/dist/lib/entity/entity-attachment.js +208 -208
- package/dist/lib/entity/entity-comment.js +132 -132
- package/dist/lib/entity/entity-link.js +132 -132
- package/dist/lib/entity/entity-lod.js +189 -189
- package/dist/lib/entity/entity-relation-type.js +150 -150
- package/dist/lib/entity/entity-relation.js +189 -189
- package/dist/lib/entity/entity-source.js +176 -176
- package/dist/lib/entity/entity-tag.js +229 -229
- package/dist/lib/entity/entity-type.js +163 -163
- package/dist/lib/entity/entity-type.js.map +1 -1
- package/dist/lib/entity/entity.js +349 -349
- package/dist/lib/entity/getters/batched-data-getter.js +91 -91
- package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
- package/dist/lib/entity/getters/entity-globe.js +135 -135
- package/dist/lib/entity/getters/view-monitor.js +2 -2
- package/dist/lib/import/import-cad.js +82 -82
- package/dist/lib/import/import-csv.js +51 -51
- package/dist/lib/import/import-json.js +51 -51
- package/dist/lib/import/import-kml.js +51 -51
- package/dist/lib/import/imported-file.js +121 -121
- package/dist/lib/markup/markup.js +40 -40
- package/dist/lib/program-key/program-key.js +152 -152
- package/dist/lib/project/menu-item.js +115 -115
- package/dist/lib/project/project-view-bookmark.js +172 -172
- package/dist/lib/project/project-view-tile-source.js +115 -115
- package/dist/lib/project/project-view.js +166 -166
- package/dist/lib/project/zoom-control.js +17 -17
- package/dist/lib/server/pending-action.js +106 -106
- package/dist/lib/server/task.js +113 -113
- package/dist/lib/style/style.js +152 -152
- package/dist/lib/tileset/tileset-cad.js +2 -2
- package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
- package/dist/lib/tileset/tileset-entities.js +2 -2
- package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
- package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
- package/dist/lib/tileset/tileset-map-tiles.js +2 -2
- package/dist/lib/tileset/tileset-pointcloud.js +2 -2
- package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
- package/dist/lib/tileset/tileset.js +403 -403
- package/dist/lib/ucs/ucs.js +135 -135
- package/dist/lib/user/permission.js +20 -20
- package/dist/lib/user/session.js +160 -160
- package/dist/lib/user/user-group.js +139 -139
- package/dist/lib/user/user.js +451 -451
- package/dist/lib/util/encrypt-utils.js +20 -20
- package/dist/lib/util/math-utils.js +41 -41
- package/dist/lib/util/object-utils.js +17 -17
- package/dist/lib/util/path-utils.js +61 -61
- package/dist/lib/util/url-utils.js +107 -107
- package/dist/types/entity/entity-type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,345 +1,345 @@
|
|
|
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.EntityFilterGetter = void 0;
|
|
40
|
-
var api_1 = require("../../api/api");
|
|
41
|
-
var bruce_event_1 = require("../../common/bruce-event");
|
|
42
|
-
var entity_1 = require("../entity");
|
|
43
|
-
var entity_globe_1 = require("./entity-globe");
|
|
44
|
-
var MAX_AREA_IN_DEGREES = 90;
|
|
45
|
-
var MAX_RETRY_ATTEMPTS = 1;
|
|
46
|
-
var RETRY_DELAY_INCREMENT = 500;
|
|
47
|
-
var REQUEST_PAGE_DELAY = 50;
|
|
48
|
-
var regMenuItemGetter = /** @class */ (function () {
|
|
49
|
-
function regMenuItemGetter(tagIds, minHeight, maxHeight) {
|
|
50
|
-
this.TagIds = tagIds;
|
|
51
|
-
this.MinHeight = minHeight;
|
|
52
|
-
this.MaxHeight = maxHeight;
|
|
53
|
-
}
|
|
54
|
-
return regMenuItemGetter;
|
|
55
|
-
}());
|
|
56
|
-
function delay(milliseconds) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
return __generator(this, function (_a) {
|
|
59
|
-
return [2 /*return*/, new Promise(function (res) {
|
|
60
|
-
setTimeout(function () {
|
|
61
|
-
res();
|
|
62
|
-
}, milliseconds);
|
|
63
|
-
})];
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* This is a batched entity getter.
|
|
69
|
-
* It will scan for entity records in a view-area and emit them in batches.
|
|
70
|
-
* It will restart scanning if the camera moves.
|
|
71
|
-
*/
|
|
72
|
-
var EntityFilterGetter;
|
|
73
|
-
(function (EntityFilterGetter) {
|
|
74
|
-
var EStatus;
|
|
75
|
-
(function (EStatus) {
|
|
76
|
-
EStatus["Scanning"] = "SCANNING";
|
|
77
|
-
EStatus["Loading"] = "LOADING";
|
|
78
|
-
})(EStatus = EntityFilterGetter.EStatus || (EntityFilterGetter.EStatus = {}));
|
|
79
|
-
var Getter = /** @class */ (function () {
|
|
80
|
-
function Getter(api, viewPort, typeId, batchSize, attrFilter) {
|
|
81
|
-
this.onUpdate = null;
|
|
82
|
-
this.LastStateUpdates = {};
|
|
83
|
-
this.onStateUpdate = null;
|
|
84
|
-
this.viewPortChangeRemoval = null;
|
|
85
|
-
this.cells = null;
|
|
86
|
-
this.registeredItems = {};
|
|
87
|
-
this.getterLoopId = 0;
|
|
88
|
-
this.tagIds = null;
|
|
89
|
-
this.minHeight = 0;
|
|
90
|
-
this.maxHeight = 100000;
|
|
91
|
-
this.viewRect = null;
|
|
92
|
-
this.viewCenter = null;
|
|
93
|
-
this.api = api;
|
|
94
|
-
this.typeId = typeId;
|
|
95
|
-
this.batchSize = batchSize;
|
|
96
|
-
this.viewPort = viewPort;
|
|
97
|
-
this.attrFilter = attrFilter;
|
|
98
|
-
this.updateBounds();
|
|
99
|
-
}
|
|
100
|
-
Object.defineProperty(Getter.prototype, "OnUpdate", {
|
|
101
|
-
get: function () {
|
|
102
|
-
if (!this.onUpdate) {
|
|
103
|
-
this.onUpdate = new bruce_event_1.BruceEvent();
|
|
104
|
-
}
|
|
105
|
-
return this.onUpdate;
|
|
106
|
-
},
|
|
107
|
-
enumerable: false,
|
|
108
|
-
configurable: true
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(Getter.prototype, "OnStateUpdate", {
|
|
111
|
-
get: function () {
|
|
112
|
-
if (!this.onStateUpdate) {
|
|
113
|
-
this.onStateUpdate = new bruce_event_1.BruceEvent();
|
|
114
|
-
}
|
|
115
|
-
return this.onStateUpdate;
|
|
116
|
-
},
|
|
117
|
-
enumerable: false,
|
|
118
|
-
configurable: true
|
|
119
|
-
});
|
|
120
|
-
Getter.prototype.viewAreaSub = function () {
|
|
121
|
-
var _this = this;
|
|
122
|
-
this.viewAreaDispose();
|
|
123
|
-
this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
|
|
124
|
-
_this.updateBounds();
|
|
125
|
-
_this.startGetterLoop();
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
Getter.prototype.viewAreaDispose = function () {
|
|
129
|
-
var _a;
|
|
130
|
-
(_a = this.viewPortChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
131
|
-
};
|
|
132
|
-
Getter.prototype.GetMenuItems = function () {
|
|
133
|
-
return Object.keys(this.registeredItems);
|
|
134
|
-
};
|
|
135
|
-
Getter.prototype.IncludeMenuItem = function (menuItemId, layerIds, minHeight, maxHeight) {
|
|
136
|
-
this.registeredItems[menuItemId] = new regMenuItemGetter(layerIds, minHeight, maxHeight);
|
|
137
|
-
this.updateState();
|
|
138
|
-
};
|
|
139
|
-
Getter.prototype.ExcludeMenuItem = function (menuItemId) {
|
|
140
|
-
this.registeredItems[menuItemId] = null;
|
|
141
|
-
delete this.registeredItems[menuItemId];
|
|
142
|
-
this.updateState();
|
|
143
|
-
};
|
|
144
|
-
Getter.prototype.updateBounds = function () {
|
|
145
|
-
var viewRect = this.viewPort.GetBounds();
|
|
146
|
-
var poi = this.viewPort.GetTarget();
|
|
147
|
-
if (viewRect && poi) {
|
|
148
|
-
if (Math.abs(viewRect.west - viewRect.east) > MAX_AREA_IN_DEGREES) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (Math.abs(viewRect.south - viewRect.north) > MAX_AREA_IN_DEGREES) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
this.viewRect = viewRect;
|
|
155
|
-
this.viewCenter = poi;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
Getter.prototype.updateState = function () {
|
|
159
|
-
var tagIds = [];
|
|
160
|
-
var menuItemIds = this.GetMenuItems();
|
|
161
|
-
var minHeight = null;
|
|
162
|
-
var maxHeight = null;
|
|
163
|
-
for (var i = 0; i < menuItemIds.length; i++) {
|
|
164
|
-
var menuItem = this.registeredItems[menuItemIds[i]];
|
|
165
|
-
if (menuItem) {
|
|
166
|
-
if (maxHeight == null || maxHeight < menuItem.MaxHeight) {
|
|
167
|
-
maxHeight = menuItem.MaxHeight;
|
|
168
|
-
}
|
|
169
|
-
if (minHeight == null || minHeight > menuItem.MinHeight) {
|
|
170
|
-
minHeight = menuItem.MinHeight;
|
|
171
|
-
}
|
|
172
|
-
var itemLayerIds = menuItem.TagIds;
|
|
173
|
-
if (itemLayerIds) {
|
|
174
|
-
for (var j = 0; j < itemLayerIds.length; j++) {
|
|
175
|
-
var itemLayerId = itemLayerIds[j];
|
|
176
|
-
if (!tagIds.includes(itemLayerId)) {
|
|
177
|
-
tagIds.push(itemLayerId);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
if (menuItemIds.length > 0) {
|
|
184
|
-
// Reset cells so none are marked as fetched.
|
|
185
|
-
this.cells = new entity_globe_1.EntityGlobe.Grid();
|
|
186
|
-
this.tagIds = tagIds;
|
|
187
|
-
this.minHeight = minHeight;
|
|
188
|
-
this.maxHeight = maxHeight;
|
|
189
|
-
this.updateBounds();
|
|
190
|
-
this.startGetterLoop();
|
|
191
|
-
this.viewAreaSub();
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
this.getterLoopId = -1;
|
|
195
|
-
this.viewAreaDispose();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
Getter.prototype.postStatus = function (status) {
|
|
199
|
-
var _a;
|
|
200
|
-
this.LastStateUpdates[status.msg] = status;
|
|
201
|
-
(_a = this.onStateUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(status);
|
|
202
|
-
};
|
|
203
|
-
Getter.prototype.startGetterLoop = function () {
|
|
204
|
-
var _this = this;
|
|
205
|
-
// Increase id so that existing loops stop.
|
|
206
|
-
this.getterLoopId += 1;
|
|
207
|
-
var loopId = this.getterLoopId;
|
|
208
|
-
new Promise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
209
|
-
var MIN_HEIGHT, MAX_HEIGHT, PAGE_SIZE, retryAttempts, retryDelay, prevFirstId, prevLastId, alt, cells, curCellIndex, postedScanning, postedLoading, curCell, page, first, last, e_1;
|
|
210
|
-
var _a, _b, _c, _d, _e;
|
|
211
|
-
return __generator(this, function (_f) {
|
|
212
|
-
switch (_f.label) {
|
|
213
|
-
case 0:
|
|
214
|
-
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
215
|
-
// This gives it time to recognize only 1 request is needed.
|
|
216
|
-
// Would be better to not use this delay but we're on a clock.
|
|
217
|
-
return [4 /*yield*/, delay(100)];
|
|
218
|
-
case 1:
|
|
219
|
-
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
220
|
-
// This gives it time to recognize only 1 request is needed.
|
|
221
|
-
// Would be better to not use this delay but we're on a clock.
|
|
222
|
-
_f.sent();
|
|
223
|
-
MIN_HEIGHT = this.minHeight;
|
|
224
|
-
MAX_HEIGHT = this.maxHeight;
|
|
225
|
-
PAGE_SIZE = this.batchSize;
|
|
226
|
-
retryAttempts = MAX_RETRY_ATTEMPTS;
|
|
227
|
-
retryDelay = 0;
|
|
228
|
-
prevFirstId = "";
|
|
229
|
-
prevLastId = "";
|
|
230
|
-
_f.label = 2;
|
|
231
|
-
case 2:
|
|
232
|
-
if (!((!this.viewCenter || !this.viewRect) && this.getterLoopId == loopId)) return [3 /*break*/, 4];
|
|
233
|
-
return [4 /*yield*/, delay(RETRY_DELAY_INCREMENT)];
|
|
234
|
-
case 3:
|
|
235
|
-
_f.sent();
|
|
236
|
-
return [3 /*break*/, 2];
|
|
237
|
-
case 4:
|
|
238
|
-
if (this.getterLoopId != loopId) {
|
|
239
|
-
return [2 /*return*/];
|
|
240
|
-
}
|
|
241
|
-
alt = this.viewRect.alt;
|
|
242
|
-
if (alt > MAX_HEIGHT || (alt < MIN_HEIGHT && MIN_HEIGHT > 0)) {
|
|
243
|
-
return [2 /*return*/];
|
|
244
|
-
}
|
|
245
|
-
cells = this.cells.GetCellsForView(this.viewRect);
|
|
246
|
-
curCellIndex = cells.length > 0 ? 0 : null;
|
|
247
|
-
postedScanning = false;
|
|
248
|
-
postedLoading = false;
|
|
249
|
-
_f.label = 5;
|
|
250
|
-
case 5:
|
|
251
|
-
if (!(retryAttempts > 0 && curCellIndex != null)) return [3 /*break*/, 13];
|
|
252
|
-
if (this.getterLoopId != loopId) {
|
|
253
|
-
return [3 /*break*/, 13];
|
|
254
|
-
}
|
|
255
|
-
if (!(retryDelay > 0)) return [3 /*break*/, 7];
|
|
256
|
-
return [4 /*yield*/, delay(retryDelay)];
|
|
257
|
-
case 6:
|
|
258
|
-
_f.sent();
|
|
259
|
-
_f.label = 7;
|
|
260
|
-
case 7:
|
|
261
|
-
if (!postedScanning) {
|
|
262
|
-
this.postStatus({ msg: EStatus.Scanning, revoking: false });
|
|
263
|
-
postedScanning = true;
|
|
264
|
-
}
|
|
265
|
-
curCell = cells[curCellIndex];
|
|
266
|
-
if (curCell.IsFetched()) {
|
|
267
|
-
curCellIndex += 1;
|
|
268
|
-
if (!cells[curCellIndex]) {
|
|
269
|
-
curCellIndex = null;
|
|
270
|
-
}
|
|
271
|
-
return [3 /*break*/, 5];
|
|
272
|
-
}
|
|
273
|
-
_f.label = 8;
|
|
274
|
-
case 8:
|
|
275
|
-
_f.trys.push([8, 10, , 11]);
|
|
276
|
-
return [4 /*yield*/, entity_1.Entity.Filter.V1.GetList(this.api, {
|
|
277
|
-
pageSize: PAGE_SIZE,
|
|
278
|
-
pageIndex: curCell.FetchPageIndex,
|
|
279
|
-
entityTypeId: this.typeId,
|
|
280
|
-
layerIds: this.tagIds,
|
|
281
|
-
bounds: curCell.GetBounds(),
|
|
282
|
-
sortOrder: api_1.Api.ESortOrder.Asc,
|
|
283
|
-
entityTypeConditions: this.attrFilter
|
|
284
|
-
})];
|
|
285
|
-
case 9:
|
|
286
|
-
page = _f.sent();
|
|
287
|
-
if (this.getterLoopId != loopId) {
|
|
288
|
-
return [3 /*break*/, 13];
|
|
289
|
-
}
|
|
290
|
-
if (page) {
|
|
291
|
-
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(page);
|
|
292
|
-
}
|
|
293
|
-
if (!postedLoading) {
|
|
294
|
-
this.postStatus({ msg: EStatus.Loading, revoking: false });
|
|
295
|
-
postedLoading = true;
|
|
296
|
-
}
|
|
297
|
-
if (page.length <= 0) {
|
|
298
|
-
curCell.Fetched = true; // Only mark as fetched when ALL pages are done.
|
|
299
|
-
return [3 /*break*/, 5];
|
|
300
|
-
}
|
|
301
|
-
// Checking to make sure it's not just the same batch over and over again.
|
|
302
|
-
if (page.length > 0) {
|
|
303
|
-
first = (_c = (_b = page[0]) === null || _b === void 0 ? void 0 : _b.Bruce) === null || _c === void 0 ? void 0 : _c.ID;
|
|
304
|
-
last = (_e = (_d = page[page.length - 1]) === null || _d === void 0 ? void 0 : _d.Bruce) === null || _e === void 0 ? void 0 : _e.ID;
|
|
305
|
-
if (prevFirstId == first && prevLastId == last) {
|
|
306
|
-
return [3 /*break*/, 13];
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
prevFirstId = first;
|
|
310
|
-
prevLastId = last;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
curCell.FetchPageIndex++;
|
|
314
|
-
// Request passed so let's assume it was server hiccup and refresh counts.
|
|
315
|
-
retryAttempts = MAX_RETRY_ATTEMPTS;
|
|
316
|
-
retryDelay = 0;
|
|
317
|
-
return [3 /*break*/, 11];
|
|
318
|
-
case 10:
|
|
319
|
-
e_1 = _f.sent();
|
|
320
|
-
console.log(e_1);
|
|
321
|
-
// Request failed so let's add a delay and try again soon.
|
|
322
|
-
retryDelay += RETRY_DELAY_INCREMENT;
|
|
323
|
-
retryAttempts -= 1;
|
|
324
|
-
return [3 /*break*/, 11];
|
|
325
|
-
case 11: return [4 /*yield*/, delay(REQUEST_PAGE_DELAY)];
|
|
326
|
-
case 12:
|
|
327
|
-
_f.sent();
|
|
328
|
-
return [3 /*break*/, 5];
|
|
329
|
-
case 13:
|
|
330
|
-
if (postedLoading) {
|
|
331
|
-
this.postStatus({ msg: EStatus.Loading, revoking: true });
|
|
332
|
-
}
|
|
333
|
-
if (postedScanning) {
|
|
334
|
-
this.postStatus({ msg: EStatus.Scanning, revoking: true });
|
|
335
|
-
}
|
|
336
|
-
return [2 /*return*/];
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}); });
|
|
340
|
-
};
|
|
341
|
-
return Getter;
|
|
342
|
-
}());
|
|
343
|
-
EntityFilterGetter.Getter = Getter;
|
|
344
|
-
})(EntityFilterGetter = exports.EntityFilterGetter || (exports.EntityFilterGetter = {}));
|
|
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.EntityFilterGetter = void 0;
|
|
40
|
+
var api_1 = require("../../api/api");
|
|
41
|
+
var bruce_event_1 = require("../../common/bruce-event");
|
|
42
|
+
var entity_1 = require("../entity");
|
|
43
|
+
var entity_globe_1 = require("./entity-globe");
|
|
44
|
+
var MAX_AREA_IN_DEGREES = 90;
|
|
45
|
+
var MAX_RETRY_ATTEMPTS = 1;
|
|
46
|
+
var RETRY_DELAY_INCREMENT = 500;
|
|
47
|
+
var REQUEST_PAGE_DELAY = 50;
|
|
48
|
+
var regMenuItemGetter = /** @class */ (function () {
|
|
49
|
+
function regMenuItemGetter(tagIds, minHeight, maxHeight) {
|
|
50
|
+
this.TagIds = tagIds;
|
|
51
|
+
this.MinHeight = minHeight;
|
|
52
|
+
this.MaxHeight = maxHeight;
|
|
53
|
+
}
|
|
54
|
+
return regMenuItemGetter;
|
|
55
|
+
}());
|
|
56
|
+
function delay(milliseconds) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
return [2 /*return*/, new Promise(function (res) {
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
res();
|
|
62
|
+
}, milliseconds);
|
|
63
|
+
})];
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* This is a batched entity getter.
|
|
69
|
+
* It will scan for entity records in a view-area and emit them in batches.
|
|
70
|
+
* It will restart scanning if the camera moves.
|
|
71
|
+
*/
|
|
72
|
+
var EntityFilterGetter;
|
|
73
|
+
(function (EntityFilterGetter) {
|
|
74
|
+
var EStatus;
|
|
75
|
+
(function (EStatus) {
|
|
76
|
+
EStatus["Scanning"] = "SCANNING";
|
|
77
|
+
EStatus["Loading"] = "LOADING";
|
|
78
|
+
})(EStatus = EntityFilterGetter.EStatus || (EntityFilterGetter.EStatus = {}));
|
|
79
|
+
var Getter = /** @class */ (function () {
|
|
80
|
+
function Getter(api, viewPort, typeId, batchSize, attrFilter) {
|
|
81
|
+
this.onUpdate = null;
|
|
82
|
+
this.LastStateUpdates = {};
|
|
83
|
+
this.onStateUpdate = null;
|
|
84
|
+
this.viewPortChangeRemoval = null;
|
|
85
|
+
this.cells = null;
|
|
86
|
+
this.registeredItems = {};
|
|
87
|
+
this.getterLoopId = 0;
|
|
88
|
+
this.tagIds = null;
|
|
89
|
+
this.minHeight = 0;
|
|
90
|
+
this.maxHeight = 100000;
|
|
91
|
+
this.viewRect = null;
|
|
92
|
+
this.viewCenter = null;
|
|
93
|
+
this.api = api;
|
|
94
|
+
this.typeId = typeId;
|
|
95
|
+
this.batchSize = batchSize;
|
|
96
|
+
this.viewPort = viewPort;
|
|
97
|
+
this.attrFilter = attrFilter;
|
|
98
|
+
this.updateBounds();
|
|
99
|
+
}
|
|
100
|
+
Object.defineProperty(Getter.prototype, "OnUpdate", {
|
|
101
|
+
get: function () {
|
|
102
|
+
if (!this.onUpdate) {
|
|
103
|
+
this.onUpdate = new bruce_event_1.BruceEvent();
|
|
104
|
+
}
|
|
105
|
+
return this.onUpdate;
|
|
106
|
+
},
|
|
107
|
+
enumerable: false,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(Getter.prototype, "OnStateUpdate", {
|
|
111
|
+
get: function () {
|
|
112
|
+
if (!this.onStateUpdate) {
|
|
113
|
+
this.onStateUpdate = new bruce_event_1.BruceEvent();
|
|
114
|
+
}
|
|
115
|
+
return this.onStateUpdate;
|
|
116
|
+
},
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true
|
|
119
|
+
});
|
|
120
|
+
Getter.prototype.viewAreaSub = function () {
|
|
121
|
+
var _this = this;
|
|
122
|
+
this.viewAreaDispose();
|
|
123
|
+
this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(function () {
|
|
124
|
+
_this.updateBounds();
|
|
125
|
+
_this.startGetterLoop();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
Getter.prototype.viewAreaDispose = function () {
|
|
129
|
+
var _a;
|
|
130
|
+
(_a = this.viewPortChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
131
|
+
};
|
|
132
|
+
Getter.prototype.GetMenuItems = function () {
|
|
133
|
+
return Object.keys(this.registeredItems);
|
|
134
|
+
};
|
|
135
|
+
Getter.prototype.IncludeMenuItem = function (menuItemId, layerIds, minHeight, maxHeight) {
|
|
136
|
+
this.registeredItems[menuItemId] = new regMenuItemGetter(layerIds, minHeight, maxHeight);
|
|
137
|
+
this.updateState();
|
|
138
|
+
};
|
|
139
|
+
Getter.prototype.ExcludeMenuItem = function (menuItemId) {
|
|
140
|
+
this.registeredItems[menuItemId] = null;
|
|
141
|
+
delete this.registeredItems[menuItemId];
|
|
142
|
+
this.updateState();
|
|
143
|
+
};
|
|
144
|
+
Getter.prototype.updateBounds = function () {
|
|
145
|
+
var viewRect = this.viewPort.GetBounds();
|
|
146
|
+
var poi = this.viewPort.GetTarget();
|
|
147
|
+
if (viewRect && poi) {
|
|
148
|
+
if (Math.abs(viewRect.west - viewRect.east) > MAX_AREA_IN_DEGREES) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (Math.abs(viewRect.south - viewRect.north) > MAX_AREA_IN_DEGREES) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.viewRect = viewRect;
|
|
155
|
+
this.viewCenter = poi;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
Getter.prototype.updateState = function () {
|
|
159
|
+
var tagIds = [];
|
|
160
|
+
var menuItemIds = this.GetMenuItems();
|
|
161
|
+
var minHeight = null;
|
|
162
|
+
var maxHeight = null;
|
|
163
|
+
for (var i = 0; i < menuItemIds.length; i++) {
|
|
164
|
+
var menuItem = this.registeredItems[menuItemIds[i]];
|
|
165
|
+
if (menuItem) {
|
|
166
|
+
if (maxHeight == null || maxHeight < menuItem.MaxHeight) {
|
|
167
|
+
maxHeight = menuItem.MaxHeight;
|
|
168
|
+
}
|
|
169
|
+
if (minHeight == null || minHeight > menuItem.MinHeight) {
|
|
170
|
+
minHeight = menuItem.MinHeight;
|
|
171
|
+
}
|
|
172
|
+
var itemLayerIds = menuItem.TagIds;
|
|
173
|
+
if (itemLayerIds) {
|
|
174
|
+
for (var j = 0; j < itemLayerIds.length; j++) {
|
|
175
|
+
var itemLayerId = itemLayerIds[j];
|
|
176
|
+
if (!tagIds.includes(itemLayerId)) {
|
|
177
|
+
tagIds.push(itemLayerId);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (menuItemIds.length > 0) {
|
|
184
|
+
// Reset cells so none are marked as fetched.
|
|
185
|
+
this.cells = new entity_globe_1.EntityGlobe.Grid();
|
|
186
|
+
this.tagIds = tagIds;
|
|
187
|
+
this.minHeight = minHeight;
|
|
188
|
+
this.maxHeight = maxHeight;
|
|
189
|
+
this.updateBounds();
|
|
190
|
+
this.startGetterLoop();
|
|
191
|
+
this.viewAreaSub();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
this.getterLoopId = -1;
|
|
195
|
+
this.viewAreaDispose();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
Getter.prototype.postStatus = function (status) {
|
|
199
|
+
var _a;
|
|
200
|
+
this.LastStateUpdates[status.msg] = status;
|
|
201
|
+
(_a = this.onStateUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(status);
|
|
202
|
+
};
|
|
203
|
+
Getter.prototype.startGetterLoop = function () {
|
|
204
|
+
var _this = this;
|
|
205
|
+
// Increase id so that existing loops stop.
|
|
206
|
+
this.getterLoopId += 1;
|
|
207
|
+
var loopId = this.getterLoopId;
|
|
208
|
+
new Promise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
209
|
+
var MIN_HEIGHT, MAX_HEIGHT, PAGE_SIZE, retryAttempts, retryDelay, prevFirstId, prevLastId, alt, cells, curCellIndex, postedScanning, postedLoading, curCell, page, first, last, e_1;
|
|
210
|
+
var _a, _b, _c, _d, _e;
|
|
211
|
+
return __generator(this, function (_f) {
|
|
212
|
+
switch (_f.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
215
|
+
// This gives it time to recognize only 1 request is needed.
|
|
216
|
+
// Would be better to not use this delay but we're on a clock.
|
|
217
|
+
return [4 /*yield*/, delay(100)];
|
|
218
|
+
case 1:
|
|
219
|
+
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
220
|
+
// This gives it time to recognize only 1 request is needed.
|
|
221
|
+
// Would be better to not use this delay but we're on a clock.
|
|
222
|
+
_f.sent();
|
|
223
|
+
MIN_HEIGHT = this.minHeight;
|
|
224
|
+
MAX_HEIGHT = this.maxHeight;
|
|
225
|
+
PAGE_SIZE = this.batchSize;
|
|
226
|
+
retryAttempts = MAX_RETRY_ATTEMPTS;
|
|
227
|
+
retryDelay = 0;
|
|
228
|
+
prevFirstId = "";
|
|
229
|
+
prevLastId = "";
|
|
230
|
+
_f.label = 2;
|
|
231
|
+
case 2:
|
|
232
|
+
if (!((!this.viewCenter || !this.viewRect) && this.getterLoopId == loopId)) return [3 /*break*/, 4];
|
|
233
|
+
return [4 /*yield*/, delay(RETRY_DELAY_INCREMENT)];
|
|
234
|
+
case 3:
|
|
235
|
+
_f.sent();
|
|
236
|
+
return [3 /*break*/, 2];
|
|
237
|
+
case 4:
|
|
238
|
+
if (this.getterLoopId != loopId) {
|
|
239
|
+
return [2 /*return*/];
|
|
240
|
+
}
|
|
241
|
+
alt = this.viewRect.alt;
|
|
242
|
+
if (alt > MAX_HEIGHT || (alt < MIN_HEIGHT && MIN_HEIGHT > 0)) {
|
|
243
|
+
return [2 /*return*/];
|
|
244
|
+
}
|
|
245
|
+
cells = this.cells.GetCellsForView(this.viewRect);
|
|
246
|
+
curCellIndex = cells.length > 0 ? 0 : null;
|
|
247
|
+
postedScanning = false;
|
|
248
|
+
postedLoading = false;
|
|
249
|
+
_f.label = 5;
|
|
250
|
+
case 5:
|
|
251
|
+
if (!(retryAttempts > 0 && curCellIndex != null)) return [3 /*break*/, 13];
|
|
252
|
+
if (this.getterLoopId != loopId) {
|
|
253
|
+
return [3 /*break*/, 13];
|
|
254
|
+
}
|
|
255
|
+
if (!(retryDelay > 0)) return [3 /*break*/, 7];
|
|
256
|
+
return [4 /*yield*/, delay(retryDelay)];
|
|
257
|
+
case 6:
|
|
258
|
+
_f.sent();
|
|
259
|
+
_f.label = 7;
|
|
260
|
+
case 7:
|
|
261
|
+
if (!postedScanning) {
|
|
262
|
+
this.postStatus({ msg: EStatus.Scanning, revoking: false });
|
|
263
|
+
postedScanning = true;
|
|
264
|
+
}
|
|
265
|
+
curCell = cells[curCellIndex];
|
|
266
|
+
if (curCell.IsFetched()) {
|
|
267
|
+
curCellIndex += 1;
|
|
268
|
+
if (!cells[curCellIndex]) {
|
|
269
|
+
curCellIndex = null;
|
|
270
|
+
}
|
|
271
|
+
return [3 /*break*/, 5];
|
|
272
|
+
}
|
|
273
|
+
_f.label = 8;
|
|
274
|
+
case 8:
|
|
275
|
+
_f.trys.push([8, 10, , 11]);
|
|
276
|
+
return [4 /*yield*/, entity_1.Entity.Filter.V1.GetList(this.api, {
|
|
277
|
+
pageSize: PAGE_SIZE,
|
|
278
|
+
pageIndex: curCell.FetchPageIndex,
|
|
279
|
+
entityTypeId: this.typeId,
|
|
280
|
+
layerIds: this.tagIds,
|
|
281
|
+
bounds: curCell.GetBounds(),
|
|
282
|
+
sortOrder: api_1.Api.ESortOrder.Asc,
|
|
283
|
+
entityTypeConditions: this.attrFilter
|
|
284
|
+
})];
|
|
285
|
+
case 9:
|
|
286
|
+
page = _f.sent();
|
|
287
|
+
if (this.getterLoopId != loopId) {
|
|
288
|
+
return [3 /*break*/, 13];
|
|
289
|
+
}
|
|
290
|
+
if (page) {
|
|
291
|
+
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(page);
|
|
292
|
+
}
|
|
293
|
+
if (!postedLoading) {
|
|
294
|
+
this.postStatus({ msg: EStatus.Loading, revoking: false });
|
|
295
|
+
postedLoading = true;
|
|
296
|
+
}
|
|
297
|
+
if (page.length <= 0) {
|
|
298
|
+
curCell.Fetched = true; // Only mark as fetched when ALL pages are done.
|
|
299
|
+
return [3 /*break*/, 5];
|
|
300
|
+
}
|
|
301
|
+
// Checking to make sure it's not just the same batch over and over again.
|
|
302
|
+
if (page.length > 0) {
|
|
303
|
+
first = (_c = (_b = page[0]) === null || _b === void 0 ? void 0 : _b.Bruce) === null || _c === void 0 ? void 0 : _c.ID;
|
|
304
|
+
last = (_e = (_d = page[page.length - 1]) === null || _d === void 0 ? void 0 : _d.Bruce) === null || _e === void 0 ? void 0 : _e.ID;
|
|
305
|
+
if (prevFirstId == first && prevLastId == last) {
|
|
306
|
+
return [3 /*break*/, 13];
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
prevFirstId = first;
|
|
310
|
+
prevLastId = last;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
curCell.FetchPageIndex++;
|
|
314
|
+
// Request passed so let's assume it was server hiccup and refresh counts.
|
|
315
|
+
retryAttempts = MAX_RETRY_ATTEMPTS;
|
|
316
|
+
retryDelay = 0;
|
|
317
|
+
return [3 /*break*/, 11];
|
|
318
|
+
case 10:
|
|
319
|
+
e_1 = _f.sent();
|
|
320
|
+
console.log(e_1);
|
|
321
|
+
// Request failed so let's add a delay and try again soon.
|
|
322
|
+
retryDelay += RETRY_DELAY_INCREMENT;
|
|
323
|
+
retryAttempts -= 1;
|
|
324
|
+
return [3 /*break*/, 11];
|
|
325
|
+
case 11: return [4 /*yield*/, delay(REQUEST_PAGE_DELAY)];
|
|
326
|
+
case 12:
|
|
327
|
+
_f.sent();
|
|
328
|
+
return [3 /*break*/, 5];
|
|
329
|
+
case 13:
|
|
330
|
+
if (postedLoading) {
|
|
331
|
+
this.postStatus({ msg: EStatus.Loading, revoking: true });
|
|
332
|
+
}
|
|
333
|
+
if (postedScanning) {
|
|
334
|
+
this.postStatus({ msg: EStatus.Scanning, revoking: true });
|
|
335
|
+
}
|
|
336
|
+
return [2 /*return*/];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}); });
|
|
340
|
+
};
|
|
341
|
+
return Getter;
|
|
342
|
+
}());
|
|
343
|
+
EntityFilterGetter.Getter = Getter;
|
|
344
|
+
})(EntityFilterGetter = exports.EntityFilterGetter || (exports.EntityFilterGetter = {}));
|
|
345
345
|
//# sourceMappingURL=entity-filter-getter.js.map
|