in interactive-visualizers/src/app/app.component.ts [535:571]
async fetchLabelmap(labelmapName: string): Promise<void> {
try {
const labelmapUrl = this.getAssetsUrlPrefix() + labelmapName;
const labelmapResponse = await fetch(labelmapUrl);
const labelmapJson = await labelmapResponse.json();
let maxId = labelmapJson.item.length - 1;
for (const item of labelmapJson.item) {
if (item.id && item.id > maxId) {
maxId = item.id;
}
}
const labelmap = [];
for (let i = 0; i <= maxId; ++i) {
labelmap.push(UNKNOWN_LABEL_DISPLAY_NAME);
}
for (let i = 0; i < labelmapJson.item.length; ++i) {
const item = labelmapJson.item[i];
let displayName = UNKNOWN_LABEL_DISPLAY_NAME;
if (item.name) {
displayName = item.name;
}
if (item.display_name) {
displayName = item.display_name;
}
if (item.id) {
labelmap[item.id] = displayName;
} else {
labelmap[i] = displayName;
}
}
this.labelmap = labelmap;
} catch (error) {
this.labelmap = [];
console.error(
`Fetching the labelmap failed with the following error: ${error}`);
}
}