bruce-models 2.1.1 → 2.1.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.
- package/dist/bruce-models.es5.js +48 -79
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +48 -79
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/entity/getters/entity-filter-getter.js +14 -4
- package/dist/lib/entity/getters/entity-filter-getter.js.map +1 -1
- package/dist/lib/entity/getters/entity-globe.js +33 -69
- package/dist/lib/entity/getters/entity-globe.js.map +1 -1
- package/dist/types/entity/getters/entity-globe.d.ts +4 -4
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -6986,6 +6986,7 @@
|
|
|
6986
6986
|
this.IsFetched = null;
|
|
6987
6987
|
this.FetchPageIndex = 0;
|
|
6988
6988
|
this.Boundaries = null;
|
|
6989
|
+
this.Fetching = false;
|
|
6989
6990
|
}
|
|
6990
6991
|
GetBounds() {
|
|
6991
6992
|
// Entity data works in -180 to 180 range.
|
|
@@ -7012,93 +7013,51 @@
|
|
|
7012
7013
|
class Grid {
|
|
7013
7014
|
constructor() {
|
|
7014
7015
|
this.cells = {};
|
|
7015
|
-
this.patches = [];
|
|
7016
7016
|
}
|
|
7017
|
-
GetCellsForView(viewRect) {
|
|
7017
|
+
GetCellsForView(cameraPos, viewRect) {
|
|
7018
|
+
const cells = [];
|
|
7019
|
+
const minLat = viewRect.south;
|
|
7020
|
+
const minLon = viewRect.west;
|
|
7021
|
+
const maxLat = viewRect.north;
|
|
7022
|
+
const maxLon = viewRect.east;
|
|
7018
7023
|
const MAX_CELLS = 150;
|
|
7019
|
-
const { south: minLat, west: minLon, north: maxLat, east: maxLon } = viewRect;
|
|
7020
7024
|
const cellDegreeSize = getCellSizeFromHeight(viewRect.alt);
|
|
7021
|
-
const
|
|
7022
|
-
const
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
const [id, cell] = getOrCreateCell(this.cells, cellDegreeSize, lon1, lon2, lat1, lat2);
|
|
7033
|
-
/*
|
|
7034
|
-
{
|
|
7035
|
-
const cell_bounds = { south: lat1, west: lon1, north: lat2, east: lon2 };
|
|
7036
|
-
const subcells = [];
|
|
7037
|
-
for (const id of intersections) {
|
|
7038
|
-
const c = this.cells[id].GetBounds();
|
|
7039
|
-
if (contains(c, cell_bounds)) {
|
|
7040
|
-
cell.Fetched = true;
|
|
7041
|
-
return;
|
|
7042
|
-
}
|
|
7043
|
-
if (intersects(c, cell_bounds)) {
|
|
7044
|
-
const cropped = crop(c, cell.GetBounds());
|
|
7045
|
-
subcells.push(cropped);
|
|
7046
|
-
}
|
|
7047
|
-
}
|
|
7048
|
-
let filled = 0;
|
|
7049
|
-
while (subcells.length > 0) {
|
|
7050
|
-
const c = subcells.pop();
|
|
7051
|
-
filled += area(c);
|
|
7052
|
-
for (const s of subcells) {
|
|
7053
|
-
filled -= intersection(s, c);
|
|
7054
|
-
}
|
|
7055
|
-
}
|
|
7056
|
-
if (filled + Number.EPSILON * 2 > area(cell.GetBounds())) {
|
|
7057
|
-
cell.Fetched = true;
|
|
7058
|
-
return;
|
|
7059
|
-
}
|
|
7060
|
-
|
|
7061
|
-
let [x2, y2] = max;
|
|
7062
|
-
x2 = Math.max(x2, lon2);
|
|
7063
|
-
y2 = Math.max(y2, lat2);
|
|
7064
|
-
max = [x2, y2];
|
|
7065
|
-
}
|
|
7066
|
-
*/
|
|
7067
|
-
ids.push(id);
|
|
7068
|
-
cells.push(cell);
|
|
7069
|
-
cells[id] = cell;
|
|
7070
|
-
};
|
|
7025
|
+
const curMinLon = floorValueToCellSize(cellDegreeSize, minLon);
|
|
7026
|
+
const curMinLat = floorValueToCellSize(cellDegreeSize, minLat);
|
|
7027
|
+
let centerX = cameraPos === null || cameraPos === void 0 ? void 0 : cameraPos.longitude;
|
|
7028
|
+
let centerY = cameraPos === null || cameraPos === void 0 ? void 0 : cameraPos.latitude;
|
|
7029
|
+
if (isNaN(centerX) || isNaN(centerY)) {
|
|
7030
|
+
centerX = (minLon + maxLon) / 2;
|
|
7031
|
+
centerY = (minLat + maxLat) / 2;
|
|
7032
|
+
}
|
|
7033
|
+
const width = Math.ceil((maxLon - curMinLon) / cellDegreeSize);
|
|
7034
|
+
const height = Math.ceil((maxLat - curMinLat) / cellDegreeSize);
|
|
7035
|
+
const cellDistances = [];
|
|
7071
7036
|
for (let x = 0; x < width; x++) {
|
|
7072
7037
|
for (let y = 0; y < height; y++) {
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7038
|
+
const lon = x * cellDegreeSize + curMinLon;
|
|
7039
|
+
const lat = y * cellDegreeSize + curMinLat;
|
|
7040
|
+
const cellCenterX = lon + cellDegreeSize / 2;
|
|
7041
|
+
const cellCenterY = lat + cellDegreeSize / 2;
|
|
7042
|
+
const dist = Math.sqrt(Math.pow(cellCenterX - centerX, 2) + Math.pow(cellCenterY - centerY, 2));
|
|
7043
|
+
cellDistances.push({ x, y, dist });
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
cellDistances.sort((a, b) => a.dist - b.dist);
|
|
7047
|
+
for (const { x, y } of cellDistances) {
|
|
7048
|
+
const lon = x * cellDegreeSize + curMinLon;
|
|
7049
|
+
const lat = y * cellDegreeSize + curMinLat;
|
|
7050
|
+
const [id, cell] = getOrCreateCell(this.cells, cellDegreeSize, lon, lon + cellDegreeSize, lat, lat + cellDegreeSize);
|
|
7051
|
+
cells.push(cell);
|
|
7052
|
+
if (cells.length >= MAX_CELLS) {
|
|
7053
|
+
break;
|
|
7077
7054
|
}
|
|
7078
7055
|
}
|
|
7079
|
-
const [x2, y2] = max;
|
|
7080
|
-
if (x2 != curMinLon && y2 != curMinLat) {
|
|
7081
|
-
this.patches.push([{ west: curMinLon, east: x2, south: curMinLat, north: y2 }, ids]);
|
|
7082
|
-
}
|
|
7083
7056
|
return cells;
|
|
7084
7057
|
}
|
|
7085
|
-
intersections(withRect) {
|
|
7086
|
-
return this.patches
|
|
7087
|
-
.filter(([rect, _]) => intersects(rect, withRect))
|
|
7088
|
-
.map(([_, ids]) => ids)
|
|
7089
|
-
.reduce((all, ids) => {
|
|
7090
|
-
all.push(...ids);
|
|
7091
|
-
return all;
|
|
7092
|
-
}, []);
|
|
7093
|
-
}
|
|
7094
7058
|
}
|
|
7095
7059
|
EntityGlobe.Grid = Grid;
|
|
7096
7060
|
})(exports.EntityGlobe || (exports.EntityGlobe = {}));
|
|
7097
|
-
function intersects(l, r) {
|
|
7098
|
-
const { west: w, south: s, north: n, east: e } = l;
|
|
7099
|
-
const { west: wr, south: sr, north: nr, east: er } = r;
|
|
7100
|
-
return !(e <= wr || w >= er || n <= sr || s >= nr);
|
|
7101
|
-
}
|
|
7102
7061
|
function floorValueToCellSize(size, value) {
|
|
7103
7062
|
return Math.floor(value / size) * size;
|
|
7104
7063
|
}
|
|
@@ -7332,6 +7291,7 @@
|
|
|
7332
7291
|
let retryDelay = 0;
|
|
7333
7292
|
let prevFirstId = "";
|
|
7334
7293
|
let prevLastId = "";
|
|
7294
|
+
let prevTicks = 0;
|
|
7335
7295
|
while ((!this.viewCenter || !this.viewRect) && this.getterLoopId == loopId) {
|
|
7336
7296
|
yield delay(RETRY_DELAY_INCREMENT);
|
|
7337
7297
|
}
|
|
@@ -7342,7 +7302,7 @@
|
|
|
7342
7302
|
if (alt > MAX_HEIGHT || (alt < MIN_HEIGHT && MIN_HEIGHT > 0)) {
|
|
7343
7303
|
return;
|
|
7344
7304
|
}
|
|
7345
|
-
const cells = this.cells.GetCellsForView(this.viewRect);
|
|
7305
|
+
const cells = this.cells.GetCellsForView(this.viewCenter, this.viewRect);
|
|
7346
7306
|
(_a = this.onScanUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(cells);
|
|
7347
7307
|
let curCellIndex = cells.length > 0 ? 0 : null;
|
|
7348
7308
|
let postedScanning = false;
|
|
@@ -7361,8 +7321,12 @@
|
|
|
7361
7321
|
}
|
|
7362
7322
|
const curCell = cells[curCellIndex];
|
|
7363
7323
|
if (curCell.IsFetched()) {
|
|
7324
|
+
curCell.Fetching = false;
|
|
7364
7325
|
curCellIndex += 1;
|
|
7365
|
-
if (
|
|
7326
|
+
if (cells[curCellIndex]) {
|
|
7327
|
+
cells[curCellIndex].Fetching = true;
|
|
7328
|
+
}
|
|
7329
|
+
else {
|
|
7366
7330
|
curCellIndex = null;
|
|
7367
7331
|
}
|
|
7368
7332
|
(_b = this.onScanUpdate) === null || _b === void 0 ? void 0 : _b.Trigger(cells);
|
|
@@ -7402,6 +7366,7 @@
|
|
|
7402
7366
|
// Only mark as fetched when ALL pages are done.
|
|
7403
7367
|
if (entities.length <= 0) {
|
|
7404
7368
|
curCell.Fetched = true;
|
|
7369
|
+
curCell.Fetching = false;
|
|
7405
7370
|
(_d = this.onScanUpdate) === null || _d === void 0 ? void 0 : _d.Trigger(cells);
|
|
7406
7371
|
continue;
|
|
7407
7372
|
}
|
|
@@ -7410,11 +7375,15 @@
|
|
|
7410
7375
|
const first = (_f = (_e = entities[0]) === null || _e === void 0 ? void 0 : _e.Bruce) === null || _f === void 0 ? void 0 : _f.ID;
|
|
7411
7376
|
const last = (_h = (_g = entities[entities.length - 1]) === null || _g === void 0 ? void 0 : _g.Bruce) === null || _h === void 0 ? void 0 : _h.ID;
|
|
7412
7377
|
if (prevFirstId == first && prevLastId == last) {
|
|
7413
|
-
|
|
7378
|
+
prevTicks += 1;
|
|
7379
|
+
if (prevTicks > 3) {
|
|
7380
|
+
break;
|
|
7381
|
+
}
|
|
7414
7382
|
}
|
|
7415
7383
|
else {
|
|
7416
7384
|
prevFirstId = first;
|
|
7417
7385
|
prevLastId = last;
|
|
7386
|
+
prevTicks = 0;
|
|
7418
7387
|
}
|
|
7419
7388
|
}
|
|
7420
7389
|
curCell.FetchPageIndex++;
|
|
@@ -7423,7 +7392,7 @@
|
|
|
7423
7392
|
retryDelay = 0;
|
|
7424
7393
|
}
|
|
7425
7394
|
catch (e) {
|
|
7426
|
-
console.
|
|
7395
|
+
console.error(e);
|
|
7427
7396
|
// Request failed so let's add a delay and try again soon.
|
|
7428
7397
|
retryDelay += RETRY_DELAY_INCREMENT;
|
|
7429
7398
|
retryAttempts -= 1;
|