1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 14:33:52 +01:00

TX ID Algorithm tweaks and config options

Fix bug when TX ERP is 1W and allow user choice of algorithms in webserver config
This commit is contained in:
Adam Wisher
2025-04-21 08:22:36 +01:00
parent ea3b0d8ced
commit 2cd2cf5cf1
3 changed files with 36 additions and 4 deletions

View File

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

View File

@@ -12,6 +12,21 @@ var currentRdsPs = '';
const usStatesGeoJsonUrl = "https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json"; 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 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 // Load the US states GeoJSON data
async function loadUsStatesGeoJson() { async function loadUsStatesGeoJson() {
if (!usStatesGeoJson) { if (!usStatesGeoJson) {
@@ -121,8 +136,14 @@ async function processData(data, piCode, rdsPs) {
weightDistance = Math.abs(distance.distanceKm - 1500); weightDistance = Math.abs(distance.distanceKm - 1500);
} }
let erp = station.erp && station.erp > 0 ? station.erp : 1; let erp = station.erp && station.erp > 0 ? station.erp : 1;
let extraWeight = erp >= 10 && distance.distanceKm <= 400 ? 0.3 : 0; let extraWeight = erp >= weightedErp && distance.distanceKm <= weightedDist ? 0.3 : 0;
const score = ((10 * Math.log10(erp * 1000)) / weightDistance) + extraWeight; 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) { if (score > maxScore) {
maxScore = score; maxScore = score;
txAzimuth = distance.azimuth; txAzimuth = distance.azimuth;

View File

@@ -296,6 +296,16 @@
<p>You can switch between American (RBDS) / Global (RDS) mode here.</p> <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> <%- include('_components', {component: 'checkbox', cssClass: 'bottom-20', iconClass: '', label: 'American RDS mode (RBDS)', id: 'webserver-rdsMode'}) %><br>
</div> </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>
</div> </div>