diff --git a/server/datahandler.js b/server/datahandler.js index d0e2291..1f4ef74 100644 --- a/server/datahandler.js +++ b/server/datahandler.js @@ -421,7 +421,8 @@ function handleData(wss, receivedData, rdsWss) { id: currentTx.id, pi: currentTx.pi, reg: currentTx.reg, - otherMatches: currentTx.others + otherMatches: currentTx.others, + score: currentTx.score, }; } }) diff --git a/server/tx_search.js b/server/tx_search.js index 2380cce..33c8eef 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -191,10 +191,12 @@ async function fetchTx(freq, piCode, rdsPs) { for (loc of filteredLocations) { loc.score = evaluateStation(loc); } - match = filteredLocations.reduce((max, obj) => obj.score > max.score ? obj : max, filteredLocations[0]); - multiMatches = filteredLocations.filter(obj => obj !== match); + filteredLocations.sort((a, b) => b.score - a.score); + match = filteredLocations[0]; + multiMatches = filteredLocations.slice(1); } else if (filteredLocations.length === 1) { match = filteredLocations[0]; + match.score = 1; } if (match) { @@ -218,6 +220,7 @@ async function fetchTx(freq, piCode, rdsPs) { pi: match.pi, foundStation: true, reg: match.detectedByPireg, + score: match.score, others: multiMatches, }; } else { diff --git a/web/index.ejs b/web/index.ejs index 044d2ed..286c8b0 100644 --- a/web/index.ejs +++ b/web/index.ejs @@ -290,7 +290,7 @@