How harvey-andrew/trajectory-roaming works
Project Type and Purpose
• This is a single‐page front-end application built with Vue.js and Vite, focused on 3D map visualization using Cesium.js.
• It loads bus stop and trajectory data (load.json), renders a Cesium map with AMap imagery, animates vehicles along routes, and provides UI controls (play/pause, speed, perspective).
High-Level Components
a. Entry Point & Build
• index.html – loads the app shell
• vite.config.js & pnpm-lock.yaml – build/config tooling
• package.json – dependencies (vue, cesium, turf, tailwindcss)
b. Bootstrapping
• src/main.js – creates Vue app, injects global CSS
• src/App.vue – root component orchestrating map + panels
c. UI Components
• src/components/Popup.vue – informational overlays (“bubble windows”)
• src/components/PopupCar.vue – vehicle-specific popups
• Tailwind CSS – styling via tailwind.config.js + postcss.config.js
d. API Layer
• src/api/request.js – base HTTP request wrapper (fetch/axios)
• src/api/houseApi/index.js, buildApi/index.js – specific endpoints (if used)
e. Cesium Map & Tools
• src/tool/*.js – utility modules for:
– bubbleCar.js (popup logic)
– cesiumToZh.js (coordinate transforms)
– load3D.js (model loading)
– trajectory.js (path/time sampling)
f. Static Assets
Data Flow & Interactions
1. On load, App.vue calls initData():
– fetch load.json via request.js
– parse trajectory points & stations
– convert to Cesium.Cartesian3 positions
2. Cesium Initialization:
– Cesium.Viewer ‹imageryProvider› gets AMap tiles
– apply filterColor to adjust map appearance
3. Render Layers:
– load3D.js: add station models & bus entity with orientationController
– trajectory.js: compute siteTimes & Clock samples for vehicle animation
4. UI Controls:
– user events in PopupCar.vue trigger Cesium Clock (start, pause, reset)
– speed adjustments recompute siteTimes → update Clock.stopTime
– viewpoint switches:
• free view: viewer.trackedEntity = null;
• follow view: viewer.trackedEntity = busEntity;
• in-car view: camera.lookAtTransform(… computed transform)
5. External Services:
– AMap tile server (Cesium.UrlTemplateImageryProvider)
– (Optional) houseApi, buildApi endpoints for remote data
Architectural Patterns & Principles
• Separation of Concerns:
• UI (Vue components) vs. Data (API modules) vs. Map logic (tool modules)
• Single Source of Truth:
• Vue reactive state for control panel, current index, play state
• Modular Utilities:
• trajectory.js for time/distance computation;
• turf.js via dependency for lineSlice logic
Final Advice
• Be exhaustive: capture all 6 tool modules + 2 API modules + 2 UI components
• Keep labels concise but specific (e.g., “trajectory.js: compute time samples”)