124 lines
2.7 KiB
JavaScript
124 lines
2.7 KiB
JavaScript
/*
|
|
Copyright (c) 2023-forever Douglas Malnati. All rights reserved.
|
|
|
|
See the /faq/tos page for details.
|
|
|
|
(If this generated header is stamped on a file which is a 3rd party file or under a different license or copyright, then ignore this copyright statement and use that file's terms.)
|
|
*/
|
|
|
|
import { CodecHighResLocation } from './CodecHighResLocation.js';
|
|
|
|
|
|
export class ColumnBuilderHighResLocation
|
|
{
|
|
constructor()
|
|
{
|
|
this.codecHighResLocation = new CodecHighResLocation();
|
|
}
|
|
|
|
MatchWindow(slotMsgList)
|
|
{
|
|
return this.HasAnyHighResLocation(slotMsgList);
|
|
}
|
|
|
|
GetColNameList()
|
|
{
|
|
return [
|
|
"HiResReference",
|
|
"HiResLatitudeIdx",
|
|
"HiResLongitudeIdx",
|
|
];
|
|
}
|
|
|
|
GetColMetaDataList()
|
|
{
|
|
return [
|
|
{ rangeMin: 0, rangeMax: 1 },
|
|
{ rangeMin: 0, rangeMax: 12352 },
|
|
{ rangeMin: 0, rangeMax: 24617 },
|
|
];
|
|
}
|
|
|
|
GetValListForWindow(slotMsgList)
|
|
{
|
|
let loc = this.GetLatestHighResLocation(slotMsgList);
|
|
|
|
if (!loc)
|
|
{
|
|
return [null, null, null];
|
|
}
|
|
|
|
return [loc.referenceEnum, loc.latitudeIdx, loc.longitudeIdx];
|
|
}
|
|
|
|
GetLatestHighResLocation(slotMsgList)
|
|
{
|
|
if (!Array.isArray(slotMsgList) || slotMsgList.length == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
for (let slot = slotMsgList.length - 1; slot >= 1; --slot)
|
|
{
|
|
let msg = slotMsgList[slot];
|
|
let loc = this.DecodeLocationFromMsg(msg);
|
|
|
|
if (loc)
|
|
{
|
|
return loc;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
HasAnyHighResLocation(slotMsgList)
|
|
{
|
|
if (!Array.isArray(slotMsgList) || slotMsgList.length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
for (let slot = slotMsgList.length - 1; slot >= 1; --slot)
|
|
{
|
|
if (this.IsHighResLocationMsg(slotMsgList[slot]))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
IsHighResLocationMsg(msg)
|
|
{
|
|
if (!msg?.IsTelemetryExtended?.())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
let codec = msg.GetCodec?.();
|
|
|
|
return this.codecHighResLocation.IsCodecHighResLocation(codec);
|
|
}
|
|
|
|
DecodeLocationFromMsg(msg)
|
|
{
|
|
if (!this.IsHighResLocationMsg(msg))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
let codec = msg.GetCodec?.();
|
|
|
|
let referenceEnum = codec.GetReferenceEnum();
|
|
let latitudeIdx = codec.GetLatitudeIdx();
|
|
let longitudeIdx = codec.GetLongitudeIdx();
|
|
return {
|
|
referenceEnum,
|
|
latitudeIdx,
|
|
longitudeIdx,
|
|
};
|
|
}
|
|
}
|