Compare commits
3 Commits
89261d0010
...
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| d55039f7cb | |||
| 7eeb251c6b | |||
| d290165899 |
@@ -1,5 +1,10 @@
|
|||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
### [v2.0.0](https://git.w33ble.com/w33ble/adsb-index/compare/v1.0.1...v2.0.0) (2 November 2018)
|
||||||
|
- feat: add ads-b exchange source [`9f0da54`](https://git.w33ble.com/w33ble/adsb-index/commit/9f0da54ccfc639ec6367ea85ec39bea117fd3108)
|
||||||
|
- feat: use ads-b exchange data [`89261d0`](https://git.w33ble.com/w33ble/adsb-index/commit/89261d0010315ad248dcfdcf25916d952de648d8)
|
||||||
|
- fix: correctly formatted ads-b exchange data [`d290165`](https://git.w33ble.com/w33ble/adsb-index/commit/d2901658990a5984ef69fc34f7372e3894a3ac74)
|
||||||
|
|
||||||
#### [v1.0.1](https://git.w33ble.com/w33ble/adsb-index/compare/v1.0.0...v1.0.1) (2 November 2018)
|
#### [v1.0.1](https://git.w33ble.com/w33ble/adsb-index/compare/v1.0.0...v1.0.1) (2 November 2018)
|
||||||
- fix: format api data correctly [`6def944`](https://git.w33ble.com/w33ble/adsb-index/commit/6def9449be415c50390a2eaa4fd124bd5fa548b6)
|
- fix: format api data correctly [`6def944`](https://git.w33ble.com/w33ble/adsb-index/commit/6def9449be415c50390a2eaa4fd124bd5fa548b6)
|
||||||
|
|
||||||
|
|||||||
13
bin/index.js
13
bin/index.js
@@ -1,7 +1,7 @@
|
|||||||
/* eslint no-global-assign: 0 no-console: 0 */
|
/* eslint no-global-assign: 0 no-console: 0 */
|
||||||
require = require('esm')(module);
|
require = require('esm')(module);
|
||||||
const getopts = require('getopts');
|
const getopts = require('getopts');
|
||||||
const cron = require('node-cron');
|
const runInterval = require('interval-promise');
|
||||||
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;
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ function handleError(err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAndIndex() {
|
async function fetchAndIndex() {
|
||||||
|
logger.debug('Fetching and indexing data...');
|
||||||
return mod(index, { elasticsearch, filter: { lat, lon, radius } });
|
return mod(index, { elasticsearch, filter: { lat, lon, radius } });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +39,10 @@ async function run() {
|
|||||||
// initial kickoff
|
// initial kickoff
|
||||||
await fetchAndIndex().catch(handleError);
|
await fetchAndIndex().catch(handleError);
|
||||||
|
|
||||||
if (interval === 0) return;
|
|
||||||
|
|
||||||
// scheduled running
|
// scheduled running
|
||||||
logger.debug(`Starting cron (${interval}s)...`);
|
if (interval === 0) return;
|
||||||
cron.schedule(`${interval} * * * * *`, () => {
|
logger.debug(`Starting interval (${interval}s)...`);
|
||||||
logger.debug('Running cron...');
|
runInterval(fetchAndIndex, interval * 1000);
|
||||||
fetchAndIndex();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch(handleError);
|
run().catch(handleError);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "adsb-index",
|
"name": "adsb-index",
|
||||||
"version": "1.0.1",
|
"version": "2.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "ADS-B indexing script",
|
"description": "ADS-B indexing script",
|
||||||
"bin": "bin/index.js",
|
"bin": "bin/index.js",
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
"elasticsearch": "^15.2.0",
|
"elasticsearch": "^15.2.0",
|
||||||
"esm": "^3.0.17",
|
"esm": "^3.0.17",
|
||||||
"getopts": "^2.2.2",
|
"getopts": "^2.2.2",
|
||||||
"node-cron": "^2.0.3"
|
"interval-promise": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@w33ble/npm-auto-tools": "*",
|
"@w33ble/npm-auto-tools": "*",
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export async function getOpenskyData() {
|
|||||||
|
|
||||||
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
export async function getAdbsExchangeData({ lat, lon, radius }) {
|
||||||
const positionSourceMap = ['Unknown', 'Mode-S', 'ADS-B', 'ADS-B', 'ADS-B', 'ADS-B'];
|
const positionSourceMap = ['Unknown', 'Mode-S', 'ADS-B', 'ADS-B', 'ADS-B', 'ADS-B'];
|
||||||
|
const formatNumber = str => str && Number(`${str}`.replace(/[^0-9.-]/, ''));
|
||||||
|
|
||||||
const res = await fetch.get(
|
const res = await fetch.get(
|
||||||
`http://public-api.adsbexchange.com/VirtualRadar/AircraftList.json?lat=${lat}&lng=${lon}&fDstL=0&fDstU=${radius}`
|
`http://public-api.adsbexchange.com/VirtualRadar/AircraftList.json?lat=${lat}&lng=${lon}&fDstL=0&fDstU=${radius}`
|
||||||
);
|
);
|
||||||
@@ -38,11 +40,11 @@ export async function getAdbsExchangeData({ lat, lon, radius }) {
|
|||||||
location: rec.Lat && rec.Long ? `${rec.Lat},${rec.Long}` : null,
|
location: rec.Lat && rec.Long ? `${rec.Lat},${rec.Long}` : null,
|
||||||
lat: rec.Lat,
|
lat: rec.Lat,
|
||||||
lon: rec.Long,
|
lon: rec.Long,
|
||||||
baro_altitude: rec.Alt,
|
baro_altitude: formatNumber(rec.Alt),
|
||||||
geo_altitude: rec.Galt,
|
geo_altitude: formatNumber(rec.GAlt),
|
||||||
on_ground: rec.Gnd,
|
on_ground: rec.Gnd,
|
||||||
velocity: rec.Spd,
|
velocity: formatNumber(rec.Spd),
|
||||||
vertical_rate: rec.Vsi,
|
vertical_rate: formatNumber(rec.Vsi),
|
||||||
squawk: rec.Sqk,
|
squawk: rec.Sqk,
|
||||||
spi: false,
|
spi: false,
|
||||||
position_source: positionSourceMap[rec.Trt],
|
position_source: positionSourceMap[rec.Trt],
|
||||||
|
|||||||
23
yarn.lock
23
yarn.lock
@@ -1245,6 +1245,11 @@ inquirer@^3.0.6:
|
|||||||
strip-ansi "^4.0.0"
|
strip-ansi "^4.0.0"
|
||||||
through "^2.3.6"
|
through "^2.3.6"
|
||||||
|
|
||||||
|
interval-promise@^1.3.0:
|
||||||
|
version "1.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/interval-promise/-/interval-promise-1.3.0.tgz#26fc4fbcd18605162d0dd012c2cc5657c4f8bc22"
|
||||||
|
integrity sha512-AebPZJ0o6D1jWg487njjrhfzBp6/hfmtWCMQhXr0SXD7Zg5RexQe4Y6joYiGieJziP7W7WEMQWxFKSbywXmhbw==
|
||||||
|
|
||||||
is-accessor-descriptor@^0.1.6:
|
is-accessor-descriptor@^0.1.6:
|
||||||
version "0.1.6"
|
version "0.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
|
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
|
||||||
@@ -1826,14 +1831,6 @@ nice-try@^1.0.4:
|
|||||||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
|
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
|
||||||
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
|
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
|
||||||
|
|
||||||
node-cron@^2.0.3:
|
|
||||||
version "2.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-cron/-/node-cron-2.0.3.tgz#b9649784d0d6c00758410eef22fa54a10e3f602d"
|
|
||||||
integrity sha512-eJI+QitXlwcgiZwNNSRbqsjeZMp5shyajMR81RZCqeW0ZDEj4zU9tpd4nTh/1JsBiKbF8d08FCewiipDmVIYjg==
|
|
||||||
dependencies:
|
|
||||||
opencollective-postinstall "^2.0.0"
|
|
||||||
tz-offset "0.0.1"
|
|
||||||
|
|
||||||
node-fetch@^2.1.2, node-fetch@^2.2.0:
|
node-fetch@^2.1.2, node-fetch@^2.2.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5"
|
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5"
|
||||||
@@ -1934,11 +1931,6 @@ onetime@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mimic-fn "^1.0.0"
|
mimic-fn "^1.0.0"
|
||||||
|
|
||||||
opencollective-postinstall@^2.0.0:
|
|
||||||
version "2.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.1.tgz#798e83e168f7b91949061c2683f762af747f17cc"
|
|
||||||
integrity sha512-saQQ9hjLwu/oS0492eyYotoh+bra1819cfAT5rjY/e4REWwuc8IgZ844Oo44SiftWcJuBiqp0SA0BFVbmLX0IQ==
|
|
||||||
|
|
||||||
optimist@^0.6.1:
|
optimist@^0.6.1:
|
||||||
version "0.6.1"
|
version "0.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
|
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
|
||||||
@@ -2629,11 +2621,6 @@ typedarray@^0.0.6:
|
|||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||||
|
|
||||||
tz-offset@0.0.1:
|
|
||||||
version "0.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/tz-offset/-/tz-offset-0.0.1.tgz#fef920257024d3583ed9072a767721a18bdb8a76"
|
|
||||||
integrity sha512-kMBmblijHJXyOpKzgDhKx9INYU4u4E1RPMB0HqmKSgWG8vEcf3exEfLh4FFfzd3xdQOw9EuIy/cP0akY6rHopQ==
|
|
||||||
|
|
||||||
uglify-js@^3.1.4:
|
uglify-js@^3.1.4:
|
||||||
version "3.4.9"
|
version "3.4.9"
|
||||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
|
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
|
||||||
|
|||||||
Reference in New Issue
Block a user