isoxml-angular
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
43 lines (42 loc) • 2.72 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const __1 = require("../..");
describe('TimeLog Entity', () => {
it('should parse binary TimeLog files', () => __awaiter(void 0, void 0, void 0, function* () {
const isoxmlData = (0, fs_1.readFileSync)('./data/2021-04-09T15_33_26_taskdata.zip');
const isoxmlManager = new __1.ISOXMLManager({ version: 4 });
yield isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip');
const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0];
const parsedTimeLog = timeLog.parseBinaryFile();
expect(parsedTimeLog.timeLogs).toHaveLength(207);
expect(parsedTimeLog.valuesInfo).toHaveLength(4);
expect(parsedTimeLog.bbox).toEqual([9.5777866, 45.5277534, 9.5779409, 45.5278066]);
}));
it('should detect outliers', () => __awaiter(void 0, void 0, void 0, function* () {
const isoxmlData = (0, fs_1.readFileSync)('./data/2021-04-09T15_33_26_taskdata.zip');
const isoxmlManager = new __1.ISOXMLManager();
yield isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip');
const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0];
const ranges = timeLog.rangesWithoutOutliers();
expect(ranges[2].minValue).toBe(-2231);
expect(ranges[2].maxValue).toBe(334);
}));
it('should fill missing values', () => __awaiter(void 0, void 0, void 0, function* () {
const isoxmlData = (0, fs_1.readFileSync)('./data/2021-04-09T15_33_26_taskdata.zip');
const isoxmlManager = new __1.ISOXMLManager();
yield isoxmlManager.parseISOXMLFile(new Uint8Array(isoxmlData.buffer), 'application/zip');
const timeLog = isoxmlManager.getEntityByXmlId('TSK-1').attributes.TimeLog[0];
const filledValues = timeLog.getFilledTimeLogs();
expect(filledValues[3].values['0090_DET-1']).toBe(67159);
}));
});