1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

Cached database tidy up

Tidy up changes to just include the cached db functionality and TX ID algo 3 addition ready for pull
This commit is contained in:
Adam Wisher
2025-05-15 09:08:24 +01:00
parent 65fc84ff9f
commit f818262eff
5 changed files with 7 additions and 9 deletions

View File

@@ -416,8 +416,7 @@ function handleData(wss, receivedData, rdsWss) {
azi: currentTx.azimuth, azi: currentTx.azimuth,
id: currentTx.id, id: currentTx.id,
pi: currentTx.pi, pi: currentTx.pi,
reg: currentTx.reg, reg: currentTx.reg
otherMatches: currentTx.others
}; };
} }
}) })

View File

@@ -416,7 +416,7 @@ router.get('/log_fmlist', (req, res) => {
client: { client: {
request_ip: clientIp request_ip: clientIp
}, },
type: req.query.type ? req.query.type : 'tropo', type: (req.query.type && dataHandler.dataToSend.txInfo.dist > 700) ? req.query.type : 'tropo',
log_msg: "Logged PS: " + dataHandler.dataToSend.ps.replace(/\s+/g, '_') + ", PI: " + dataHandler.dataToSend.pi + ", Signal: " + (dataHandler.dataToSend.sig - 11.25).toFixed(0) + " dBµV", log_msg: "Logged PS: " + dataHandler.dataToSend.ps.replace(/\s+/g, '_') + ", PI: " + dataHandler.dataToSend.pi + ", Signal: " + (dataHandler.dataToSend.sig - 11.25).toFixed(0) + " dBµV",
}); });

View File

@@ -149,10 +149,10 @@ function evaluateStation(station) {
return score; return score;
} }
// Fetch data from maps // Fetch data from cached database
async function fetchTx(freq, piCode, rdsPs) { async function fetchTx(freq, piCode, rdsPs) {
let match = null; let match = null;
let multiMatches = []; // let multiMatches = [];
const now = Date.now(); const now = Date.now();
freq = parseFloat(freq); freq = parseFloat(freq);
@@ -192,7 +192,7 @@ async function fetchTx(freq, piCode, rdsPs) {
loc.score = evaluateStation(loc); loc.score = evaluateStation(loc);
} }
match = filteredLocations.reduce((max, obj) => obj.score > max.score ? obj : max, filteredLocations[0]); match = filteredLocations.reduce((max, obj) => obj.score > max.score ? obj : max, filteredLocations[0]);
multiMatches = filteredLocations.filter(obj => obj !== match); // multiMatches = filteredLocations.filter(obj => obj !== match);
} else if (filteredLocations.length === 1) { } else if (filteredLocations.length === 1) {
match = filteredLocations[0]; match = filteredLocations[0];
} }
@@ -218,7 +218,7 @@ async function fetchTx(freq, piCode, rdsPs) {
pi: match.pi, pi: match.pi,
foundStation: true, foundStation: true,
reg: match.detectedByPireg, reg: match.detectedByPireg,
others: multiMatches.length, // others: multiMatches,
}; };
} else { } else {
return Promise.resolve(); return Promise.resolve();

View File

@@ -287,7 +287,7 @@
<span id="data-station-city" style="font-size: 16px;"></span> <span class="text-small">[<span id="data-station-itu"></span>]</span> <span id="data-station-city" style="font-size: 16px;"></span> <span class="text-small">[<span id="data-station-itu"></span>]</span>
</h4> </h4>
<span class="text-small"> <span class="text-small">
<span id="data-station-erp"></span> kW [<span id="data-station-pol"></span>] <span class="text-gray">•</span> <span id="data-station-distance"></span> <span class="text-gray">•</span> <span id="data-station-azimuth"></span> <span id="data-station-others"></span> <span id="data-station-erp"></span> kW [<span id="data-station-pol"></span>] <span class="text-gray">•</span> <span id="data-station-distance"></span> <span class="text-gray">•</span> <span id="data-station-azimuth"></span>
</span> </span>
</div> </div>
</div> </div>

View File

@@ -976,7 +976,6 @@ const updateDataElements = throttle(function(parsedData) {
updateTextIfChanged($('#data-station-itu'), parsedData.txInfo.itu); updateTextIfChanged($('#data-station-itu'), parsedData.txInfo.itu);
updateTextIfChanged($('#data-station-pol'), parsedData.txInfo.pol); updateTextIfChanged($('#data-station-pol'), parsedData.txInfo.pol);
updateHtmlIfChanged($('#data-station-azimuth'), parsedData.txInfo.azi + '°'); updateHtmlIfChanged($('#data-station-azimuth'), parsedData.txInfo.azi + '°');
updateHtmlIfChanged($('#data-station-others'), parsedData.txInfo.otherMatches > 0 ? ('<span>+' + parsedData.txInfo.otherMatches +'</span>') : '');
const txDistance = localStorage.getItem('imperialUnits') == "true" ? (Number(parsedData.txInfo.dist) * 0.621371192).toFixed(0) + " mi" : parsedData.txInfo.dist + " km"; const txDistance = localStorage.getItem('imperialUnits') == "true" ? (Number(parsedData.txInfo.dist) * 0.621371192).toFixed(0) + " mi" : parsedData.txInfo.dist + " km";
updateTextIfChanged($('#data-station-distance'), txDistance); updateTextIfChanged($('#data-station-distance'), txDistance);
$dataStationContainer.css('display', 'block'); $dataStationContainer.css('display', 'block');