72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
/**
|
|
* Test script to demonstrate the updated SatLoc job creation
|
|
* This shows how the createSatLocJob function now generates
|
|
* proper JOB format according to Rev-1.09 specification
|
|
*/
|
|
|
|
const fileSatlog = require('./helpers/file_satlog');
|
|
|
|
// Sample spray areas (inclusive polygons)
|
|
const sampleSprayAreas = [
|
|
{
|
|
properties: { name: 'Field_1' },
|
|
geometry: {
|
|
coordinates: [[
|
|
[-96.031253, 39.711134],
|
|
[-96.029540, 39.711111],
|
|
[-96.029479, 39.711059],
|
|
[-96.029437, 39.710977],
|
|
[-96.029443, 39.710663],
|
|
[-96.031253, 39.711134]
|
|
]]
|
|
}
|
|
}
|
|
];
|
|
|
|
// Sample excluded areas (exclusive polygons)
|
|
const sampleExcludedAreas = [
|
|
{
|
|
properties: { name: 'Obstacle_1' },
|
|
geometry: {
|
|
coordinates: [[
|
|
[-96.030500, 39.710800],
|
|
[-96.030200, 39.710800],
|
|
[-96.030200, 39.710500],
|
|
[-96.030500, 39.710500],
|
|
[-96.030500, 39.710800]
|
|
]]
|
|
}
|
|
}
|
|
];
|
|
|
|
// Test the createSatLocJob function
|
|
console.log('=== Testing SatLoc Job Creation ===\n');
|
|
|
|
const jobName = 'SampleJob1';
|
|
const jobContent = fileSatlog.createSatLocJob(jobName, sampleSprayAreas, sampleExcludedAreas);
|
|
|
|
console.log('Generated SatLoc Job File Content:');
|
|
console.log('-----------------------------------');
|
|
console.log(jobContent);
|
|
console.log('-----------------------------------');
|
|
|
|
console.log('\nKey improvements made to match JOB Format Rev-1.09:');
|
|
console.log('1. ✅ Updated to VERSION 3 (current standard)');
|
|
console.log('2. ✅ Proper header format with job numbers');
|
|
console.log('3. ✅ Added job name (.JNM) and label (.LLB) entries');
|
|
console.log('4. ✅ TAB indentation for coordinates and type fields');
|
|
console.log('5. ✅ Coordinates formatted to 6 decimal places');
|
|
console.log('6. ✅ Proper lat/lon order (latitude first)');
|
|
console.log('7. ✅ Windows line endings (\\r\\n) as per specification');
|
|
console.log('8. ✅ RGB color information for inclusive polygons');
|
|
console.log('9. ✅ Proper handling of first/last coordinate duplication');
|
|
console.log('10. ✅ Counterclockwise ordering for exclusive areas');
|
|
|
|
// Test with different job name formats
|
|
console.log('\n=== Testing Job Number Extraction ===');
|
|
const testNames = ['100', 'Job_123', 'SampleJob1', '456.job', 'Field_789'];
|
|
testNames.forEach(name => {
|
|
const extractedNumber = fileSatlog.extractJobNumber(name);
|
|
console.log(`"${name}" -> Job Number: ${extractedNumber || 'default(1)'}`);
|
|
});
|