Fixed landmark distance units.

This commit is contained in:
John Wiseman 2019-12-14 14:01:16 -08:00
parent 7a5139d449
commit 9f859ee204

View File

@ -288,6 +288,9 @@
(first results))) (first results)))
(defn km->miles [km]
(* km 0.621371))
(defn generate-description [ac reverse wiki-nearby nearby] (defn generate-description [ac reverse wiki-nearby nearby]
(let [rev-props (:properties reverse) (let [rev-props (:properties reverse)
nearby (:properties (first nearby)) nearby (:properties (first nearby))
@ -298,10 +301,10 @@
:militaryicao (:icao ac))) :militaryicao (:icao ac)))
wiki-nearby wiki-nearby
(assoc :nearbylandmark (:name wiki-nearby) (assoc :nearbylandmark (:name wiki-nearby)
:nearbydistance (:distance wiki-nearby)) :nearbydistance (-> wiki-nearby :distance km->miles))
(and nearby (not wiki-nearby)) (and nearby (not wiki-nearby))
(assoc :nearbylandmark (:name nearby) (assoc :nearbylandmark (:name nearby)
:nearbydistance (:distance nearby)) :nearbydistance (-> nearby :distance km->miles))
(:speed ac) (:speed ac)
(assoc :speed (.toFixed (* (:speed ac) 1.15078) 0)) (assoc :speed (.toFixed (* (:speed ac) 1.15078) 0))
(= (:registration ac) (:callsign ac)) (= (:registration ac) (:callsign ac))
@ -332,7 +335,7 @@
airport-properties (:properties airport)] airport-properties (:properties airport)]
(log-info "%s: Recent centroid is %s %s" icao lat lon) (log-info "%s: Recent centroid is %s %s" icao lat lon)
(if airport (if airport
(log-info "%s: Closest airport is %s, distance: %s" (log-info "%s: Closest airport is %s, distance: %s km"
(:icao ac) (:label airport-properties) (:distance airport-properties)) (:icao ac) (:label airport-properties) (:distance airport-properties))
(log-info "%s: No airports nearby" (:icao ac))) (log-info "%s: No airports nearby" (:icao ac)))
(if (and airport-properties (<= (:distance airport-properties) minimum-airport-distance-km)) (if (and airport-properties (<= (:distance airport-properties) minimum-airport-distance-km))