mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Merge remote-tracking branch 'origin/main' into german/cctv-camera-counts
# Conflicts: # src/layers/cctv/lifecycle.test.mjs
This commit is contained in:
commit
2b7a6b0c63
1463 files changed
+48705
-10313
No files matched your search
@@ -12,14 +12,20 @@ export function createNavigation({
|
||||
source,
|
||||
}) {
|
||||
/**
|
||||
* Finds the camera closest to the viewer's current position.
|
||||
* @returns {string|null} Camera ID of the nearest camera, or null.
|
||||
* Nearest catalog camera to a WGS84 point.
|
||||
* @param {number} lat Latitude in degrees.
|
||||
* @param {number} lon Longitude in degrees.
|
||||
* @returns {string|null} Camera ID, or null (invalid point, empty catalog).
|
||||
*/
|
||||
|
||||
function nearestCameraIdToViewer() {
|
||||
const pose = parts.model.eyePose();
|
||||
if (!pose || !layerState._records.length) return null;
|
||||
const { lat, lon } = pose;
|
||||
function nearestCameraIdToPoint(lat, lon) {
|
||||
if (
|
||||
!Number.isFinite(lat) ||
|
||||
!Number.isFinite(lon) ||
|
||||
Math.abs(lat) > 90 ||
|
||||
Math.abs(lon) > 180 ||
|
||||
!layerState._records.length
|
||||
)
|
||||
return null;
|
||||
|
||||
let best = null;
|
||||
for (const record of layerState._records) {
|
||||
@@ -36,6 +42,16 @@ export function createNavigation({
|
||||
return best?.id || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the camera closest to the viewer's current position.
|
||||
* @returns {string|null} Camera ID of the nearest camera, or null.
|
||||
*/
|
||||
function nearestCameraIdToViewer() {
|
||||
const pose = parts.model.eyePose();
|
||||
if (!pose) return null;
|
||||
return nearestCameraIdToPoint(pose.lat, pose.lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* The camera the layer opens on when none is selected: the one nearest the
|
||||
* viewer, or the first record when the viewer has no position yet.
|
||||
@@ -214,6 +230,7 @@ export function createNavigation({
|
||||
return (((Math.floor(currentIdx) + delta) % total) + total) % total;
|
||||
}
|
||||
return {
|
||||
nearestCameraIdToPoint,
|
||||
nearestCameraIdToViewer,
|
||||
openingCameraId,
|
||||
reopenNearestCamera,
|
||||
|
||||
Reference in new issue
Block a user