Use new tidied normalising code on the client-side
This commit is contained in:
parent
4493fbb0fa
commit
c9114cc4c4
2 changed files with 21 additions and 24 deletions
|
@ -5,7 +5,19 @@ import path from 'path';
|
|||
import brain from 'brain.js';
|
||||
import haversine from 'haversine-distance';
|
||||
|
||||
import { normalise, clamp } from '../../../common/Math.mjs';
|
||||
import {
|
||||
normalise_lat,
|
||||
normalise_lng,
|
||||
unnormalise_lat,
|
||||
unnormalise_lng,
|
||||
|
||||
normalise_gateway_distance,
|
||||
unnormalise_gateway_distance,
|
||||
|
||||
normalise_rssi,
|
||||
unnormalise_rssi
|
||||
} from '../../../common/Normalisers.mjs';
|
||||
|
||||
import GetFromUrl from '../Helpers/GetFromUrl.mjs';
|
||||
|
||||
class AIWrapper {
|
||||
|
@ -62,34 +74,20 @@ class AIWrapper {
|
|||
{ latitude: lat, longitude: lng },
|
||||
this.gateways.get(gateway_id)
|
||||
);
|
||||
|
||||
max_predicted_rssi = Math.max(
|
||||
max_predicted_rssi,
|
||||
ai.run({
|
||||
latitude: normalise(lat,
|
||||
{ min: -90, max: +90 },
|
||||
{ min: 0, max: 1 }
|
||||
latitude: normalise_lat(lat),
|
||||
longitude: normalise_lng(lng),
|
||||
distance: normalise_gateway_distance(
|
||||
distance_from_gateway
|
||||
),
|
||||
longitude: normalise(lng,
|
||||
{ min: -180, max: +180 },
|
||||
{ min: 0, max: 1 }
|
||||
),
|
||||
distance: clamp(
|
||||
normalise(distance_from_gateway,
|
||||
{ min: 0, max: 20000 },
|
||||
{ min: 0, max: 1 }
|
||||
),
|
||||
0, 1)
|
||||
})
|
||||
})[0]
|
||||
);
|
||||
}
|
||||
|
||||
max_predicted_rssi = normalise(max_predicted_rssi,
|
||||
{ min: 0, max: 1 },
|
||||
{
|
||||
min: this.index.properties.rssi_min,
|
||||
max: this.index.properties.rssi_max
|
||||
}
|
||||
);
|
||||
max_predicted_rssi = unnormalise_rssi(max_predicted_rssi);
|
||||
|
||||
if(max_predicted_rssi > stats.rssi_max)
|
||||
stats.rssi_max = max_predicted_rssi;
|
||||
|
|
|
@ -55,8 +55,7 @@ class AITrainer {
|
|||
),
|
||||
JSON.stringify({
|
||||
properties: {
|
||||
rssi_min: this.settings.ai.rssi_min,
|
||||
rssi_max: this.settings.ai.rssi_max
|
||||
|
||||
},
|
||||
index
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue