Distance reports now limited to 2 digits after the decimal point.

This commit is contained in:
John Wiseman 2019-12-14 14:20:54 -08:00
parent 9f859ee204
commit 7a6567af88

View File

@ -291,6 +291,9 @@
(defn km->miles [km]
(* km 0.621371))
(defn to-fixed [n d]
(.toFixed n d))
(defn generate-description [ac reverse wiki-nearby nearby]
(let [rev-props (:properties reverse)
nearby (:properties (first nearby))
@ -301,10 +304,10 @@
:militaryicao (:icao ac)))
wiki-nearby
(assoc :nearbylandmark (:name wiki-nearby)
:nearbydistance (-> wiki-nearby :distance km->miles))
:nearbydistance (-> wiki-nearby :distance km->miles (to-fixed 2)))
(and nearby (not wiki-nearby))
(assoc :nearbylandmark (:name nearby)
:nearbydistance (-> nearby :distance km->miles))
:nearbydistance (-> nearby :distance km->miles (to-fixed 2)))
(:speed ac)
(assoc :speed (.toFixed (* (:speed ac) 1.15078) 0))
(= (:registration ac) (:callsign ac))