Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5559,7 +5559,6 @@ app.get('/api/wspr/heatmap', async (req, res) => {
}
});


// ============================================
// SATELLITE TRACKING API
// ============================================
Expand All @@ -5575,8 +5574,8 @@ const HAM_SATELLITES = {
'PO-101': { norad: 43678, name: 'PO-101 (Diwata-2)', color: '#ff3399', priority: 1, mode: 'FM' },

// Weather Satellites - GOES & METEOR
//'GOES-18': { norad: 51850, name: 'GOES-18', color: '#66ff66', priority: 1, mode: 'GRB/HRIT/LRIT' },
//'GOES-19': { norad: 60133, name: 'GOES-19', color: '#33cc33', priority: 1, mode: 'GRB/HRIT/LRIT' },
'GOES-18': { norad: 51850, name: 'GOES-18', color: '#66ff66', priority: 1, mode: 'GRB/HRIT/LRIT' },
'GOES-19': { norad: 60133, name: 'GOES-19', color: '#33cc33', priority: 1, mode: 'GRB/HRIT/LRIT' },
'METEOR-M2-3': { norad: 57166, name: 'METEOR M2-3', color: '#FF0000', priority: 1, mode: 'HRPT/LRPT' },
'METEOR-M2-4': { norad: 59051, name: 'METEOR M2-4', color: '#FF0000', priority: 1, mode: 'HRPT/LRPT' },
'SUOMI-NPP': { norad: 37849, name: 'SUOMI NPP', color: '#0000FF', priority: 2, mode: 'HRD/SMD' },
Expand Down Expand Up @@ -5636,18 +5635,34 @@ const HAM_SATELLITES = {
'SSTV-ISS': { norad: 25544, name: 'ISS SSTV', color: '#00ffff', priority: 2, mode: 'SSTV' }
};

// Cache for TLE data (refresh every 6 hours)
let tleCache = { data: null, timestamp: 0 };
const TLE_CACHE_DURATION = 6 * 60 * 60 * 1000; // 6 hours
const OFFLINE_MODE = false; // Set to false when you want live data again

app.get('/api/satellites/tle', async (req, res) => {
try {
const now = Date.now();
// Return cached data if fresh (6-hour window)
const backupFilePath = path.join(__dirname, 'tle_backup.txt'); // Define this first

// 1. Return memory cache if fresh
if (tleCache.data && (now - tleCache.timestamp) < TLE_CACHE_DURATION) {
return res.json(tleCache.data);
}

// 2. OFFLINE TESTING BLOCK
if (OFFLINE_MODE && fs.existsSync(backupFilePath)) {
logInfo('[Satellites] Loading OFFLINE cache from tle_backup.txt');
const fileContent = fs.readFileSync(backupFilePath, 'utf8');
const parsedData = JSON.parse(fileContent);

tleCache = { data: parsedData, timestamp: now };
return res.json(parsedData);
}

// C. Live Fetching (Only runs if OFFLINE_MODE is false or file is missing)
logDebug('[Satellites] Fetching fresh TLE data from CelesTrak...');

// --- COMMENT OUT THE START OF THE FETCH LOGIC IF TESTING SO AS TO NOT PULL FROM CELSTRACK TOO OFTEN AND const OFFLINE_MODE = false; // Set to false when you want live data again ---
logDebug('[Satellites] Fetching fresh TLE data from multiple groups...');
const tleData = {}; // Declare this exactly once to avoid SyntaxErrors

Expand Down Expand Up @@ -5727,6 +5742,7 @@ app.get('/api/satellites/tle', async (req, res) => {
}

tleCache = { data: tleData, timestamp: now };
// --- END OF COMMENTED OUT FETCH LOGIC ---
res.json(tleData);
} catch (error) {
// Return stale cache or empty if everything fails
Expand Down
67 changes: 67 additions & 0 deletions src/plugins/layers/satellite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
🛰 Satellite Tracks Plugin
Version: 1.0.0

Last Updated: 2026-02-16

Category: Satellites

Contributor: Carl Reinemann, USRadioguy.com

Data Source: Internal TLE API / satellite.js

Overview
The Satellite Tracks plugin provides high-performance, real-time orbital tracking and visualization for the OpenHamClock interface. It uses on-device orbital propagation to calculate precise positions, helping operators predict passes and monitor satellite telemetry in a dedicated data window.

🌟 Features
Core Capabilities
Real-time Propagation: Calculates satellite positions locally using satellite.js and TLE data fetched every 60 seconds.

Orbital Predictions: Displays predicted future paths (Lead Tracks) and historical paths (Tail Tracks).

Dynamic Footprints: Renders real-time ground station line-of-sight footprints that change color based on visibility.

Interactive Tracking: Click any satellite icon to "pin" it, highlighting its specific orbit and opening the telemetry window.

Data Visualization
Floating Data Window: A dedicated UI displaying real-time Altitude, Azimuth, Elevation, Range, and Mode.

Visual Alerts: Satellites currently above the horizon feature a "Visible" blinking indicator.

Geo-Replication: Ensures tracks and markers render seamlessly across the international date line.

Dual Unit Support: Toggle between Imperial (miles) and Metric (kilometers) for all distance data.

📊 Data Details
Data Source
Provider: Internal API (/api/satellites/tle).

Propagation Library: satellite.js (SGP4/SDP4).

Update Frequency: TLE data and orbital paths refresh every 1 minute.

Visual Refresh: Dynamic rendering updates on every state or config change.

Technical Specs
Lead Time: Default 45-minute future prediction.

Tail Time: Default 15-minute historical path.

Z-Index: Prioritizes pinned satellites at 10,000 to stay above other map layers.

🎯 Use Cases
Pass Prediction: Use the yellow dashed lead tracks to visualize exactly where a satellite will be in the next 45 minutes.

Antenna Aiming: Monitor real-time Azimuth and Elevation in the floating window for precise ground station alignment.

Visual Observation: Identify "Visible" satellites that are currently above the horizon for optical tracking or radio contact.

Footprint Analysis: Determine if a specific location falls within a satellite's current reception footprint.

🔧 Usage
Enable Plugin: Open Settings → Map Layers and toggle 🛰 Satellite Tracks.

Pin a Satellite: Click on any satellite icon on the map to open the focused data window.

Configure Views: Use the config sliders to adjust Lead/Tail track lengths and toggle footprints.

Close Data Window: Click the red "×" in the telemetry window or click the satellite again to unpin.
Loading