dji_srt_parser
Advanced tools
Comparing version 1.2.2 to 1.2.3
34
index.js
@@ -144,16 +144,25 @@ const tzlookup = require('tz-lookup'); | ||
let computed = JSON.parse(JSON.stringify(arr)); | ||
const sample = computed.find( | ||
c => | ||
c.GPS && | ||
c.GPS.LATITUDE != null && | ||
c.GPS.LONGITUDE != null && | ||
c.DATE != null | ||
); | ||
let offset = 0; | ||
if (sample) { | ||
const tz = tzlookup(sample.GPS.LATITUDE, sample.GPS.LONGITUDE); | ||
if (tz) { | ||
let d = moment(sample.DATE); | ||
offset = (d.utcOffset() - d.tz(tz).utcOffset()) * 60 * 1000; | ||
if (fixDateUTC) { | ||
const sample = computed.find( | ||
c => | ||
c.GPS && | ||
c.GPS.LATITUDE != null && | ||
c.GPS.LONGITUDE != null && | ||
c.GPS.LATITUDE != 'n/a' && | ||
c.GPS.LONGITUDE != 'n/a' && | ||
c.DATE != null | ||
); | ||
if (sample) { | ||
try { | ||
const tz = tzlookup(sample.GPS.LATITUDE, sample.GPS.LONGITUDE); | ||
if (tz) { | ||
let d = moment(sample.DATE); | ||
offset = (d.utcOffset() - d.tz(tz).utcOffset()) * 60 * 1000; | ||
} | ||
} catch (error) { | ||
console.warn(error); | ||
} | ||
} | ||
computed.forEach(c => (c.DATE += offset)); | ||
} | ||
@@ -165,3 +174,2 @@ computed.forEach((c, i, arr) => { | ||
} | ||
if (fixDateUTC) c.DATE += offset; | ||
}); | ||
@@ -168,0 +176,0 @@ return computed; |
@@ -34,5 +34,5 @@ let preProcess; | ||
}); | ||
// test('The average 3D speed should be set', () => { | ||
// expect(MavicPro.metadata().stats.SPEED.THREED.avg).toBe(21.56914922116961); | ||
// }); | ||
test('The average 3D speed should be set', () => { | ||
expect(MavicPro.metadata().stats.SPEED.THREED.avg).toBe(21.56914922116961); | ||
}); | ||
test('The max altitude should be readable from the barometer', () => { | ||
@@ -68,5 +68,5 @@ expect(MavicPro.metadata().stats.BAROMETER.max).toBe(118.65000000000002); | ||
}); | ||
// test('The average 3D speed should be set in the old format', () => { | ||
// expect(Old_Format.metadata().stats.SPEED.THREED.avg).toBe(21.56914922116961); | ||
// }); | ||
test('The average 3D speed should be set in the old format', () => { | ||
expect(Old_Format.metadata().stats.SPEED.THREED.avg).toBe(21.56914922116961); | ||
}); | ||
test('The max altitude should be readable from the HB field', () => { | ||
@@ -87,5 +87,5 @@ expect(Old_Format.metadata().stats.HB.max).toBe(118.65000000000002); | ||
}); | ||
// test('The average 2D speed should be set in the Mavic 2 format', () => { | ||
// expect(Mavic_2.metadata().stats.SPEED.TWOD.avg).toBe(19.531079073870547); | ||
// }); | ||
test('The average 2D speed should be set in the Mavic 2 format', () => { | ||
expect(Mavic_2.metadata().stats.SPEED.TWOD.avg).toBe(19.531079073870547); | ||
}); | ||
test('We should be able to read the aperture in the Mavic 2 format', () => { | ||
@@ -118,5 +118,5 @@ expect(Mavic_2.metadata().packets[0].FNUM).toBe(2.2); | ||
}); | ||
// test('The average 3D speed should be set in the buggy format', () => { | ||
// expect(Buggy.metadata().stats.SPEED.THREED.avg).toBe(13.40770963200714); | ||
// }); | ||
test('The average 3D speed should be set in the buggy format', () => { | ||
expect(Buggy.metadata().stats.SPEED.THREED.avg).toBe(13.40770963200714); | ||
}); | ||
test('The max satellites should be readable from the SATELLITES field', () => { | ||
@@ -123,0 +123,0 @@ expect(Buggy.metadata().stats.GPS.SATELLITES.max).toBe(18); |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Parses and interprets DJI's drones SRT metadata", | ||
@@ -12,0 +12,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5118516
3710