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 locationService = container.resolve(LocationService);
|
||||||
const wifiScanService = container.resolve(WifiScanService);
|
const wifiScanService = container.resolve(WifiScanService);
|
||||||
|
|
||||||
const CalculateTtnGatewayLocation = async (event: TtnMessageReceivedEvent) => {
|
const CalculateTtnGatewayLocation = (event: TtnMessageReceivedEvent) => {
|
||||||
// Get location based on TTN Gateways
|
// Get location based on TTN Gateways
|
||||||
const virtualLocation = {
|
const virtualLocation = {
|
||||||
latitude: undefined as number | undefined,
|
latitude: undefined as number | undefined,
|
||||||
@ -105,25 +105,18 @@ const CalculateWifiLocation = async (event: TtnMessageReceivedEvent) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const CalculateGnssLocation = async (event: TtnMessageReceivedEvent) => {
|
const CalculateGnssLocation = (event: TtnMessageReceivedEvent) => {
|
||||||
// Default virtual location with undefined coordinates
|
// Get location based on reported GNSS
|
||||||
const virtualLocation = {
|
if (event.gnssLocation.latitude === undefined || event.gnssLocation.longitude === undefined) {
|
||||||
latitude: undefined as number | undefined,
|
|
||||||
longitude: undefined as number | undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (virtualLocation.latitude === undefined || virtualLocation.longitude === undefined) {
|
|
||||||
console.log("No valid GNSS location received!");
|
console.log("No valid GNSS location received!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gnss_latitude: virtualLocation.latitude,
|
gnss_latitude: event.gnssLocation.latitude,
|
||||||
gnss_longitude: virtualLocation.longitude,
|
gnss_longitude: event.gnssLocation.longitude,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
domainEventEmitter.on(
|
domainEventEmitter.on(
|
||||||
TtnMessageReceivedEventName,
|
TtnMessageReceivedEventName,
|
||||||
async (event: TtnMessageReceivedEvent) => {
|
async (event: TtnMessageReceivedEvent) => {
|
||||||
@ -137,7 +130,7 @@ domainEventEmitter.on(
|
|||||||
var ttn_gw_based_longitude: number | undefined = undefined;
|
var ttn_gw_based_longitude: number | undefined = undefined;
|
||||||
|
|
||||||
if (event.ttnGateways && event.ttnGateways.length > 0) {
|
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_latitude = virtualLocation.ttn_latitude;
|
||||||
ttn_gw_based_longitude = virtualLocation.ttn_longitude;
|
ttn_gw_based_longitude = virtualLocation.ttn_longitude;
|
||||||
}
|
}
|
||||||
@ -148,7 +141,7 @@ domainEventEmitter.on(
|
|||||||
wifi_based_longitude = virtualLocation.wifi_longitude;
|
wifi_based_longitude = virtualLocation.wifi_longitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
const virtualLocation = await CalculateGnssLocation(event);
|
const virtualLocation = CalculateGnssLocation(event);
|
||||||
gnss_based_latitude = virtualLocation.gnss_latitude;
|
gnss_based_latitude = virtualLocation.gnss_latitude;
|
||||||
gnss_based_longitude = virtualLocation.gnss_longitude;
|
gnss_based_longitude = virtualLocation.gnss_longitude;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user