bruce-models 1.0.3 → 1.0.5
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 +114 -92
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +119 -92
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/entity/getters/entity-filter-getter.js +28 -7
- package/dist/lib/entity/getters/entity-filter-getter.js.map +1 -1
- package/dist/lib/entity/getters/entity-globe.js +86 -85
- package/dist/lib/entity/getters/entity-globe.js.map +1 -1
- package/dist/types/entity/getters/entity-filter-getter.d.ts +9 -0
- package/dist/types/entity/getters/entity-globe.d.ts +7 -8
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -3172,92 +3172,41 @@
|
|
|
3172
3172
|
EntityType.Update = Update;
|
|
3173
3173
|
})(exports.EntityType || (exports.EntityType = {}));
|
|
3174
3174
|
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
this.Boundaries = null;
|
|
3181
|
-
}
|
|
3182
|
-
GetBounds() {
|
|
3183
|
-
// Entity data works in -180 to 180 range.
|
|
3184
|
-
function prepareRangeForBounds(range) {
|
|
3185
|
-
if (range > 180) {
|
|
3186
|
-
return range - 360;
|
|
3187
|
-
}
|
|
3188
|
-
return range;
|
|
3189
|
-
}
|
|
3190
|
-
// Add minor decimal as API crashes when giving it whole numbers.
|
|
3191
|
-
const maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
|
|
3192
|
-
const minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
|
|
3193
|
-
const maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
|
|
3194
|
-
const minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
|
|
3195
|
-
return {
|
|
3196
|
-
east: maxLon,
|
|
3197
|
-
north: maxLat,
|
|
3198
|
-
south: minLat,
|
|
3199
|
-
west: minLon
|
|
3200
|
-
};
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
function floorValueToCellSize(size, value) {
|
|
3204
|
-
return Math.floor(value / size) * size;
|
|
3205
|
-
}
|
|
3206
|
-
function getCellSizeFromHeight(height) {
|
|
3207
|
-
if (height < 1000) {
|
|
3208
|
-
return 0.01;
|
|
3209
|
-
}
|
|
3210
|
-
if (height < 5000) {
|
|
3211
|
-
return 0.025;
|
|
3212
|
-
}
|
|
3213
|
-
else if (height < 10000) {
|
|
3214
|
-
return 0.05;
|
|
3215
|
-
}
|
|
3216
|
-
else if (height < 30000) {
|
|
3217
|
-
return 0.1;
|
|
3218
|
-
}
|
|
3219
|
-
else if (height < 70000) {
|
|
3220
|
-
return 0.2;
|
|
3221
|
-
}
|
|
3222
|
-
else if (height < 100000) {
|
|
3223
|
-
return 0.3;
|
|
3224
|
-
}
|
|
3225
|
-
else if (height < 150000) {
|
|
3226
|
-
return 0.4;
|
|
3227
|
-
}
|
|
3228
|
-
else if (height < 200000) {
|
|
3229
|
-
return 0.5;
|
|
3230
|
-
}
|
|
3231
|
-
else if (height < 300000) {
|
|
3232
|
-
return 0.6;
|
|
3233
|
-
}
|
|
3234
|
-
else if (height < 500000) {
|
|
3235
|
-
return 1;
|
|
3236
|
-
}
|
|
3237
|
-
return 1.5;
|
|
3238
|
-
}
|
|
3239
|
-
function isCellFetched(cell) {
|
|
3240
|
-
if (cell.Fetched) {
|
|
3241
|
-
return true;
|
|
3242
|
-
}
|
|
3243
|
-
return false;
|
|
3244
|
-
}
|
|
3245
|
-
function getOrCreateCell(cells, cellSize, lon, maxLon, lat, maxLat) {
|
|
3246
|
-
const id = cellSize + "_" + lon + "_" + maxLon + "_" + lat + "_" + maxLat;
|
|
3247
|
-
let cell = cells[id];
|
|
3248
|
-
if (!cell) {
|
|
3249
|
-
cell = cells[id] = new Cell();
|
|
3250
|
-
cell.Boundaries = {
|
|
3251
|
-
minLatitude: lat,
|
|
3252
|
-
maxLatitude: maxLat,
|
|
3253
|
-
minLongitude: lon,
|
|
3254
|
-
maxLongitude: maxLon
|
|
3255
|
-
};
|
|
3256
|
-
cell.IsFetched = () => isCellFetched(cell);
|
|
3257
|
-
}
|
|
3258
|
-
return [id, cell];
|
|
3259
|
-
}
|
|
3175
|
+
/**
|
|
3176
|
+
* This is a helper for making entity requests based on a grid area.
|
|
3177
|
+
* It will return grid cells based on given view-area then will remember when stuff-
|
|
3178
|
+
* was fully-fetched for those cells to avoid making duplicate requests.
|
|
3179
|
+
*/
|
|
3260
3180
|
(function (EntityGlobe) {
|
|
3181
|
+
class Cell {
|
|
3182
|
+
constructor() {
|
|
3183
|
+
this.Fetched = false;
|
|
3184
|
+
this.IsFetched = null;
|
|
3185
|
+
this.FetchPageIndex = 0;
|
|
3186
|
+
this.Boundaries = null;
|
|
3187
|
+
}
|
|
3188
|
+
GetBounds() {
|
|
3189
|
+
// Entity data works in -180 to 180 range.
|
|
3190
|
+
function prepareRangeForBounds(range) {
|
|
3191
|
+
if (range > 180) {
|
|
3192
|
+
return range - 360;
|
|
3193
|
+
}
|
|
3194
|
+
return range;
|
|
3195
|
+
}
|
|
3196
|
+
// Add minor decimal as API crashes when giving it whole numbers.
|
|
3197
|
+
const maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
|
|
3198
|
+
const minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
|
|
3199
|
+
const maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
|
|
3200
|
+
const minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
|
|
3201
|
+
return {
|
|
3202
|
+
east: maxLon,
|
|
3203
|
+
north: maxLat,
|
|
3204
|
+
south: minLat,
|
|
3205
|
+
west: minLon
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
EntityGlobe.Cell = Cell;
|
|
3261
3210
|
class Grid {
|
|
3262
3211
|
constructor() {
|
|
3263
3212
|
this.cells = {};
|
|
@@ -3369,6 +3318,63 @@
|
|
|
3369
3318
|
function area(rect) {
|
|
3370
3319
|
let { west: w, south: s, north: n, east: e } = rect;
|
|
3371
3320
|
return Math.abs((e - w) * (n - s));
|
|
3321
|
+
}
|
|
3322
|
+
function floorValueToCellSize(size, value) {
|
|
3323
|
+
return Math.floor(value / size) * size;
|
|
3324
|
+
}
|
|
3325
|
+
function getCellSizeFromHeight(height) {
|
|
3326
|
+
if (height < 1000) {
|
|
3327
|
+
return 0.01;
|
|
3328
|
+
}
|
|
3329
|
+
if (height < 5000) {
|
|
3330
|
+
return 0.025;
|
|
3331
|
+
}
|
|
3332
|
+
else if (height < 10000) {
|
|
3333
|
+
return 0.05;
|
|
3334
|
+
}
|
|
3335
|
+
else if (height < 30000) {
|
|
3336
|
+
return 0.1;
|
|
3337
|
+
}
|
|
3338
|
+
else if (height < 70000) {
|
|
3339
|
+
return 0.2;
|
|
3340
|
+
}
|
|
3341
|
+
else if (height < 100000) {
|
|
3342
|
+
return 0.3;
|
|
3343
|
+
}
|
|
3344
|
+
else if (height < 150000) {
|
|
3345
|
+
return 0.4;
|
|
3346
|
+
}
|
|
3347
|
+
else if (height < 200000) {
|
|
3348
|
+
return 0.5;
|
|
3349
|
+
}
|
|
3350
|
+
else if (height < 300000) {
|
|
3351
|
+
return 0.6;
|
|
3352
|
+
}
|
|
3353
|
+
else if (height < 500000) {
|
|
3354
|
+
return 1;
|
|
3355
|
+
}
|
|
3356
|
+
return 1.5;
|
|
3357
|
+
}
|
|
3358
|
+
function isCellFetched(cell) {
|
|
3359
|
+
if (cell.Fetched) {
|
|
3360
|
+
return true;
|
|
3361
|
+
}
|
|
3362
|
+
return false;
|
|
3363
|
+
}
|
|
3364
|
+
function getOrCreateCell(cells, cellSize, lon, maxLon, lat, maxLat) {
|
|
3365
|
+
const id = cellSize + "_" + lon + "_" + maxLon + "_" + lat + "_" + maxLat;
|
|
3366
|
+
let cell = cells[id];
|
|
3367
|
+
if (!cell) {
|
|
3368
|
+
cell = cells[id] = new exports.EntityGlobe.Cell();
|
|
3369
|
+
cell.Boundaries = {
|
|
3370
|
+
minLatitude: lat,
|
|
3371
|
+
maxLatitude: maxLat,
|
|
3372
|
+
minLongitude: lon,
|
|
3373
|
+
maxLongitude: maxLon
|
|
3374
|
+
};
|
|
3375
|
+
cell.IsFetched = () => isCellFetched(cell);
|
|
3376
|
+
}
|
|
3377
|
+
return [id, cell];
|
|
3372
3378
|
}
|
|
3373
3379
|
|
|
3374
3380
|
const MAX_AREA_IN_DEGREES = 90;
|
|
@@ -3402,6 +3408,7 @@
|
|
|
3402
3408
|
this.onUpdate = null;
|
|
3403
3409
|
this.LastStateUpdates = {};
|
|
3404
3410
|
this.onStateUpdate = null;
|
|
3411
|
+
this.onScanUpdate = null;
|
|
3405
3412
|
this.viewPortChangeRemoval = null;
|
|
3406
3413
|
this.cells = null;
|
|
3407
3414
|
this.registeredItems = {};
|
|
@@ -3430,6 +3437,20 @@
|
|
|
3430
3437
|
}
|
|
3431
3438
|
return this.onStateUpdate;
|
|
3432
3439
|
}
|
|
3440
|
+
get OnScanUpdate() {
|
|
3441
|
+
if (!this.onScanUpdate) {
|
|
3442
|
+
this.onScanUpdate = new BruceEvent();
|
|
3443
|
+
}
|
|
3444
|
+
return this.onScanUpdate;
|
|
3445
|
+
}
|
|
3446
|
+
/**
|
|
3447
|
+
* Returns id that represents the combined menu item parameters.
|
|
3448
|
+
* If integrity changes while a request is running, the request will not emit a response.
|
|
3449
|
+
* @returns
|
|
3450
|
+
*/
|
|
3451
|
+
getIntegrityId() {
|
|
3452
|
+
return this.tagIds == null ? "" : this.tagIds.join();
|
|
3453
|
+
}
|
|
3433
3454
|
viewAreaSub() {
|
|
3434
3455
|
this.viewAreaDispose();
|
|
3435
3456
|
this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(() => {
|
|
@@ -3516,8 +3537,9 @@
|
|
|
3516
3537
|
// Increase id so that existing loops stop.
|
|
3517
3538
|
this.getterLoopId += 1;
|
|
3518
3539
|
const loopId = this.getterLoopId;
|
|
3540
|
+
const loopIntegrity = this.getIntegrityId();
|
|
3519
3541
|
new Promise(() => __awaiter(this, void 0, void 0, function* () {
|
|
3520
|
-
var _a, _b, _c, _d, _e;
|
|
3542
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3521
3543
|
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
3522
3544
|
// This gives it time to recognize only 1 request is needed.
|
|
3523
3545
|
// Would be better to not use this delay but we're on a clock.
|
|
@@ -3540,6 +3562,7 @@
|
|
|
3540
3562
|
return;
|
|
3541
3563
|
}
|
|
3542
3564
|
const cells = this.cells.GetCellsForView(this.viewRect);
|
|
3565
|
+
(_a = this.onScanUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(cells);
|
|
3543
3566
|
let curCellIndex = cells.length > 0 ? 0 : null;
|
|
3544
3567
|
let postedScanning = false;
|
|
3545
3568
|
let postedLoading = false;
|
|
@@ -3560,6 +3583,7 @@
|
|
|
3560
3583
|
if (!cells[curCellIndex]) {
|
|
3561
3584
|
curCellIndex = null;
|
|
3562
3585
|
}
|
|
3586
|
+
(_b = this.onScanUpdate) === null || _b === void 0 ? void 0 : _b.Trigger(cells);
|
|
3563
3587
|
continue;
|
|
3564
3588
|
}
|
|
3565
3589
|
try {
|
|
@@ -3572,24 +3596,27 @@
|
|
|
3572
3596
|
sortOrder: exports.Api.ESortOrder.Asc,
|
|
3573
3597
|
entityTypeConditions: this.attrFilter
|
|
3574
3598
|
});
|
|
3599
|
+
const integrity = this.getIntegrityId();
|
|
3600
|
+
if (loopIntegrity == integrity && page) {
|
|
3601
|
+
(_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger(page);
|
|
3602
|
+
}
|
|
3575
3603
|
if (this.getterLoopId != loopId) {
|
|
3576
3604
|
break;
|
|
3577
3605
|
}
|
|
3578
|
-
if (page) {
|
|
3579
|
-
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(page);
|
|
3580
|
-
}
|
|
3581
3606
|
if (!postedLoading) {
|
|
3582
3607
|
this.postStatus({ msg: EStatus.Loading, revoking: false });
|
|
3583
3608
|
postedLoading = true;
|
|
3584
3609
|
}
|
|
3610
|
+
// Only mark as fetched when ALL pages are done.
|
|
3585
3611
|
if (page.length <= 0) {
|
|
3586
|
-
curCell.Fetched = true;
|
|
3612
|
+
curCell.Fetched = true;
|
|
3613
|
+
(_d = this.onScanUpdate) === null || _d === void 0 ? void 0 : _d.Trigger(cells);
|
|
3587
3614
|
continue;
|
|
3588
3615
|
}
|
|
3589
3616
|
// Checking to make sure it's not just the same batch over and over again.
|
|
3590
3617
|
if (page.length > 0) {
|
|
3591
|
-
const first = (
|
|
3592
|
-
const last = (
|
|
3618
|
+
const first = (_f = (_e = page[0]) === null || _e === void 0 ? void 0 : _e.Bruce) === null || _f === void 0 ? void 0 : _f.ID;
|
|
3619
|
+
const last = (_h = (_g = page[page.length - 1]) === null || _g === void 0 ? void 0 : _g.Bruce) === null || _h === void 0 ? void 0 : _h.ID;
|
|
3593
3620
|
if (prevFirstId == first && prevLastId == last) {
|
|
3594
3621
|
break;
|
|
3595
3622
|
}
|