LoRaWAN-Signal-Mapping/server/train-ai/DatasetFetcher.mjs

39 lines
786 B
JavaScript
Raw Normal View History

"use strict";
import { normalise, clamp } from '../Helpers/Math.mjs';
class DatasetFetcher {
constructor({ settings, RSSIRepo }) {
this.settings = settings;
this.repo_rssi = RSSIRepo;
}
*fetch_input(gateway_id) {
for(let rssi of this.repo_rssi.iterate_gateway(gateway_id)) {
yield [
normalise(rssi.latitude,
{ min: -90, max: +90 },
{ min: 0, max: 1 }
),
normalise(rssi.longitude,
{ min: -180, max: +180 },
{ min: 0, max: 1 }
)
];
}
}
*fetch_output(gateway_id) {
for(let rssi of this.repo_rssi.iterate_gateway(gateway_id)) {
yield [
clamp(normalise(rssi.rssi,
{ min: this.settings.ai.rssi_min, max: this.settings.ai.rssi_max },
{ min: 0, max: 1 }
), 0, 1)
];
}
}
}
export default DatasetFetcher;