mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Launches selection/replay/panel/policy/policyHelpers/state/camera, CCTV geometry/model/projection/navigation/cards/geometryQueue/state and ALPR model/visuals now use src/geo for Math, Cartesian2/3, Cartographic, Matrix3/4, Quaternion and ENU frames. launches/paths.js keeps Cesium (EllipsoidGeodesic). In camera.js, EllipsoidGeodesic, BoundingSphere.fromPoints/union and the BoundingSphere constructor stay on Cesium; the geo Cartographics passed into EllipsoidGeodesic are only read field by field and cloned there (computeProperties). The CCTV plane orientation stays a Cesium Quaternion and plane dimensions a Cesium Cartesian2 (entity ConstantProperty values). launches-layer and alpr-cameras own the src/geo files.
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
import * as geo from '../../geo/index.js';
|
|
import { EARTH_MEAN_RADIUS_M } from './policy.js';
|
|
export * from './records.js';
|
|
|
|
/**
|
|
* Great-circle destination point — used only to draw the short
|
|
* facing-direction line when a node carries `camera:direction`/`direction`.
|
|
* @param {number} latDeg @param {number} lonDeg
|
|
* @param {number} bearingDeg Compass bearing, degrees clockwise from north.
|
|
* @param {number} distanceM
|
|
* @returns {{latitude:number, longitude:number}}
|
|
*/
|
|
export function destinationPointDeg(latDeg, lonDeg, bearingDeg, distanceM) {
|
|
const angularDistance = distanceM / EARTH_MEAN_RADIUS_M;
|
|
const bearing = geo.math.toRadians(bearingDeg);
|
|
const lat1 = geo.math.toRadians(latDeg);
|
|
const lon1 = geo.math.toRadians(lonDeg);
|
|
const lat2 = Math.asin(
|
|
Math.sin(lat1) * Math.cos(angularDistance) +
|
|
Math.cos(lat1) * Math.sin(angularDistance) * Math.cos(bearing),
|
|
);
|
|
const lon2 =
|
|
lon1 +
|
|
Math.atan2(
|
|
Math.sin(bearing) * Math.sin(angularDistance) * Math.cos(lat1),
|
|
Math.cos(angularDistance) - Math.sin(lat1) * Math.sin(lat2),
|
|
);
|
|
return {
|
|
latitude: geo.math.toDegrees(lat2),
|
|
longitude: geo.math.toDegrees(lon2),
|
|
};
|
|
}
|
|
|
|
/** Build a linked attribution from plain text and an HTTPS URL only. */
|
|
export function alprCreditMarkup(attribution) {
|
|
if (!attribution?.text || !attribution?.href) return null;
|
|
const href = new URL(attribution.href);
|
|
if (href.protocol !== 'https:' || href.username || href.password) {
|
|
throw new TypeError('Camera attribution requires a public HTTPS link');
|
|
}
|
|
const escape = (value) =>
|
|
String(value).replace(
|
|
/[&<>"']/g,
|
|
(char) =>
|
|
({
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
})[char],
|
|
);
|
|
return `<span class="gev-alpr-credit">ALPR: <a href="${escape(href.href)}" target="_blank" rel="noopener">${escape(attribution.text)}</a></span>`;
|
|
}
|