fix(launches): keep null pad and landing coordinates unknown instead of 0

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Rudy Celekli <[email protected]>
This commit is contained in:
Rudy CelekliandClaude Sonnet 5.5 committed 2026-10-16 15:24:08 -04:00
1 parent e8b3a10a07
commit 0d8caaafd8
3 files changed
+37 -9

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# Changelog # Changelog
- Launch Library records with a null or blank pad latitude/longitude, landing
position, downrange distance or stage flight number now keep those values
unknown instead of reading them as 0, so a launch is no longer placed at
0°N 0°E and an undisclosed landing no longer reports a 0 km downrange.
- Local FM seek finds stations after wrapping around 87.5–108 MHz, covers both - Local FM seek finds stations after wrapping around 87.5–108 MHz, covers both
band edges, skips the starting station and rejects spectra from an earlier band edges, skips the starting station and rejects spectra from an earlier
tune (Aditya, @Rohilalala, #1174). tune (Aditya, @Rohilalala, #1174).
+25
View File
@@ -676,6 +676,31 @@ test('uses Launch Library 2 pad latitude/longitude fields', () => {
assert.equal(launches[0].lon, -120.611); assert.equal(launches[0].lon, -120.611);
}); });
test('null or blank pad and landing coordinates stay unknown instead of becoming 0', () => {
const base = { net: '2026-07-20T10:00:00Z' };
for (const blank of [null, '', ' ', false]) {
assert.deepEqual(
normalizeRocketLaunches([{ ...base, id: 'blank', pad: { latitude: blank, longitude: blank } }], NOW),
[],
);
}
// Null pad fields fall through to the location's "lon,lat" pair, not 0,0.
const [fallback] = normalizeRocketLaunches([{ ...base, id: 'fallback',
pad: { latitude: null, longitude: null, location: { coordinates: '-80.6,28.6' } } }], NOW);
assert.equal(fallback.lat, 28.6);
assert.equal(fallback.lon, -80.6);
// An undisclosed landing keeps position, distance and flight number unknown.
const [launch] = normalizeRocketLaunches([{ ...base, id: 'landing', pad: { latitude: 1, longitude: 2 },
rocket: { launcher_stage: [{ launcher_flight_number: null,
landing: { attempt: true, downrange_distance: null,
landing_location: { latitude: null, longitude: null } } }] } }], NOW);
const [stage] = launch.recoveryStages;
assert.equal(stage.lat, null);
assert.equal(stage.lon, null);
assert.equal(stage.downrangeKm, null);
assert.equal(stage.flightNumber, null);
});
test('normalizes detailed payload and stage recovery records', () => { test('normalizes detailed payload and stage recovery records', () => {
const launches = normalizeRocketLaunches({ results: [{ const launches = normalizeRocketLaunches({ results: [{
id: 'recovery-details', id: 'recovery-details',
+8 -9
View File
@@ -10,6 +10,9 @@ export const UNKNOWN_LAUNCH_STATUS = msg('Unknown');
export function createModel({ state: layerState, services, parts, source }) { export function createModel({ state: layerState, services, parts, source }) {
function finiteCoordinate(value) { function finiteCoordinate(value) {
// Number(null), Number('') and Number(false) are 0: absent is not zero.
if (value == null || typeof value === 'boolean') return null;
if (typeof value === 'string' && value.trim() === '') return null;
const number = Number(value); const number = Number(value);
return Number.isFinite(number) ? number : null; return Number.isFinite(number) ? number : null;
} }
@@ -184,15 +187,11 @@ export function createModel({ state: layerState, services, parts, source }) {
const pad = launch.pad || {}; const pad = launch.pad || {};
const location = pad.location || {}; const location = pad.location || {};
const coordinates = location.coordinates || ''; const coordinates = location.coordinates || '';
const [coordinateLon, coordinateLat] = String(coordinates) const [coordinateLon, coordinateLat] = String(coordinates).split(',');
.split(',') const lat =
.map(Number); finiteCoordinate(pad.latitude) ?? finiteCoordinate(coordinateLat);
const lat = Number.isFinite(Number(pad.latitude)) const lon =
? Number(pad.latitude) finiteCoordinate(pad.longitude) ?? finiteCoordinate(coordinateLon);
: coordinateLat;
const lon = Number.isFinite(Number(pad.longitude))
? Number(pad.longitude)
: coordinateLon;
const payloads = normalizePayloadFlights(launch); const payloads = normalizePayloadFlights(launch);
return { return {
id: String( id: String(