mirror of
https://github.com/bistromath/gr-air-modes.git
synced 2026-03-13 04:26:48 +01:00
Merge branch 'master' into qtapp
This commit is contained in:
@@ -73,7 +73,7 @@ class output_kml(threading.Thread):
|
||||
bearing = i*(2*math.pi/steps) #in radians
|
||||
lat_out = math.degrees(math.asin(math.sin(lat_rad)*math.cos(tmp0) + math.cos(lat_rad)*math.sin(tmp0)*math.cos(bearing)))
|
||||
lon_out = center_lon + math.degrees(math.atan2(math.sin(bearing)*math.sin(tmp0)*math.cos(lat_rad), math.cos(tmp0)-math.sin(lat_rad)*math.sin(math.radians(lat_out))))
|
||||
retstr += " %.8f, %.8f, 0" % (lon_out, lat_out,)
|
||||
retstr += " %.8f,%.8f, 0" % (lon_out, lat_out,)
|
||||
|
||||
retstr = string.lstrip(retstr)
|
||||
return retstr
|
||||
@@ -150,7 +150,7 @@ class output_kml(threading.Thread):
|
||||
heading = 0
|
||||
vertical = 0
|
||||
#now generate some KML
|
||||
retstr+= "\n\t\t<Placemark>\n\t\t\t<name>%s</name>\n\t\t\t<styleUrl>#airplane</styleUrl>\n\t\t\t<description>\n\t\t\t\t<![CDATA[Altitude: %s<br/>Heading: %i<br/>Speed: %i<br/>Vertical speed: %i<br/>ICAO: %x<br/>Last seen: %s]]>\n\t\t\t</description>\n\t\t\t<Point>\n\t\t\t\t<altitudeMode>absolute</altitudeMode>\n\t\t\t\t<extrude>1</extrude>\n\t\t\t\t<coordinates>%s,%s,%i</coordinates>\n\t\t\t</Point>\n\t\t</Placemark>" % (ident, alt, heading, speed, vertical, icao[0], seen, lon, lat, metric_alt, )
|
||||
retstr+= "\n\t\t<Placemark>\n\t\t\t<name>%s</name>\n\t\t\t<Style><IconStyle><heading>%i</heading></IconStyle></Style>\n\t\t\t<styleUrl>#airplane</styleUrl>\n\t\t\t<description>\n\t\t\t\t<![CDATA[Altitude: %s<br/>Heading: %i<br/>Speed: %i<br/>Vertical speed: %i<br/>ICAO: %x<br/>Last seen: %s]]>\n\t\t\t</description>\n\t\t\t<Point>\n\t\t\t\t<altitudeMode>absolute</altitudeMode>\n\t\t\t\t<extrude>1</extrude>\n\t\t\t\t<coordinates>%s,%s,%i</coordinates>\n\t\t\t</Point>\n\t\t</Placemark>" % (ident, heading, alt, heading, speed, vertical, icao[0], seen, lon, lat, metric_alt, )
|
||||
|
||||
retstr+= "\n\t\t<Placemark>\n\t\t\t<styleUrl>#track</styleUrl>\n\t\t\t<LineString>\n\t\t\t\t<extrude>0</extrude>\n\t\t\t\t<altitudeMode>absolute</altitudeMode>\n\t\t\t\t<coordinates>%s</coordinates>\n\t\t\t</LineString>\n\t\t</Placemark>" % (trackstr,)
|
||||
|
||||
|
||||
@@ -36,11 +36,10 @@ class output_print(air_modes.parse):
|
||||
reference = float(reference)
|
||||
timestamp = float(timestamp)
|
||||
|
||||
#TODO this is suspect
|
||||
if reference == 0.0:
|
||||
refdb = -150.0
|
||||
else:
|
||||
refdb = 10.0*math.log10(reference)
|
||||
refdb = 20.0*math.log10(reference)
|
||||
output = "(%.0f %.10f) " % (refdb, timestamp);
|
||||
|
||||
try:
|
||||
@@ -161,10 +160,18 @@ class output_print(air_modes.parse):
|
||||
|
||||
elif bdsreg == 0x09:
|
||||
subtype = data["bds09"].get_type()
|
||||
if subtype == 0 or subtype == 1:
|
||||
parser = self.parseBDS09_0 if subtype == 0 else self.parseBDS09_1
|
||||
[velocity, heading, vert_spd] = parser(data)
|
||||
if subtype == 0:
|
||||
[velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
||||
retstr = "Type 17 BDS0,9-%i (track report) from %x with velocity %.0fkt heading %.0f VS %.0f turn rate %.0f" \
|
||||
% (subtype, icao24, velocity, heading, vert_spd, turnrate)
|
||||
elif subtype == 1:
|
||||
[velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||
retstr = "Type 17 BDS0,9-%i (track report) from %x with velocity %.0fkt heading %.0f VS %.0f" % (subtype, icao24, velocity, heading, vert_spd)
|
||||
elif subtype == 3:
|
||||
[mag_hdg, vel_src, vel, vert_spd, geo_diff] = self.parseBDS09_3(data)
|
||||
retstr = "Type 17 BDS0,9-%i (air course report) from %x with %s %.0fkt magnetic heading %.0f VS %.0f geo. diff. from baro. alt. %.0fft" \
|
||||
% (subtype, icao24, vel_src, vel, mag_hdg, vert_spd, geo_diff)
|
||||
|
||||
else:
|
||||
retstr = "Type 17 BDS0,9-%i from %x not implemented" % (subtype, icao24)
|
||||
|
||||
|
||||
@@ -345,6 +345,21 @@ class parse:
|
||||
|
||||
return [velocity, heading, vert_spd]
|
||||
|
||||
def parseBDS09_3(self, data):
|
||||
#3: {"sub", "icf", "ifr", "nuc", "mhs", "hdg", "ast", "spd", "vrsrc",
|
||||
# "dvr", "vr", "dhd", "hd"}
|
||||
mag_hdg = data["mhs"] * 360. / 1024
|
||||
vel_src = "TAS" if data["ast"] == 1 else "IAS"
|
||||
vel = data["spd"]
|
||||
if data["sub"] == 4:
|
||||
vel *= 4
|
||||
vert_spd = float(data["vr"] - 1) * 64
|
||||
if data["dvr"] == 1:
|
||||
vert_spd = 0 - vert_spd
|
||||
geo_diff = float(data["hd"] - 1) * 25
|
||||
return [mag_hdg, vel_src, vel, vert_spd, geo_diff]
|
||||
|
||||
|
||||
def parseBDS62(self, data):
|
||||
eps_strings = ["NO EMERGENCY", "GENERAL EMERGENCY", "LIFEGUARD/MEDICAL", "FUEL EMERGENCY",
|
||||
"NO COMMUNICATIONS", "UNLAWFUL INTERFERENCE", "RESERVED", "RESERVED"]
|
||||
|
||||
@@ -146,7 +146,7 @@ class output_sbs1(air_modes.parse):
|
||||
def pp5(self, shortdata, ecc):
|
||||
# I'm not sure what to do with the identiifcation shortdata & 0x1FFF
|
||||
[datestr, timestr] = self.current_time()
|
||||
[fs, dr, um] = self.parse5(shortdata)
|
||||
[fs, dr, um, ident] = self.parse5(shortdata)
|
||||
aircraft_id = self.get_aircraft_id(ecc)
|
||||
retstr = "MSG,6,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr)
|
||||
return retstr + self.decode_fs(fs) + "\n"
|
||||
|
||||
@@ -125,9 +125,13 @@ class output_sql(air_modes.parse):
|
||||
|
||||
elif bdsreg == 0x09:
|
||||
subtype = data["bds09"].get_type()
|
||||
if subtype == 0 or subtype == 1:
|
||||
parser = self.parseBDS09_0 if subtype == 0 else self.parseBDS09_1
|
||||
[velocity, heading, vert_spd] = parser(data)
|
||||
if subtype == 0:
|
||||
[velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
||||
retstr = "INSERT INTO vectors (icao, seen, speed, heading, vertical) VALUES (" + "%i" % icao24 + ", datetime('now'), " + "%.0f" % velocity + ", " + "%.0f" % heading + ", " + "%.0f" % vert_spd + ")"
|
||||
|
||||
elif subtype == 1:
|
||||
[velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||
retstr = "INSERT INTO vectors (icao, seen, speed, heading, vertical) VALUES (" + "%i" % icao24 + ", datetime('now'), " + "%.0f" % velocity + ", " + "%.0f" % heading + ", " + "%.0f" % vert_spd + ")"
|
||||
else:
|
||||
retstr = None
|
||||
|
||||
return retstr
|
||||
|
||||
Reference in New Issue
Block a user