2019-07-17 14:15:31 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import { normalise, clamp } from '../Helpers/Math.mjs';
|
|
|
|
|
|
|
|
class DatasetFetcher {
|
|
|
|
constructor({ settings, RSSIRepo }) {
|
|
|
|
this.settings = settings;
|
|
|
|
this.repo_rssi = RSSIRepo;
|
|
|
|
}
|
|
|
|
|
2019-07-18 15:34:25 +00:00
|
|
|
*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)
|
|
|
|
];
|
2019-07-17 14:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DatasetFetcher;
|