38 lines
788 B
JavaScript
38 lines
788 B
JavaScript
"use strict";
|
|
|
|
import { normalise, clamp } from '../../common/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;
|