70 lines
2.9 KiB
Plaintext
70 lines
2.9 KiB
Plaintext
// Test UTM zone object functionality
|
|
const { SatLocLogParser } = require('../../helpers/satloc_log_parser');
|
|
const fs = require('fs');
|
|
|
|
async function testUTMZone() {
|
|
console.log('Testing UTM Zone Object...\n');
|
|
|
|
// Test with a real log file
|
|
const testFile = './test-logs/02220710.LOG';
|
|
|
|
if (fs.existsSync(testFile)) {
|
|
try {
|
|
const parser = new SatLocLogParser();
|
|
const buffer = fs.readFileSync(testFile);
|
|
|
|
console.log(`Processing file: ${testFile}`);
|
|
console.log(`File size: ${buffer.length} bytes\n`);
|
|
|
|
// Create minimal file context - the parser needs this
|
|
const fileContext = {
|
|
filenameJobId: null,
|
|
filePath: testFile,
|
|
fileName: 'test.LOG'
|
|
};
|
|
|
|
// Create minimal header info - the parser needs this too
|
|
const headerInfo = {
|
|
// Add minimal header - parser will extract what it needs
|
|
};
|
|
|
|
const results = await parser.parseRecordsFromBuffer(buffer, headerInfo, fileContext);
|
|
|
|
console.log('Parser Results:');
|
|
console.log(`- Result keys: ${Object.keys(results)}`);
|
|
console.log(`- Total job groups: ${results.jobGroups ? Object.keys(results.jobGroups).length : 'undefined'}`);
|
|
console.log(`- Job groups keys: ${results.jobGroups ? Object.keys(results.jobGroups) : 'N/A'}`);
|
|
console.log(`- UTM Zone type: ${typeof results.utmZone}`);
|
|
console.log(`- UTM Zone: ${JSON.stringify(results.utmZone)}`);
|
|
|
|
if (results.utmZone && typeof results.utmZone === 'object') {
|
|
console.log(`- Zone Number: ${results.utmZone.zoneNumber}`);
|
|
console.log(`- Hemisphere: ${results.utmZone.hemisphere}`);
|
|
console.log(`- toString(): ${results.utmZone.toString()}`);
|
|
|
|
console.log('\n✓ UTM Zone object structure is correct!');
|
|
} else {
|
|
console.log('\n✗ UTM Zone is not an object with the expected structure');
|
|
}
|
|
|
|
if (results.jobGroups && Object.keys(results.jobGroups).length > 0) {
|
|
console.log(`\nFirst job group details:`);
|
|
const firstGroupKey = Object.keys(results.jobGroups)[0];
|
|
const firstGroup = results.jobGroups[firstGroupKey];
|
|
console.log(`- Job ID: ${firstGroupKey}`);
|
|
console.log(`- Records count: ${firstGroup.length}`);
|
|
} else {
|
|
console.log('\n- No job groups found or jobGroups is undefined');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error testing parser:', error.message);
|
|
console.error('Stack:', error.stack);
|
|
}
|
|
} else {
|
|
console.log(`Test file not found: ${testFile}`);
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testUTMZone().catch(console.error); |