mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-23 21:25:12 +00:00
Make ionosonde_data a map keyed by URSI, and on polling the website, replace data for the specific URSI rather than overwriting everything. This allows us to preserve data from an older lookup if the website is down or returns nothing
This commit is contained in:
@@ -15,7 +15,7 @@ info:
|
||||
|
||||
### 1.4
|
||||
|
||||
* `/solar` response now includes `ionosonde_data`, a list of ionosonde station measurements (foF2 and MUF) sourced from the GIRO Data Center.
|
||||
* `/solar` response now includes `ionosonde_data`, which contains ionosonde station measurements (foF2 and MUF) sourced from the GIRO Data Center.
|
||||
|
||||
### 1.3
|
||||
|
||||
@@ -1688,13 +1688,13 @@ components:
|
||||
description: Electron flux impact description, derived from electron flux level.
|
||||
example: "No impact"
|
||||
ionosonde_data:
|
||||
type: array
|
||||
type: object
|
||||
nullable: true
|
||||
description: >
|
||||
Ionosonde measurements from the GIRO Data Center, covering active stations listed in the
|
||||
system. Only stations for which data was successfully retrieved are included. Null if the
|
||||
GIROIonosonde provider has not yet completed its first poll.
|
||||
items:
|
||||
Ionosonde measurements from the GIRO Data Center, keyed by URSI station code. Only
|
||||
stations for which data was successfully retrieved are included. Null if the
|
||||
GIROIonosonde provider has not yet completed its first poll or if this data source is disabled.
|
||||
additionalProperties:
|
||||
$ref: '#/components/schemas/IonosondeStation'
|
||||
|
||||
IonosondeStation:
|
||||
|
||||
@@ -115,7 +115,7 @@ function loadSolarConditions() {
|
||||
|
||||
// Ionosonde
|
||||
|
||||
if (jsonData.ionosonde_data && jsonData.ionosonde_data.length > 0) {
|
||||
if (jsonData.ionosonde_data && Object.keys(jsonData.ionosonde_data).length > 0) {
|
||||
ionosondeData = jsonData.ionosonde_data;
|
||||
populateIonosondeDropdown(ionosondeData);
|
||||
renderIonosondeData();
|
||||
@@ -366,9 +366,12 @@ function populateIonosondeDropdown(data) {
|
||||
const savedUrsi = localStorage.getItem('#ionosonde-station:value');
|
||||
const savedValue = savedUrsi ? JSON.parse(savedUrsi) : null;
|
||||
select.empty();
|
||||
data.forEach(function (station) {
|
||||
// Sort by station name rather than URSI because station name is what's displayed, and any out-of-order names might
|
||||
// confuse the user
|
||||
Object.values(data).sort((a, b) => a.name.localeCompare(b.name)).forEach(function (station) {
|
||||
select.append($('<option>', {value: station.ursi, text: station.name}));
|
||||
});
|
||||
// Select one by default if the user's localStorage has an existing selection for this
|
||||
if (savedValue && select.find('option[value="' + savedValue + '"]').length) {
|
||||
select.val(savedValue);
|
||||
}
|
||||
@@ -381,9 +384,7 @@ function renderIonosondeData() {
|
||||
if (!ionosondeData) return;
|
||||
const ursi = $('#ionosonde-station').val();
|
||||
if (!ursi) return;
|
||||
const station = ionosondeData.find(function (s) {
|
||||
return s.ursi === ursi;
|
||||
});
|
||||
const station = ionosondeData[ursi];
|
||||
if (!station) return;
|
||||
|
||||
// Set up some styles, matching the k-index chart. We use Bootstrap's "primary" and "danger" colours not for any
|
||||
|
||||
Reference in New Issue
Block a user