69 lines
1.2 KiB
JavaScript
69 lines
1.2 KiB
JavaScript
import { normalise, clamp } from './Math.mjs';
|
|
|
|
function normalise_lat(lat) {
|
|
return normalise(lat,
|
|
{ min: -90, max: +90 },
|
|
{ min: 0, max: 1 }
|
|
);
|
|
}
|
|
|
|
function normalise_lng(lng) {
|
|
return normalise(lng,
|
|
{ min: -180, max: +180 },
|
|
{ min: 0, max: 1 }
|
|
);
|
|
}
|
|
|
|
function unnormalise_lat(nlat) {
|
|
return normalise(nlat,
|
|
{ min: 0, max: 1 },
|
|
{ min: -90, max: +90 }
|
|
);
|
|
}
|
|
|
|
function unnormalise_lng(nlng) {
|
|
return normalise(nlng,
|
|
{ min: 0, max: 1 },
|
|
{ min: -180, max: +180 }
|
|
);
|
|
}
|
|
|
|
function normalise_gateway_distance(distance) {
|
|
return clamp(normalise(distance,
|
|
{ min: 0, max: 20000 },
|
|
{ min: 0, max: 1 }
|
|
), 0, 20000);
|
|
}
|
|
|
|
function unnormalise_gateway_distance(ndistance) {
|
|
return clamp(normalise(ndistance,
|
|
{ min: 0, max: 1 },
|
|
{ min: 0, max: 20000 }
|
|
), 0, 20000);
|
|
}
|
|
|
|
function normalise_rssi(rssi) {
|
|
return clamp(normalise(rssi,
|
|
{ min: -150, max: 0 },
|
|
{ min: 0, max: 1 }
|
|
), 0, 1)
|
|
}
|
|
function unnormalise_rssi(rssi) {
|
|
return clamp(normalise(rssi,
|
|
{ min: 0, max: 1 },
|
|
{ min: -150, max: 0 }
|
|
), 0, 1)
|
|
}
|
|
|
|
export {
|
|
normalise_lat,
|
|
normalise_lng,
|
|
unnormalise_lat,
|
|
unnormalise_lng,
|
|
|
|
normalise_gateway_distance,
|
|
unnormalise_gateway_distance,
|
|
|
|
normalise_rssi,
|
|
unnormalise_rssi
|
|
};
|