Add filtering of icao type descriptions / wtc based on descriptor.
This commit is contained in:
parent
d1790cd411
commit
69031408f3
|
@ -18,17 +18,41 @@
|
||||||
// nodejs filter-regs.js <input.csv >output.csv
|
// nodejs filter-regs.js <input.csv >output.csv
|
||||||
|
|
||||||
var reglookup = require('../public_html/registrations.js');
|
var reglookup = require('../public_html/registrations.js');
|
||||||
|
var actypes = require('../public_html/db/aircraft_types/icao_aircraft_types.json');
|
||||||
var csv = require('csv');
|
var csv = require('csv');
|
||||||
|
|
||||||
var parser = csv.parse({columns: true});
|
var parser = csv.parse({columns: true});
|
||||||
var writer = csv.stringify({header: true});
|
var writer = csv.stringify({header: true});
|
||||||
var transformer = csv.transform(function (record, callback) {
|
var transformer = csv.transform(function (record, callback) {
|
||||||
if (('icao24' in record) && ('r' in record)) {
|
if ('icao24' in record) {
|
||||||
|
if ('r' in record && record.r != '') {
|
||||||
var computed = reglookup(record.icao24);
|
var computed = reglookup(record.icao24);
|
||||||
if (computed === record.r) {
|
if (computed === record.r) {
|
||||||
record.r = '';
|
record.r = '';
|
||||||
} else if (computed !== null) {
|
} else if (computed !== null) {
|
||||||
console.warn(record.icao24 + " computed " + computed + " but CSV data had " + record.r);
|
console.warn(record.icao24 + " computed registration " + computed + " but CSV data had " + record.r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('t' in record && record.t in actypes) {
|
||||||
|
if ('desc' in record && record.desc != '') {
|
||||||
|
var computed_desc = actypes[record.t].desc;
|
||||||
|
if (computed_desc === record.desc) {
|
||||||
|
record.desc = '';
|
||||||
|
} else if (computed_desc !== undefined) {
|
||||||
|
// too noisy, the icao descriptors are very coarse and reality often disagrees
|
||||||
|
//console.warn(record.icao24 + " (" + record.t + "): computed type description " + computed_desc + " but CSV data had " + record.desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('wtc' in record && record.wtc != '') {
|
||||||
|
var computed_wtc = actypes[record.t].wtc;
|
||||||
|
if (computed_wtc === record.wtc) {
|
||||||
|
record.wtc = '';
|
||||||
|
} else if (computed_desc !== undefined) {
|
||||||
|
//console.warn(record.icao24 + " (" + record.t + "): computed type WTC " + computed_wtc + " but CSV data had " + record.wtc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue