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

Merge pull request #136 from mrwish7/main

TX ID Algorithm tweaks and config options
This commit is contained in:
Marek Farkaš
2025-04-22 13:10:30 +02:00
committed by GitHub
3 changed files with 36 additions and 4 deletions

View File

@@ -30,7 +30,8 @@ let serverConfig = {
],
defaultTheme: "theme1",
bgImage: "",
rdsMode: false
rdsMode: false,
txIdAlgorithm: 0
},
xdrd: {
wirelessConnection: true,

View File

@@ -12,6 +12,21 @@ var currentRdsPs = '';
const usStatesGeoJsonUrl = "https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json";
let usStatesGeoJson = null; // To cache the GeoJSON data for US states
// Get weighting values based on algorithm setting.
// Defaults = algorithm 1
let weightedErp = 10;
let weightedDist = 400;
const algorithms = [
[10, 400],
[30, 500]
];
const algoSetting = parseInt(serverConfig.webserver.txIdAlgorithm);
if (typeof algorithms[algoSetting] !== 'undefined') {
weightedErp = algorithms[algoSetting][0];
weightedDist = algorithms[algoSetting][1];
}
// Load the US states GeoJSON data
async function loadUsStatesGeoJson() {
if (!usStatesGeoJson) {
@@ -121,8 +136,14 @@ async function processData(data, piCode, rdsPs) {
weightDistance = Math.abs(distance.distanceKm - 1500);
}
let erp = station.erp && station.erp > 0 ? station.erp : 1;
let extraWeight = erp >= 10 && distance.distanceKm <= 400 ? 0.3 : 0;
const score = ((10 * Math.log10(erp * 1000)) / weightDistance) + extraWeight;
let extraWeight = erp >= weightedErp && distance.distanceKm <= weightedDist ? 0.3 : 0;
let score = 0;
// If ERP is 1W, use a simpler formula to avoid zero-scoring.
if (erp === 0.001) {
score = erp / distance.distanceKm;
} else {
score = ((10 * Math.log10(erp * 1000)) / weightDistance) + extraWeight;
}
if (score > maxScore) {
maxScore = score;
txAzimuth = distance.azimuth;
@@ -247,4 +268,4 @@ function deg2rad(deg) {
module.exports = {
fetchTx
};
};

View File

@@ -296,6 +296,16 @@
<p>You can switch between American (RBDS) / Global (RDS) mode here.</p>
<%- include('_components', {component: 'checkbox', cssClass: 'bottom-20', iconClass: '', label: 'American RDS mode (RBDS)', id: 'webserver-rdsMode'}) %><br>
</div>
<div class="panel-33 p-bottom-20" style="padding-left: 20px; padding-right: 20px;">
<h3>Transmitter Search Algorithm</h3>
<p>Different modes may help with more accurate transmitter identification depending on your region.</p>
<%- include('_components', { component: 'dropdown', id: 'server-tx-id-algo', inputId: 'webserver-txIdAlgorithm', label: 'Transmitter ID Algorithm', cssClass: '', placeholder: 'Algorithm 1',
options: [
{ value: '0', label: 'Algorithm 1' },
{ value: '1', label: 'Algorithm 2' },
]
}) %>
</div>
</div>
</div>