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';
|
||||
|
||||
export function createFirmsState({ services, config }) {
|
||||
const layerState = {};
|
||||
@@ -9,11 +10,11 @@ export function createFirmsState({ services, config }) {
|
||||
|
||||
layerState.scratchViewRect = new Cesium.Rectangle();
|
||||
|
||||
layerState.scratchCenterA = new Cesium.Cartographic();
|
||||
layerState.scratchCenterA = geo.cartographic.create();
|
||||
|
||||
layerState.scratchCenterB = new Cesium.Cartographic();
|
||||
layerState.scratchCenterB = geo.cartographic.create();
|
||||
|
||||
layerState.scratchWindowCoord = new Cesium.Cartesian2();
|
||||
layerState.scratchWindowCoord = geo.cartesian2.create();
|
||||
|
||||
layerState._viewer = null;
|
||||
|
||||
@@ -107,9 +108,9 @@ export function createFirmsState({ services, config }) {
|
||||
|
||||
layerState._camSnapValid = false;
|
||||
|
||||
layerState._camPos = new Cesium.Cartesian3();
|
||||
layerState._camPos = geo.cartesian3.create();
|
||||
|
||||
layerState._camDir = new Cesium.Cartesian3();
|
||||
layerState._camDir = geo.cartesian3.create();
|
||||
layerState.request = null;
|
||||
return layerState;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import {
|
||||
LOD_LEVELS,
|
||||
LOD_HYSTERESIS,
|
||||
@@ -122,7 +123,7 @@ export function createViewport({
|
||||
const center = Cesium.Rectangle.center(viewRect, layerState.scratchCenterB);
|
||||
const latShift = Math.abs(center.latitude - lastCenter.latitude);
|
||||
let lonShift = Math.abs(center.longitude - lastCenter.longitude);
|
||||
if (lonShift > Math.PI) lonShift = Cesium.Math.TWO_PI - lonShift;
|
||||
if (lonShift > Math.PI) lonShift = geo.math.TWO_PI - lonShift;
|
||||
return (
|
||||
latShift > lastHeight * VIEW_PADDING * 0.6 ||
|
||||
lonShift > lastWidth * VIEW_PADDING * 0.6
|
||||
@@ -159,13 +160,13 @@ export function createViewport({
|
||||
const camera = layerState._viewer.camera;
|
||||
if (
|
||||
layerState._camSnapValid &&
|
||||
Cesium.Cartesian3.equalsEpsilon(
|
||||
geo.cartesian3.equalsEpsilon(
|
||||
camera.positionWC,
|
||||
layerState._camPos,
|
||||
0,
|
||||
0.5,
|
||||
) &&
|
||||
Cesium.Cartesian3.equalsEpsilon(
|
||||
geo.cartesian3.equalsEpsilon(
|
||||
camera.directionWC,
|
||||
layerState._camDir,
|
||||
0,
|
||||
@@ -174,8 +175,8 @@ export function createViewport({
|
||||
) {
|
||||
return;
|
||||
}
|
||||
Cesium.Cartesian3.clone(camera.positionWC, layerState._camPos);
|
||||
Cesium.Cartesian3.clone(camera.directionWC, layerState._camDir);
|
||||
geo.cartesian3.clone(camera.positionWC, layerState._camPos);
|
||||
geo.cartesian3.clone(camera.directionWC, layerState._camDir);
|
||||
layerState._camSnapValid = true;
|
||||
// The camera moved, so the horizon moved. A rebuild culls its own fresh
|
||||
// sprites (renderDetections); an early-out — same LOD band and view
|
||||
|
||||
Reference in new issue
Block a user