bruce-models 2.1.2 → 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 +25 -21
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +25 -21
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/entity/getters/entity-filter-getter.js +1 -1
- package/dist/lib/entity/getters/entity-filter-getter.js.map +1 -1
- package/dist/lib/entity/getters/entity-globe.js +24 -20
- package/dist/lib/entity/getters/entity-globe.js.map +1 -1
- package/dist/types/entity/getters/entity-globe.d.ts +3 -2
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -7120,7 +7120,7 @@ var EntityGlobe;
|
|
|
7120
7120
|
constructor() {
|
|
7121
7121
|
this.cells = {};
|
|
7122
7122
|
}
|
|
7123
|
-
GetCellsForView(viewRect) {
|
|
7123
|
+
GetCellsForView(cameraPos, viewRect) {
|
|
7124
7124
|
const cells = [];
|
|
7125
7125
|
const minLat = viewRect.south;
|
|
7126
7126
|
const minLon = viewRect.west;
|
|
@@ -7130,31 +7130,35 @@ var EntityGlobe;
|
|
|
7130
7130
|
const cellDegreeSize = getCellSizeFromHeight(viewRect.alt);
|
|
7131
7131
|
const curMinLon = floorValueToCellSize(cellDegreeSize, minLon);
|
|
7132
7132
|
const curMinLat = floorValueToCellSize(cellDegreeSize, minLat);
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7133
|
+
let centerX = cameraPos === null || cameraPos === void 0 ? void 0 : cameraPos.longitude;
|
|
7134
|
+
let centerY = cameraPos === null || cameraPos === void 0 ? void 0 : cameraPos.latitude;
|
|
7135
|
+
if (isNaN(centerX) || isNaN(centerY)) {
|
|
7136
|
+
centerX = (minLon + maxLon) / 2;
|
|
7137
|
+
centerY = (minLat + maxLat) / 2;
|
|
7138
|
+
}
|
|
7139
|
+
const width = Math.ceil((maxLon - curMinLon) / cellDegreeSize);
|
|
7140
|
+
const height = Math.ceil((maxLat - curMinLat) / cellDegreeSize);
|
|
7141
|
+
const cellDistances = [];
|
|
7137
7142
|
for (let x = 0; x < width; x++) {
|
|
7138
7143
|
for (let y = 0; y < height; y++) {
|
|
7139
7144
|
const lon = x * cellDegreeSize + curMinLon;
|
|
7140
7145
|
const lat = y * cellDegreeSize + curMinLat;
|
|
7141
|
-
const
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
+
const cellCenterX = lon + cellDegreeSize / 2;
|
|
7147
|
+
const cellCenterY = lat + cellDegreeSize / 2;
|
|
7148
|
+
const dist = Math.sqrt(Math.pow(cellCenterX - centerX, 2) + Math.pow(cellCenterY - centerY, 2));
|
|
7149
|
+
cellDistances.push({ x, y, dist });
|
|
7150
|
+
}
|
|
7151
|
+
}
|
|
7152
|
+
cellDistances.sort((a, b) => a.dist - b.dist);
|
|
7153
|
+
for (const { x, y } of cellDistances) {
|
|
7154
|
+
const lon = x * cellDegreeSize + curMinLon;
|
|
7155
|
+
const lat = y * cellDegreeSize + curMinLat;
|
|
7156
|
+
const [id, cell] = getOrCreateCell(this.cells, cellDegreeSize, lon, lon + cellDegreeSize, lat, lat + cellDegreeSize);
|
|
7157
|
+
cells.push(cell);
|
|
7158
|
+
if (cells.length >= MAX_CELLS) {
|
|
7159
|
+
break;
|
|
7146
7160
|
}
|
|
7147
7161
|
}
|
|
7148
|
-
// Sort cells so that the ones closest to the center are first
|
|
7149
|
-
cells.sort((a, b) => {
|
|
7150
|
-
const aCenterX = (a.Boundaries.minLongitude + a.Boundaries.maxLongitude) / 2;
|
|
7151
|
-
const aCenterY = (a.Boundaries.minLatitude + a.Boundaries.maxLatitude) / 2;
|
|
7152
|
-
const bCenterX = (b.Boundaries.minLongitude + b.Boundaries.maxLongitude) / 2;
|
|
7153
|
-
const bCenterY = (b.Boundaries.minLatitude + b.Boundaries.maxLatitude) / 2;
|
|
7154
|
-
const aDist = Math.sqrt(Math.pow(aCenterX - centerX, 2) + Math.pow(aCenterY - centerY, 2));
|
|
7155
|
-
const bDist = Math.sqrt(Math.pow(bCenterX - centerX, 2) + Math.pow(bCenterY - centerY, 2));
|
|
7156
|
-
return aDist - bDist;
|
|
7157
|
-
});
|
|
7158
7162
|
return cells;
|
|
7159
7163
|
}
|
|
7160
7164
|
}
|
|
@@ -7410,7 +7414,7 @@ var EntityFilterGetter;
|
|
|
7410
7414
|
if (alt > MAX_HEIGHT || (alt < MIN_HEIGHT && MIN_HEIGHT > 0)) {
|
|
7411
7415
|
return;
|
|
7412
7416
|
}
|
|
7413
|
-
const cells = this.cells.GetCellsForView(this.viewRect);
|
|
7417
|
+
const cells = this.cells.GetCellsForView(this.viewCenter, this.viewRect);
|
|
7414
7418
|
(_a = this.onScanUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(cells);
|
|
7415
7419
|
let curCellIndex = cells.length > 0 ? 0 : null;
|
|
7416
7420
|
let postedScanning = false;
|