mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
refactor(streetLevel,traffic,transit,firms,installations,radio,bikeshare,cables,detection): take vector maths from src/geo
Street level view/cameraFollow/groundClick/index, traffic footprint/viewport/ingestion, transit viewport/trails/state/rendering, FIRMS state/viewport, installations controls/viewport/state, radio queries/navigation/state, bikeshare viewport, submarine cable overlay and data/detection now use src/geo for Math, Cartesian2/3, Cartographic and WGS84 maths. Cesium stays for Rectangle, Ray, BoundingSphere, HeadingPitchRange, EasingFunction, EllipsoidGeodesic, EllipsoidalOccluder and the Ellipsoids passed into Cesium (pickEllipsoid, occluders). traffic/state.js keeps its Cesium lerp scratch (written per frame by Cesium.Cartesian3.lerp in animation.js; a geo scratch cost +4-7% there) and traffic/timing.js stays on Cesium (a test keeps it source-equivalent to model.parseRoads, outside this batch). street-level-layer, traffic-layer, installations-layer, bikeshare-layer and submarine-cables own the src/geo files.
This commit is contained in:
1 parent
a915bdb3e5
commit
e3061872cc
23 files changed
+231
-162
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import {
|
||||
HORIZON_CAMERA_MOVE_EPSILON_M,
|
||||
GLOBAL_RADIO_ALTITUDE_M,
|
||||
@@ -178,15 +179,13 @@ export function createNavigation({
|
||||
);
|
||||
} else {
|
||||
const earthRadius = earthDiscScreenRadius(
|
||||
Cesium.Cartesian3.magnitude(camera.positionWC),
|
||||
geo.cartesian3.magnitude(camera.positionWC),
|
||||
height,
|
||||
camera.frustum?.fovy,
|
||||
);
|
||||
const facingEarthCenter =
|
||||
Cesium.Cartesian3.dot(
|
||||
camera.directionWC,
|
||||
layerState._radioEarthToCenter,
|
||||
) > 0;
|
||||
geo.cartesian3.dot(camera.directionWC, layerState._radioEarthToCenter) >
|
||||
0;
|
||||
if (!earthRadius || facingEarthCenter) return null;
|
||||
const keyhole = getKeyholeGeometry(width, height);
|
||||
fullGlobeCapable =
|
||||
@@ -198,7 +197,7 @@ export function createNavigation({
|
||||
);
|
||||
if (recenterHeight == null) return null;
|
||||
return {
|
||||
destination: Cesium.Cartesian3.fromRadians(
|
||||
destination: geo.cartesian3.fromRadians(
|
||||
cartographic.longitude,
|
||||
cartographic.latitude,
|
||||
recenterHeight,
|
||||
@@ -207,7 +206,7 @@ export function createNavigation({
|
||||
...radioCameraState(camera),
|
||||
height: recenterHeight,
|
||||
heading: 0,
|
||||
pitch: -Cesium.Math.PI_OVER_TWO,
|
||||
pitch: -geo.math.PI_OVER_TWO,
|
||||
roll: 0,
|
||||
},
|
||||
};
|
||||
@@ -280,7 +279,7 @@ export function createNavigation({
|
||||
return startRadioCameraFlight(
|
||||
navigation,
|
||||
{
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
destination: geo.cartesian3.fromDegrees(
|
||||
plan.lon,
|
||||
plan.lat,
|
||||
plan.height,
|
||||
@@ -364,11 +363,7 @@ export function createNavigation({
|
||||
return false;
|
||||
cancelActiveRadioCameraFlight();
|
||||
layerState._viewer.camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(
|
||||
station.lon,
|
||||
station.lat,
|
||||
85_000,
|
||||
),
|
||||
destination: geo.cartesian3.fromDegrees(station.lon, station.lat, 85_000),
|
||||
duration: 1.1,
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import { normalizeRadioCountryInput } from '../../data/radioCountry.js';
|
||||
|
||||
export function createQueries({ state: layerState, services, parts, source }) {
|
||||
function radioAngularDistance(station, anchor) {
|
||||
const lat1 = Cesium.Math.toRadians(Number(anchor?.lat));
|
||||
const lon1 = Cesium.Math.toRadians(Number(anchor?.lon));
|
||||
const lat2 = Cesium.Math.toRadians(Number(station?.lat));
|
||||
const lon2 = Cesium.Math.toRadians(Number(station?.lon));
|
||||
const lat1 = geo.math.toRadians(Number(anchor?.lat));
|
||||
const lon1 = geo.math.toRadians(Number(anchor?.lon));
|
||||
const lat2 = geo.math.toRadians(Number(station?.lat));
|
||||
const lon2 = geo.math.toRadians(Number(station?.lon));
|
||||
if (![lat1, lon1, lat2, lon2].every(Number.isFinite))
|
||||
return Number.POSITIVE_INFINITY;
|
||||
const deltaLat = lat2 - lat1;
|
||||
@@ -113,7 +114,7 @@ export function createQueries({ state: layerState, services, parts, source }) {
|
||||
let cartographic = null;
|
||||
const canvas = scene?.canvas;
|
||||
if (canvas && typeof camera.pickEllipsoid === 'function') {
|
||||
const center = new Cesium.Cartesian2(
|
||||
const center = geo.cartesian2.create(
|
||||
canvas.clientWidth / 2,
|
||||
canvas.clientHeight / 2,
|
||||
);
|
||||
@@ -121,13 +122,13 @@ export function createQueries({ state: layerState, services, parts, source }) {
|
||||
center,
|
||||
scene.globe?.ellipsoid || Cesium.Ellipsoid.WGS84,
|
||||
);
|
||||
if (position) cartographic = Cesium.Cartographic.fromCartesian(position);
|
||||
if (position) cartographic = geo.cartographic.fromCartesian(position);
|
||||
}
|
||||
cartographic ||= camera.positionCartographic || null;
|
||||
if (!cartographic) return null;
|
||||
return {
|
||||
lat: Cesium.Math.toDegrees(cartographic.latitude),
|
||||
lon: Cesium.Math.toDegrees(cartographic.longitude),
|
||||
lat: geo.math.toDegrees(cartographic.latitude),
|
||||
lon: geo.math.toDegrees(cartographic.longitude),
|
||||
altitudeM,
|
||||
globalView: parts.navigation.radioViewIsGlobal(altitudeM),
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import {
|
||||
EMPTY_ACCEPTED_CATALOG_SNAPSHOT,
|
||||
DEFAULT_RADIO_FILTER,
|
||||
@@ -8,9 +8,9 @@ import {
|
||||
export function createState({ services }) {
|
||||
const layerState = {};
|
||||
|
||||
layerState._radioEarthScreenCenter = new Cesium.Cartesian2();
|
||||
layerState._radioEarthScreenCenter = geo.cartesian2.create();
|
||||
|
||||
layerState._radioEarthToCenter = new Cesium.Cartesian3();
|
||||
layerState._radioEarthToCenter = geo.cartesian3.create();
|
||||
|
||||
layerState._viewer = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user