mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:37:07 +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.layerName = "SequenceDataLayer";
|
||||||
SequenceDataLayer.tooltip = ({index, sourceLayer}) => {
|
SequenceDataLayer.tooltip = ({index, sourceLayer}) => {
|
||||||
if (index >= 0) {
|
try {
|
||||||
const p = sourceLayer?.props?.data;
|
if (index >= 0) {
|
||||||
// console.log("P", p);
|
const p = sourceLayer?.props?.data;
|
||||||
if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) {
|
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 seq = p.seq.toString().padStart(3, "0");
|
||||||
const pnt = p.sp0 + p.Δsp * index;
|
const pnt = p.sp0 + p.Δsp * index;
|
||||||
return `S${seq} ${pnt}`;
|
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 seq = p.seq.toString().padStart(3, "0");
|
||||||
const pnt = p.sp0 + p.Δsp * index;
|
const pnt = p.sp0 + p.Δsp * index;
|
||||||
const kind = p.type == MSGTYPE.RAW_OPT ? "Raw" : "Final";
|
const kind = p.type == MSGTYPE.RAW_OPT ? "Raw" : "Final";
|
||||||
const Δi = p.Δij[index*2];
|
const Δi = p.Δij[index*2];
|
||||||
const Δj = p.Δij[index*2+1];
|
const Δj = p.Δij[index*2+1];
|
||||||
const tstamp = new Date(Number(p.ts0) + p.Δts[index]);
|
const tstamp = new Date(Number(p.ts0) + p.Δts[index]);
|
||||||
|
|
||||||
const html = `S${seq} ${pnt} (${kind})<br/>\n` +
|
const html = `S${seq} ${pnt} (${kind})<br/>\n` +
|
||||||
`<small>${tstamp.toISOString()}</small><br/>\n` +
|
`<small>${tstamp.toISOString()}</small><br/>\n` +
|
||||||
`Δi: ${Δi.toFixed(2)}<br/>\n` +
|
`Δi: ${Δi.toFixed(2)}<br/>\n` +
|
||||||
`Δj: ${Δj.toFixed(2)}</br/>`;
|
`Δj: ${Δj.toFixed(2)}</br/>`;
|
||||||
return {html};
|
return {html};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.message);
|
||||||
|
console.log(index, sourceLayer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user