Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dji_srt_parser

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dji_srt_parser - npm Package Compare versions

Comparing version 1.0.45 to 1.0.46

134

index.js

@@ -23,3 +23,5 @@ const toMGJSON = require('./modules/toMGJSON');

.replace(/.*-->.*/g, match => match.replace(/,/g, ':separator:'))
.replace(/\(([^\)]+)\)/g, match => match.replace(/,/g, ':separator:').replace(/\s/g, ''))
.replace(/\(([^\)]+)\)/g, match =>
match.replace(/,/g, ':separator:').replace(/\s/g, '')
)
.replace(/,/g, '')

@@ -56,3 +58,4 @@ .replace(/Â|°|(B0)/g, '') // For P4RTK: parasite characters emerged after imported using "express-fileupload" and the actual "readfile" function.

if ((match = accurateDateRegex.exec(line))) {
converted[converted.length - 1].DATE = match[1] + ':' + match[2] + '.' + match[3];
converted[converted.length - 1].DATE =
match[1] + ':' + match[2] + '.' + match[3];
} else if ((match = dateRegEx.exec(line))) {

@@ -63,2 +66,3 @@ converted[converted.length - 1].DATE = match[0];

});
if (converted.length < 1) {

@@ -81,3 +85,8 @@ console.log('Error converting object');

// generally used geo measurement function. Source: https://stackoverflow.com/questions/639695/how-to-convert-latitude-or-longitude-to-meters
if ([lat1, lon1, lat2, lon2].reduce((acc, val) => (!isNum(val) ? true : acc), false)) {
if (
[lat1, lon1, lat2, lon2].reduce(
(acc, val) => (!isNum(val) ? true : acc),
false
)
) {
return 0; //set distance to 0 if there are null or nans in positions

@@ -110,3 +119,8 @@ }

let destin2d = [pck.GPS.LATITUDE, pck.GPS.LATITUDE];
let distance2D = measure(origin2d[0], origin2d[1], destin2d[0], destin2d[1]);
let distance2D = measure(
origin2d[0],
origin2d[1],
destin2d[0],
destin2d[1]
);
distance2D /= 1000;

@@ -118,10 +132,31 @@ let distanceVert = getElevation(pck) - getElevation(cmp[i - 1]);

if (pck.DATE) {
time = (new Date(pck.DATE).getTime() - new Date(cmp[i - 1].DATE).getTime()) / 1000.0; //seconds
time =
(new Date(pck.DATE).getTime() -
new Date(cmp[i - 1].DATE).getTime()) /
1000.0; //seconds
} else if (pck.TIMECODE) {
const parseTC = /(\d\d):(\d\d):(\d\d),(\d{3})/;
let match = pck.TIMECODE.match(parseTC);
const useDate = new Date(0, 0, 0, match[1], match[2], match[3], match[4]);
const useDate = new Date(
0,
0,
0,
match[1],
match[2],
match[3],
match[4]
);
match = cmp[i - 1].TIMECODE.match(parseTC);
const prevDate = new Date(0, 0, 0, match[1], match[2], match[3], match[4]);
time = (new Date(useDate).getTime() - new Date(prevDate).getTime()) / 1000.0; //seconds
const prevDate = new Date(
0,
0,
0,
match[1],
match[2],
match[3],
match[4]
);
time =
(new Date(useDate).getTime() - new Date(prevDate).getTime()) /
1000.0; //seconds
}

@@ -139,7 +174,9 @@

if (result.SPEED_VERTICAL != null) result.SPEED.VERTICAL = result.SPEED_VERTICAL;
if (result.SPEED_VERTICAL != null)
result.SPEED.VERTICAL = result.SPEED_VERTICAL;
else result.SPEED.VERTICAL = distanceVert / time;
delete result.SPEED_VERTICAL;
if (result.SPEED_THREED != null) result.SPEED.THREED = result.SPEED_THREED;
if (result.SPEED_THREED != null)
result.SPEED.THREED = result.SPEED_THREED;
else result.SPEED.THREED = distance3D / time;

@@ -155,3 +192,4 @@ delete result.SPEED_THREED;

let statsObject = function(obj) {
if (obj.constructor === Object && Object.keys(obj).length === 0) return null;
if (obj.constructor === Object && Object.keys(obj).length === 0)
return null;
let result = {};

@@ -177,3 +215,9 @@ for (let elt in obj) {

if (a === b) return true;
if (a == null || typeof a != 'object' || b == null || typeof b != 'object') return false;
if (
a == null ||
typeof a != 'object' ||
b == null ||
typeof b != 'object'
)
return false;
var propsInA = 0,

@@ -216,3 +260,4 @@ propsInB = 0;

result[elt].avg =
select.reduce((acc, val) => (isNum(val) ? acc + val : acc), 0) / select.length;
select.reduce((acc, val) => (isNum(val) ? acc + val : acc), 0) /
select.length;
}

@@ -223,3 +268,4 @@ }

let result = statsObject(arr[0]);
if (result.constructor === Object && Object.keys(result).length === 0) return null;
if (result.constructor === Object && Object.keys(result).length === 0)
return null;
result = recursiveStatsExtraction(result, arr);

@@ -229,3 +275,4 @@ if (arr[arr.length - 1].DIFFTIME != undefined) {

} else if (arr[arr.length - 1].DATE != undefined) {
result.DURATION = new Date(arr[arr.length - 1].DATE) - new Date(arr[0].DATE); //duration of video in milliseconds
result.DURATION =
new Date(arr[arr.length - 1].DATE) - new Date(arr[0].DATE); //duration of video in milliseconds
}

@@ -286,3 +333,6 @@ if (arr[arr.length - 1].DISTANCE != null) {

}
if (interpretedI.constructor === Object && Object.keys(interpretedI).length === 0)
if (
interpretedI.constructor === Object &&
Object.keys(interpretedI).length === 0
)
return null;

@@ -294,3 +344,7 @@ return interpretedI;

if (old_key !== new_key) {
Object.defineProperty(o, new_key, Object.getOwnPropertyDescriptor(o, old_key));
Object.defineProperty(
o,
new_key,
Object.getOwnPropertyDescriptor(o, old_key)
);
delete o[old_key];

@@ -314,2 +368,13 @@ }

}
//Make up date with timecode if not present
if (!pckt['DATE'] && pckt['TIMECODE']) {
pckt['DATE'] = new Date(
new Date()
.toISOString()
.replace(/\d{2}:\d{2}:\d{2}.\d{3}Z/i, pckt['TIMECODE'])
.replace(/,/, '.')
).getTime();
}
let latitude = pckt['LATITUDE']; //Mavic 2 style

@@ -337,3 +402,7 @@ let longitude = pckt['LONGITUDE'] || pckt['LONGTITUDE'];

interpretedP = fillMissingFields(interpretedP);
if (interpretedP.constructor === Object && Object.keys(interpretedP).length === 0) return null;
if (
interpretedP.constructor === Object &&
Object.keys(interpretedP).length === 0
)
return null;
return interpretedP;

@@ -383,4 +452,6 @@ };

if (newArr[i].GPS) {
if (!isNum(newArr[i].GPS.LATITUDE)) newArr[i].GPS.LATITUDE = newArr[i - 1].GPS.LATITUDE;
if (!isNum(newArr[i].GPS.LONGITUDE)) newArr[i].GPS.LONGITUDE = newArr[i - 1].GPS.LONGITUDE;
if (!isNum(newArr[i].GPS.LATITUDE))
newArr[i].GPS.LATITUDE = newArr[i - 1].GPS.LATITUDE;
if (!isNum(newArr[i].GPS.LONGITUDE))
newArr[i].GPS.LONGITUDE = newArr[i - 1].GPS.LONGITUDE;
if (newArr[i].GPS.ALTITUDE && !isNum(newArr[i].GPS.ALTITUDE))

@@ -487,5 +558,8 @@ ewArr[i].GPS.ALTITUDE = newArr[i - 1].GPS.ALTITUDE;

if (raw) {
if (coordsObj.length >= 0 && coordsObj[0]) coordResult[0] = coordsObj[0];
if (coordsObj.length >= 1 && coordsObj[1]) coordResult[1] = coordsObj[1];
if (coordsObj.length >= 2 && coordsObj[2]) coordResult[2] = coordsObj[2];
if (coordsObj.length >= 0 && coordsObj[0])
coordResult[0] = coordsObj[0];
if (coordsObj.length >= 1 && coordsObj[1])
coordResult[1] = coordsObj[1];
if (coordsObj.length >= 2 && coordsObj[2])
coordResult[2] = coordsObj[2];
} else {

@@ -615,6 +689,3 @@ if (coordsObj.LONGITUDE) coordResult[0] = coordsObj.LONGITUDE;

};
this.flow(
decode(data),
preparedData
);
this.flow(decode(data), preparedData);
};

@@ -650,3 +721,6 @@

if (context.loaded) {
context.metadata = context.interpretMetadata(context.rawMetadata, smooth);
context.metadata = context.interpretMetadata(
context.rawMetadata,
smooth
);
} else {

@@ -666,3 +740,5 @@ notReady();

toMGJSON: function() {
return context.loaded ? context.createMGJSON(context.fileName) : notReady();
return context.loaded
? context.createMGJSON(context.fileName)
: notReady();
},

@@ -669,0 +745,0 @@ toGeoJSON: function(raw) {

{
"name": "dji_srt_parser",
"version": "1.0.45",
"version": "1.0.46",
"description": "Parses and interprets DJI's drones SRT metadata",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,3 @@ # DJI_SRT_Parser

- Used for creating this SRT log viewer in https://djitelemetryoverlay.com
- Example video using the data in After Effects: https://youtu.be/zAkUTOLmdmQ

@@ -10,0 +11,0 @@ ## Installation

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc