feat: use ads-b exchange data
This commit is contained in:
@@ -5,7 +5,7 @@ const cron = require('node-cron');
|
|||||||
const mod = require('../src/index.mjs').default;
|
const mod = require('../src/index.mjs').default;
|
||||||
const logger = require('../src/lib/logger.mjs').default;
|
const logger = require('../src/lib/logger.mjs').default;
|
||||||
|
|
||||||
const { index, interval, ...elasticsearch } = getopts(process.argv.slice(2), {
|
const { index, interval, lat, lon, radius, ...elasticsearch } = getopts(process.argv.slice(2), {
|
||||||
string: ['host', 'auth', 'log', 'index'],
|
string: ['host', 'auth', 'log', 'index'],
|
||||||
alias: {
|
alias: {
|
||||||
h: 'host',
|
h: 'host',
|
||||||
@@ -19,6 +19,9 @@ const { index, interval, ...elasticsearch } = getopts(process.argv.slice(2), {
|
|||||||
log: 'error',
|
log: 'error',
|
||||||
index: 'adsb-data',
|
index: 'adsb-data',
|
||||||
interval: 0,
|
interval: 0,
|
||||||
|
lat: 33.433638,
|
||||||
|
lon: -112.008113,
|
||||||
|
radius: 1000,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ function handleError(err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAndIndex() {
|
async function fetchAndIndex() {
|
||||||
return mod(index, { elasticsearch });
|
return mod(index, { elasticsearch, filter: { lat, lon, radius } });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import elasticsearch from 'elasticsearch';
|
import elasticsearch from 'elasticsearch';
|
||||||
import logger from './lib/logger.mjs';
|
import logger from './lib/logger.mjs';
|
||||||
import { createIndex, bulkInsert } from './lib/data-source.mjs';
|
import { createIndex, bulkInsert } from './lib/data-source.mjs';
|
||||||
import { getOpenskyData } from './lib/get-data.mjs';
|
import { getAdbsExchangeData } from './lib/get-data.mjs';
|
||||||
|
|
||||||
|
|
||||||
export default async function(indexName, opts = {}) {
|
export default async function(indexName, opts = {}) {
|
||||||
const client = new elasticsearch.Client({
|
const client = new elasticsearch.Client({
|
||||||
@@ -17,7 +16,7 @@ export default async function(indexName, opts = {}) {
|
|||||||
// create the target index
|
// create the target index
|
||||||
const index = await createIndex(client, indexName);
|
const index = await createIndex(client, indexName);
|
||||||
|
|
||||||
const records = await getOpenskyData();
|
const records = await getAdbsExchangeData(opts.filter);
|
||||||
logger.debug(`Record count:, ${records.length}`);
|
logger.debug(`Record count:, ${records.length}`);
|
||||||
|
|
||||||
await bulkInsert(client, index, records);
|
await bulkInsert(client, index, records);
|
||||||
|
|||||||
Reference in New Issue
Block a user