forked from flightaware/dump1090
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearrange json DB stuff so it can work with CSV input.
- Loading branch information
1 parent
ca57fb2
commit 158a829
Showing
4 changed files
with
31,197 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
The dump1090 webmap uses a static database of json files to provide aircraft | ||
information. | ||
|
||
This directory has some tools to turn a CSV file with aircraft data into | ||
the json format that the dump1090 map expects. | ||
|
||
The default data comes from a database kindly provided by VRS (unfortunately | ||
no longer updated). This data is in vrs.csv. It was extracted by: | ||
|
||
$ wget http://www.virtualradarserver.co.uk/Files/BasicAircraftLookup.sqb.gz | ||
$ gunzip BasicAircraftLookup.sqb.gz | ||
$ tools/vrs-to-csv.py BasicAircraftLookup.sqb >tools/vrs.csv | ||
|
||
You can modify vrs.csv (or build a new CSV entirely) and update the database | ||
via: | ||
|
||
$ tools/csv-to-json.py tools/vrs.csv public_html/db | ||
|
||
The contents of public_html/db should be installed where the webmap can find | ||
them; the Debian packaging puts these in | ||
/usr/share/dump1090-mutability/html/db | ||
|
||
The CSV format is very simple. The first line must be a header line that names | ||
the columns. These columns are understood: | ||
|
||
icao24: the 6-digit hex address of the aircraft | ||
r: the registration / tail number of the aircraft | ||
t: the ICAO aircraft type of the aircraft, e.g. B773 | ||
|
||
Any other columns are put into the json DB under the name you give them, but | ||
the standard map code won't do anything special with them. You can pick these | ||
columns up in the PlaneObject constructor (see planeObject.js where it calls | ||
getAircraftData()) for later use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python2 | ||
|
||
# | ||
# Converts a Virtual Radar Server BasicAircraftLookup.sqb database | ||
# to a CSV file suitable for feeding to csv-to-json.py | ||
# | ||
|
||
import sqlite3, csv, sys | ||
from contextlib import closing | ||
|
||
def extract(dbfile): | ||
writer = csv.DictWriter(sys.stdout, | ||
fieldnames=['icao24', 'r', 't']) | ||
writer.writeheader() | ||
with closing(sqlite3.connect(dbfile)) as db: | ||
with closing(db.execute('SELECT a.Icao, a.Registration, m.Icao FROM Aircraft a, Model m WHERE a.ModelID = m.ModelID')) as c: | ||
for icao24, reg, icaotype in c: | ||
writer.writerow({ | ||
'icao24': icao24, | ||
'r': reg, | ||
't': icaotype | ||
}) | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) < 2: | ||
print >>sys.stderr, 'Reads a VRS sqlite database and writes a CSV to stdout' | ||
print >>sys.stderr, 'Syntax: %s <path to BasicAircraftLookup.sqb>' % sys.argv[0] | ||
sys.exit(1) | ||
else: | ||
extract(sys.argv[1]) | ||
sys.exit(0) |
Oops, something went wrong.