78 lines
3.7 KiB
JavaScript
78 lines
3.7 KiB
JavaScript
// Test parser integration directly
|
|
const { SatLocLogParser } = require('./helpers/satloc_log_parser');
|
|
const fs = require('fs');
|
|
|
|
async function testParserIntegration() {
|
|
console.log('Testing SatLoc Parser Integration...\n');
|
|
|
|
try {
|
|
const testFile = './test-logs/02220710.LOG';
|
|
const parser = new SatLocLogParser();
|
|
const buffer = fs.readFileSync(testFile);
|
|
|
|
console.log(`Processing file: ${testFile}`);
|
|
console.log(`File size: ${buffer.length} bytes\n`);
|
|
|
|
// Test the method that would be called by the application processor
|
|
const headerInfo = {}; // Parser will extract header info
|
|
const fileContext = {
|
|
filenameJobId: 'TEST_JOB_001',
|
|
filePath: testFile,
|
|
fileName: '02220710.LOG'
|
|
};
|
|
|
|
console.log('=== Testing Parser Integration ===');
|
|
|
|
// Test parseRecordsFromBuffer (the method used by processLogFile)
|
|
const parseResults = await parser.parseRecordsFromBuffer(buffer, headerInfo, fileContext);
|
|
|
|
console.log('\n📊 Parse Results Summary:');
|
|
console.log(`✓ Total records parsed: ${parseResults.recordCount}`);
|
|
console.log(`✓ Job groups found: ${Object.keys(parseResults.jobGroups).length}`);
|
|
console.log(`✓ UTM Zone calculated: ${parseResults.utmZone ? parseResults.utmZone.toString() : 'None'}`);
|
|
|
|
console.log('\n🔍 UTM Zone Details:');
|
|
if (parseResults.utmZone) {
|
|
console.log(` - Zone Number: ${parseResults.utmZone.zoneNumber}`);
|
|
console.log(` - Hemisphere: ${parseResults.utmZone.hemisphere}`);
|
|
console.log(` - toString(): ${parseResults.utmZone.toString()}`);
|
|
console.log(` ✓ UTM Zone object structure is correct!`);
|
|
}
|
|
|
|
console.log('\n📝 Job Groups Analysis:');
|
|
for (const [jobId, applicationDetails] of Object.entries(parseResults.jobGroups)) {
|
|
console.log(` Job ID: "${jobId}"`);
|
|
console.log(` - Application details: ${applicationDetails.length}`);
|
|
|
|
if (applicationDetails.length > 0) {
|
|
const firstDetail = applicationDetails[0];
|
|
console.log(` - First detail properties: ${Object.keys(firstDetail).length}`);
|
|
console.log(` - Has coordinates: ${firstDetail.lat !== undefined && firstDetail.lon !== undefined}`);
|
|
console.log(` - Sample coordinates: lat=${firstDetail.lat}, lon=${firstDetail.lon}`);
|
|
}
|
|
}
|
|
|
|
console.log('\n📍 Metadata Extracted:');
|
|
const metadata = parseResults.metadata;
|
|
console.log(` - Job ID: ${metadata.jobId || 'Not found'}`);
|
|
console.log(` - Aircraft ID: ${metadata.aircraftId || 'Not found'}`);
|
|
console.log(` - Pilot Name: ${metadata.pilotName || 'Not found'}`);
|
|
console.log(` - Controller Type: ${metadata.controllerType || 'Not found'}`);
|
|
|
|
console.log('\n🎯 Detected Job IDs:');
|
|
const detected = parseResults.detectedJobIds;
|
|
console.log(` - Filename Job ID: ${detected.filenameJobId || 'None'}`);
|
|
console.log(` - Job Long Label Name: ${detected.jobLongLabelName || 'None'}`);
|
|
console.log(` - SatLoc Job ID: ${detected.satlocJobId || 'None'}`);
|
|
|
|
console.log('\n✅ All integration tests passed!');
|
|
console.log('🚀 Parser is ready for Application Processor integration');
|
|
|
|
} catch (error) {
|
|
console.error('\n❌ Error during integration test:', error.message);
|
|
console.error('Stack:', error.stack);
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testParserIntegration().catch(console.error); |