mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 09:07:09 +00:00
Protect against out of bounds array condition
This commit is contained in:
@@ -124,30 +124,38 @@ class SequenceDataLayer extends CompositeLayer {
|
||||
};
|
||||
SequenceDataLayer.layerName = "SequenceDataLayer";
|
||||
SequenceDataLayer.tooltip = ({index, sourceLayer}) => {
|
||||
if (index >= 0) {
|
||||
const p = sourceLayer?.props?.data;
|
||||
// console.log("P", p);
|
||||
if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) {
|
||||
try {
|
||||
if (index >= 0) {
|
||||
const p = sourceLayer?.props?.data;
|
||||
if (index >= p.length) {
|
||||
console.log("Index out of bounds");
|
||||
}
|
||||
// console.log("P", p);
|
||||
if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) {
|
||||
|
||||
const seq = p.seq.toString().padStart(3, "0");
|
||||
const pnt = p.sp0 + p.Δsp * index;
|
||||
return `S${seq} ${pnt}`;
|
||||
const seq = p.seq.toString().padStart(3, "0");
|
||||
const pnt = p.sp0 + p.Δsp * index;
|
||||
return `S${seq} ${pnt}`;
|
||||
|
||||
} else if (p.type == MSGTYPE.RAW_OPT || p.type == MSGTYPE.FINAL_OPT) {
|
||||
} else if (p.type == MSGTYPE.RAW_OPT || p.type == MSGTYPE.FINAL_OPT) {
|
||||
|
||||
const seq = p.seq.toString().padStart(3, "0");
|
||||
const pnt = p.sp0 + p.Δsp * index;
|
||||
const kind = p.type == MSGTYPE.RAW_OPT ? "Raw" : "Final";
|
||||
const Δi = p.Δij[index*2];
|
||||
const Δj = p.Δij[index*2+1];
|
||||
const tstamp = new Date(Number(p.ts0) + p.Δts[index]);
|
||||
const seq = p.seq.toString().padStart(3, "0");
|
||||
const pnt = p.sp0 + p.Δsp * index;
|
||||
const kind = p.type == MSGTYPE.RAW_OPT ? "Raw" : "Final";
|
||||
const Δi = p.Δij[index*2];
|
||||
const Δj = p.Δij[index*2+1];
|
||||
const tstamp = new Date(Number(p.ts0) + p.Δts[index]);
|
||||
|
||||
const html = `S${seq} ${pnt} (${kind})<br/>\n` +
|
||||
`<small>${tstamp.toISOString()}</small><br/>\n` +
|
||||
`Δi: ${Δi.toFixed(2)}<br/>\n` +
|
||||
`Δj: ${Δj.toFixed(2)}</br/>`;
|
||||
return {html};
|
||||
const html = `S${seq} ${pnt} (${kind})<br/>\n` +
|
||||
`<small>${tstamp.toISOString()}</small><br/>\n` +
|
||||
`Δi: ${Δi.toFixed(2)}<br/>\n` +
|
||||
`Δj: ${Δj.toFixed(2)}</br/>`;
|
||||
return {html};
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
console.log(index, sourceLayer);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user