freeboard-sk-helper
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "freeboard-sk-helper", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Freeboard-SK helper plugin for SignalK Server.", | ||
@@ -5,0 +5,0 @@ "main": "plugin/index.js", |
@@ -79,14 +79,24 @@ "use strict"; | ||
let fc = JSON.parse(fs_1.default.readFileSync(p, 'utf8')); | ||
if (params.section) { // return section | ||
if (Array.isArray(params.section)) { | ||
params.section.forEach((i) => { | ||
let sno = parseInt(i); | ||
if (sno < fc.length) { | ||
result.push(fc[sno]); | ||
} | ||
}); | ||
if (this.validateTrack(fc)) { | ||
if (params.section) { // return section | ||
if (Array.isArray(params.section)) { | ||
params.section.forEach((i) => { | ||
let sno = parseInt(i); | ||
if (sno < fc.length) { | ||
result.push(fc[sno]); | ||
} | ||
}); | ||
} | ||
} | ||
else { | ||
result = fc; | ||
} | ||
} | ||
else { | ||
result = fc; | ||
console.log('** ERROR **', `Invalid file contents!`); | ||
result = { | ||
message: `Invalid file contents!`, | ||
status: 400, | ||
error: true | ||
}; | ||
} | ||
@@ -115,6 +125,8 @@ return result; | ||
let res = JSON.parse(fs_1.default.readFileSync(path_1.default.join(rt[1].path, files[f]), 'utf8')); | ||
result[uuid] = res; | ||
let stats = fs_1.default.statSync(path_1.default.join(rt[1].path, files[f])); | ||
result[uuid]['timestamp'] = stats.mtime; | ||
result[uuid]['$source'] = this.pkg.id; | ||
if (this.validateTrack(res)) { | ||
result[uuid] = res; | ||
let stats = fs_1.default.statSync(path_1.default.join(rt[1].path, files[f])); | ||
result[uuid]['timestamp'] = stats.mtime; | ||
result[uuid]['$source'] = this.pkg.id; | ||
} | ||
} | ||
@@ -227,5 +239,45 @@ catch (err) { | ||
try { | ||
if (!trk.feature) { //|| !geoJSON.valid(trk.feature)) { | ||
if (!trk.feature) { | ||
return false; | ||
} | ||
let f = trk.feature; | ||
if (typeof f.type === 'undefined') { | ||
return false; | ||
} | ||
if (f.type != 'Feature') { | ||
return false; | ||
} | ||
if (!f.geometry) { | ||
return false; | ||
} | ||
if (!f.geometry.type) { | ||
return false; | ||
} | ||
if (f.geometry.type != 'MultiLineString') { | ||
return false; | ||
} | ||
if (!f.geometry.coordinates) { | ||
return false; | ||
} | ||
if (!Array.isArray(f.geometry.coordinates)) { | ||
return false; | ||
} | ||
let coordsCheck = true; | ||
f.geometry.coordinates.forEach((l) => { | ||
if (!Array.isArray(l)) { | ||
coordsCheck = coordsCheck && false; | ||
} | ||
l.forEach((p) => { | ||
if (!Array.isArray(p)) { | ||
coordsCheck = coordsCheck && false; | ||
} | ||
if (p.length < 2) { | ||
coordsCheck = coordsCheck && false; | ||
} | ||
if (typeof p[0] !== 'number' || typeof p[1] !== 'number') { | ||
coordsCheck = coordsCheck && false; | ||
} | ||
}); | ||
}); | ||
return coordsCheck; | ||
} | ||
@@ -236,5 +288,7 @@ catch (e) { | ||
} | ||
return true; | ||
finally { | ||
console.log('** TRACK VALIDATE COMPLETE **'); | ||
} | ||
} | ||
} | ||
exports.TrackStore = TrackStore; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
62039
1095
0