cleanup and fix gnss location
This commit is contained in:
parent
66b245e6ab
commit
64b77c33b5
@ -11,7 +11,7 @@ import { getLocationForWifiMemoized } from "../proxy/wigle";
|
||||
const locationService = container.resolve(LocationService);
|
||||
const wifiScanService = container.resolve(WifiScanService);
|
||||
|
||||
const CalculateTtnGatewayLocation = async (event: TtnMessageReceivedEvent) => {
|
||||
const CalculateTtnGatewayLocation = (event: TtnMessageReceivedEvent) => {
|
||||
// Get location based on TTN Gateways
|
||||
const virtualLocation = {
|
||||
latitude: undefined as number | undefined,
|
||||
@ -105,25 +105,18 @@ const CalculateWifiLocation = async (event: TtnMessageReceivedEvent) => {
|
||||
};
|
||||
};
|
||||
|
||||
const CalculateGnssLocation = async (event: TtnMessageReceivedEvent) => {
|
||||
// Default virtual location with undefined coordinates
|
||||
const virtualLocation = {
|
||||
latitude: undefined as number | undefined,
|
||||
longitude: undefined as number | undefined,
|
||||
};
|
||||
|
||||
if (virtualLocation.latitude === undefined || virtualLocation.longitude === undefined) {
|
||||
const CalculateGnssLocation = (event: TtnMessageReceivedEvent) => {
|
||||
// Get location based on reported GNSS
|
||||
if (event.gnssLocation.latitude === undefined || event.gnssLocation.longitude === undefined) {
|
||||
console.log("No valid GNSS location received!");
|
||||
}
|
||||
|
||||
return {
|
||||
gnss_latitude: virtualLocation.latitude,
|
||||
gnss_longitude: virtualLocation.longitude,
|
||||
gnss_latitude: event.gnssLocation.latitude,
|
||||
gnss_longitude: event.gnssLocation.longitude,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
domainEventEmitter.on(
|
||||
TtnMessageReceivedEventName,
|
||||
async (event: TtnMessageReceivedEvent) => {
|
||||
@ -137,7 +130,7 @@ domainEventEmitter.on(
|
||||
var ttn_gw_based_longitude: number | undefined = undefined;
|
||||
|
||||
if (event.ttnGateways && event.ttnGateways.length > 0) {
|
||||
const virtualLocation = await CalculateTtnGatewayLocation(event);
|
||||
const virtualLocation = CalculateTtnGatewayLocation(event);
|
||||
ttn_gw_based_latitude = virtualLocation.ttn_latitude;
|
||||
ttn_gw_based_longitude = virtualLocation.ttn_longitude;
|
||||
}
|
||||
@ -148,7 +141,7 @@ domainEventEmitter.on(
|
||||
wifi_based_longitude = virtualLocation.wifi_longitude;
|
||||
}
|
||||
|
||||
const virtualLocation = await CalculateGnssLocation(event);
|
||||
const virtualLocation = CalculateGnssLocation(event);
|
||||
gnss_based_latitude = virtualLocation.gnss_latitude;
|
||||
gnss_based_longitude = virtualLocation.gnss_longitude;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user