bruce-models 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-models.es5.js +114 -91
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +119 -91
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/entity/getters/entity-filter-getter.js +16 -5
- 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/lib/project/project-view-bookmark.js +12 -1
- package/dist/lib/project/project-view-bookmark.js.map +1 -1
- package/dist/types/entity/getters/entity-filter-getter.d.ts +3 -0
- package/dist/types/entity/getters/entity-globe.d.ts +7 -8
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -3275,91 +3275,6 @@ var EntityType;
|
|
|
3275
3275
|
EntityType.Update = Update;
|
|
3276
3276
|
})(EntityType || (EntityType = {}));
|
|
3277
3277
|
|
|
3278
|
-
class Cell {
|
|
3279
|
-
constructor() {
|
|
3280
|
-
this.Fetched = false;
|
|
3281
|
-
this.IsFetched = null;
|
|
3282
|
-
this.FetchPageIndex = 0;
|
|
3283
|
-
this.Boundaries = null;
|
|
3284
|
-
}
|
|
3285
|
-
GetBounds() {
|
|
3286
|
-
// Entity data works in -180 to 180 range.
|
|
3287
|
-
function prepareRangeForBounds(range) {
|
|
3288
|
-
if (range > 180) {
|
|
3289
|
-
return range - 360;
|
|
3290
|
-
}
|
|
3291
|
-
return range;
|
|
3292
|
-
}
|
|
3293
|
-
// Add minor decimal as API crashes when giving it whole numbers.
|
|
3294
|
-
const maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
|
|
3295
|
-
const minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
|
|
3296
|
-
const maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
|
|
3297
|
-
const minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
|
|
3298
|
-
return {
|
|
3299
|
-
east: maxLon,
|
|
3300
|
-
north: maxLat,
|
|
3301
|
-
south: minLat,
|
|
3302
|
-
west: minLon
|
|
3303
|
-
};
|
|
3304
|
-
}
|
|
3305
|
-
}
|
|
3306
|
-
function floorValueToCellSize(size, value) {
|
|
3307
|
-
return Math.floor(value / size) * size;
|
|
3308
|
-
}
|
|
3309
|
-
function getCellSizeFromHeight(height) {
|
|
3310
|
-
if (height < 1000) {
|
|
3311
|
-
return 0.01;
|
|
3312
|
-
}
|
|
3313
|
-
if (height < 5000) {
|
|
3314
|
-
return 0.025;
|
|
3315
|
-
}
|
|
3316
|
-
else if (height < 10000) {
|
|
3317
|
-
return 0.05;
|
|
3318
|
-
}
|
|
3319
|
-
else if (height < 30000) {
|
|
3320
|
-
return 0.1;
|
|
3321
|
-
}
|
|
3322
|
-
else if (height < 70000) {
|
|
3323
|
-
return 0.2;
|
|
3324
|
-
}
|
|
3325
|
-
else if (height < 100000) {
|
|
3326
|
-
return 0.3;
|
|
3327
|
-
}
|
|
3328
|
-
else if (height < 150000) {
|
|
3329
|
-
return 0.4;
|
|
3330
|
-
}
|
|
3331
|
-
else if (height < 200000) {
|
|
3332
|
-
return 0.5;
|
|
3333
|
-
}
|
|
3334
|
-
else if (height < 300000) {
|
|
3335
|
-
return 0.6;
|
|
3336
|
-
}
|
|
3337
|
-
else if (height < 500000) {
|
|
3338
|
-
return 1;
|
|
3339
|
-
}
|
|
3340
|
-
return 1.5;
|
|
3341
|
-
}
|
|
3342
|
-
function isCellFetched(cell) {
|
|
3343
|
-
if (cell.Fetched) {
|
|
3344
|
-
return true;
|
|
3345
|
-
}
|
|
3346
|
-
return false;
|
|
3347
|
-
}
|
|
3348
|
-
function getOrCreateCell(cells, cellSize, lon, maxLon, lat, maxLat) {
|
|
3349
|
-
const id = cellSize + "_" + lon + "_" + maxLon + "_" + lat + "_" + maxLat;
|
|
3350
|
-
let cell = cells[id];
|
|
3351
|
-
if (!cell) {
|
|
3352
|
-
cell = cells[id] = new Cell();
|
|
3353
|
-
cell.Boundaries = {
|
|
3354
|
-
minLatitude: lat,
|
|
3355
|
-
maxLatitude: maxLat,
|
|
3356
|
-
minLongitude: lon,
|
|
3357
|
-
maxLongitude: maxLon
|
|
3358
|
-
};
|
|
3359
|
-
cell.IsFetched = () => isCellFetched(cell);
|
|
3360
|
-
}
|
|
3361
|
-
return [id, cell];
|
|
3362
|
-
}
|
|
3363
3278
|
/**
|
|
3364
3279
|
* This is a helper for making entity requests based on a grid area.
|
|
3365
3280
|
* It will return grid cells based on given view-area then will remember when stuff-
|
|
@@ -3367,6 +3282,35 @@ function getOrCreateCell(cells, cellSize, lon, maxLon, lat, maxLat) {
|
|
|
3367
3282
|
*/
|
|
3368
3283
|
var EntityGlobe;
|
|
3369
3284
|
(function (EntityGlobe) {
|
|
3285
|
+
class Cell {
|
|
3286
|
+
constructor() {
|
|
3287
|
+
this.Fetched = false;
|
|
3288
|
+
this.IsFetched = null;
|
|
3289
|
+
this.FetchPageIndex = 0;
|
|
3290
|
+
this.Boundaries = null;
|
|
3291
|
+
}
|
|
3292
|
+
GetBounds() {
|
|
3293
|
+
// Entity data works in -180 to 180 range.
|
|
3294
|
+
function prepareRangeForBounds(range) {
|
|
3295
|
+
if (range > 180) {
|
|
3296
|
+
return range - 360;
|
|
3297
|
+
}
|
|
3298
|
+
return range;
|
|
3299
|
+
}
|
|
3300
|
+
// Add minor decimal as API crashes when giving it whole numbers.
|
|
3301
|
+
const maxLon = prepareRangeForBounds(this.Boundaries.maxLongitude) + 0.00001;
|
|
3302
|
+
const minLon = prepareRangeForBounds(this.Boundaries.minLongitude) - 0.00001;
|
|
3303
|
+
const maxLat = prepareRangeForBounds(this.Boundaries.maxLatitude) + 0.00001;
|
|
3304
|
+
const minLat = prepareRangeForBounds(this.Boundaries.minLatitude) - 0.00001;
|
|
3305
|
+
return {
|
|
3306
|
+
east: maxLon,
|
|
3307
|
+
north: maxLat,
|
|
3308
|
+
south: minLat,
|
|
3309
|
+
west: minLon
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
EntityGlobe.Cell = Cell;
|
|
3370
3314
|
class Grid {
|
|
3371
3315
|
constructor() {
|
|
3372
3316
|
this.cells = {};
|
|
@@ -3478,6 +3422,63 @@ function intersection(l, r) {
|
|
|
3478
3422
|
function area(rect) {
|
|
3479
3423
|
let { west: w, south: s, north: n, east: e } = rect;
|
|
3480
3424
|
return Math.abs((e - w) * (n - s));
|
|
3425
|
+
}
|
|
3426
|
+
function floorValueToCellSize(size, value) {
|
|
3427
|
+
return Math.floor(value / size) * size;
|
|
3428
|
+
}
|
|
3429
|
+
function getCellSizeFromHeight(height) {
|
|
3430
|
+
if (height < 1000) {
|
|
3431
|
+
return 0.01;
|
|
3432
|
+
}
|
|
3433
|
+
if (height < 5000) {
|
|
3434
|
+
return 0.025;
|
|
3435
|
+
}
|
|
3436
|
+
else if (height < 10000) {
|
|
3437
|
+
return 0.05;
|
|
3438
|
+
}
|
|
3439
|
+
else if (height < 30000) {
|
|
3440
|
+
return 0.1;
|
|
3441
|
+
}
|
|
3442
|
+
else if (height < 70000) {
|
|
3443
|
+
return 0.2;
|
|
3444
|
+
}
|
|
3445
|
+
else if (height < 100000) {
|
|
3446
|
+
return 0.3;
|
|
3447
|
+
}
|
|
3448
|
+
else if (height < 150000) {
|
|
3449
|
+
return 0.4;
|
|
3450
|
+
}
|
|
3451
|
+
else if (height < 200000) {
|
|
3452
|
+
return 0.5;
|
|
3453
|
+
}
|
|
3454
|
+
else if (height < 300000) {
|
|
3455
|
+
return 0.6;
|
|
3456
|
+
}
|
|
3457
|
+
else if (height < 500000) {
|
|
3458
|
+
return 1;
|
|
3459
|
+
}
|
|
3460
|
+
return 1.5;
|
|
3461
|
+
}
|
|
3462
|
+
function isCellFetched(cell) {
|
|
3463
|
+
if (cell.Fetched) {
|
|
3464
|
+
return true;
|
|
3465
|
+
}
|
|
3466
|
+
return false;
|
|
3467
|
+
}
|
|
3468
|
+
function getOrCreateCell(cells, cellSize, lon, maxLon, lat, maxLat) {
|
|
3469
|
+
const id = cellSize + "_" + lon + "_" + maxLon + "_" + lat + "_" + maxLat;
|
|
3470
|
+
let cell = cells[id];
|
|
3471
|
+
if (!cell) {
|
|
3472
|
+
cell = cells[id] = new EntityGlobe.Cell();
|
|
3473
|
+
cell.Boundaries = {
|
|
3474
|
+
minLatitude: lat,
|
|
3475
|
+
maxLatitude: maxLat,
|
|
3476
|
+
minLongitude: lon,
|
|
3477
|
+
maxLongitude: maxLon
|
|
3478
|
+
};
|
|
3479
|
+
cell.IsFetched = () => isCellFetched(cell);
|
|
3480
|
+
}
|
|
3481
|
+
return [id, cell];
|
|
3481
3482
|
}
|
|
3482
3483
|
|
|
3483
3484
|
const MAX_AREA_IN_DEGREES = 90;
|
|
@@ -3517,6 +3518,7 @@ var EntityFilterGetter;
|
|
|
3517
3518
|
this.onUpdate = null;
|
|
3518
3519
|
this.LastStateUpdates = {};
|
|
3519
3520
|
this.onStateUpdate = null;
|
|
3521
|
+
this.onScanUpdate = null;
|
|
3520
3522
|
this.viewPortChangeRemoval = null;
|
|
3521
3523
|
this.cells = null;
|
|
3522
3524
|
this.registeredItems = {};
|
|
@@ -3545,6 +3547,12 @@ var EntityFilterGetter;
|
|
|
3545
3547
|
}
|
|
3546
3548
|
return this.onStateUpdate;
|
|
3547
3549
|
}
|
|
3550
|
+
get OnScanUpdate() {
|
|
3551
|
+
if (!this.onScanUpdate) {
|
|
3552
|
+
this.onScanUpdate = new BruceEvent();
|
|
3553
|
+
}
|
|
3554
|
+
return this.onScanUpdate;
|
|
3555
|
+
}
|
|
3548
3556
|
viewAreaSub() {
|
|
3549
3557
|
this.viewAreaDispose();
|
|
3550
3558
|
this.viewPortChangeRemoval = this.viewPort.Updated().Subscribe(() => {
|
|
@@ -3632,7 +3640,7 @@ var EntityFilterGetter;
|
|
|
3632
3640
|
this.getterLoopId += 1;
|
|
3633
3641
|
const loopId = this.getterLoopId;
|
|
3634
3642
|
new Promise(() => __awaiter(this, void 0, void 0, function* () {
|
|
3635
|
-
var _a, _b, _c, _d, _e;
|
|
3643
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3636
3644
|
// Minor delay to stop 50 menu items enabling doing their first request all together.
|
|
3637
3645
|
// This gives it time to recognize only 1 request is needed.
|
|
3638
3646
|
// Would be better to not use this delay but we're on a clock.
|
|
@@ -3655,6 +3663,7 @@ var EntityFilterGetter;
|
|
|
3655
3663
|
return;
|
|
3656
3664
|
}
|
|
3657
3665
|
const cells = this.cells.GetCellsForView(this.viewRect);
|
|
3666
|
+
(_a = this.onScanUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(cells);
|
|
3658
3667
|
let curCellIndex = cells.length > 0 ? 0 : null;
|
|
3659
3668
|
let postedScanning = false;
|
|
3660
3669
|
let postedLoading = false;
|
|
@@ -3675,6 +3684,7 @@ var EntityFilterGetter;
|
|
|
3675
3684
|
if (!cells[curCellIndex]) {
|
|
3676
3685
|
curCellIndex = null;
|
|
3677
3686
|
}
|
|
3687
|
+
(_b = this.onScanUpdate) === null || _b === void 0 ? void 0 : _b.Trigger(cells);
|
|
3678
3688
|
continue;
|
|
3679
3689
|
}
|
|
3680
3690
|
try {
|
|
@@ -3691,20 +3701,22 @@ var EntityFilterGetter;
|
|
|
3691
3701
|
break;
|
|
3692
3702
|
}
|
|
3693
3703
|
if (page) {
|
|
3694
|
-
(
|
|
3704
|
+
(_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger(page);
|
|
3695
3705
|
}
|
|
3696
3706
|
if (!postedLoading) {
|
|
3697
3707
|
this.postStatus({ msg: EStatus.Loading, revoking: false });
|
|
3698
3708
|
postedLoading = true;
|
|
3699
3709
|
}
|
|
3710
|
+
// Only mark as fetched when ALL pages are done.
|
|
3700
3711
|
if (page.length <= 0) {
|
|
3701
|
-
curCell.Fetched = true;
|
|
3712
|
+
curCell.Fetched = true;
|
|
3713
|
+
(_d = this.onScanUpdate) === null || _d === void 0 ? void 0 : _d.Trigger(cells);
|
|
3702
3714
|
continue;
|
|
3703
3715
|
}
|
|
3704
3716
|
// Checking to make sure it's not just the same batch over and over again.
|
|
3705
3717
|
if (page.length > 0) {
|
|
3706
|
-
const first = (
|
|
3707
|
-
const last = (
|
|
3718
|
+
const first = (_f = (_e = page[0]) === null || _e === void 0 ? void 0 : _e.Bruce) === null || _f === void 0 ? void 0 : _f.ID;
|
|
3719
|
+
const last = (_h = (_g = page[page.length - 1]) === null || _g === void 0 ? void 0 : _g.Bruce) === null || _h === void 0 ? void 0 : _h.ID;
|
|
3708
3720
|
if (prevFirstId == first && prevLastId == last) {
|
|
3709
3721
|
break;
|
|
3710
3722
|
}
|
|
@@ -4646,7 +4658,18 @@ var ProjectViewBookmark;
|
|
|
4646
4658
|
const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
4647
4659
|
try {
|
|
4648
4660
|
const data = yield api.GET(`ui.view/${viewId}/slides`, Api.PrepReqParams(reqParams));
|
|
4649
|
-
|
|
4661
|
+
const items = data.Items ? data.Items : [];
|
|
4662
|
+
// Cache individual items.
|
|
4663
|
+
// Maybe better to load list cache when getting 1 slide and seeing if it's in there.
|
|
4664
|
+
// WARNING: Right now the data matches, in the future the list may contain a shortened result.
|
|
4665
|
+
for (let i = 0; i < items.length; i++) {
|
|
4666
|
+
const item = items[i];
|
|
4667
|
+
const prom = new Promise((res) => {
|
|
4668
|
+
res(item);
|
|
4669
|
+
});
|
|
4670
|
+
api.Cache.Set(GetCacheKey(viewId, item.ID), prom, Api.DEFAULT_CACHE_DURATION);
|
|
4671
|
+
}
|
|
4672
|
+
res(items);
|
|
4650
4673
|
}
|
|
4651
4674
|
catch (e) {
|
|
4652
4675
|
rej(e);
|