agmission/Development/server/tests/test_metadata_storage.js

52 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const SatLocProcessor = require('./helpers/satloc_application_processor');
const path = require('path');
async function testMetadataStorage() {
console.log('=== Testing UTM Metadata Storage ===\n');
const processor = new SatLocProcessor();
const logFilePath = path.join(__dirname, 'test-logs', 'Liquid_IF2_G4.log');
try {
console.log('📁 Processing file to test metadata storage...');
const result = await processor.parseSatLocLogFile(logFilePath);
console.log('\n📊 Processing Results:');
console.log(`- Application Details: ${result.applicationDetails.length}`);
console.log(`- Spray Segments: ${result.spraySegments.length}`);
console.log('\n🗺 UTM Zone and Bounding Box Information:');
console.log(`- Reference UTM Zone: ${result.utmZone}`);
console.log(`- Bounding Box: [${result.boundingBox.join(', ')}]`);
const bbox = result.boundingBox;
const width = bbox[2] - bbox[0]; // maxX - minX (longitude degrees)
const height = bbox[3] - bbox[1]; // maxY - minY (latitude degrees)
console.log(`- Coverage Area: ${(width * 111000).toFixed(0)}m × ${(height * 111000).toFixed(0)}m (approx)`);
// Verify that this metadata would be stored in ApplicationFile
console.log('\n💾 ApplicationFile Meta (would be stored as):');
console.log(`- referenceUTMZone: "${result.utmZone}"`);
console.log(`- boundingBox: [${result.boundingBox.join(', ')}]`);
// Sample a few application details to verify UTM coordinates
if (result.applicationDetails.length > 0) {
console.log('\n🎯 Sample Application Detail Records:');
for (let i = 0; i < Math.min(3, result.applicationDetails.length); i++) {
const detail = result.applicationDetails[i];
if (detail.utmX && detail.utmY) {
console.log(`Record ${i + 1}: lat/lon (${detail.lat}, ${detail.lon}) → UTM (${detail.utmX.toFixed(2)}, ${detail.utmY.toFixed(2)})`);
} else {
console.log(`Record ${i + 1}: UTM coordinates missing!`);
}
}
}
console.log('\n✅ Metadata storage test completed successfully!');
} catch (error) {
console.error('❌ Test failed:', error.message);
}
}
testMetadataStorage();