From 7a6567af88eba77c70173a00f36b31d166c32d22 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Sat, 14 Dec 2019 14:20:54 -0800 Subject: [PATCH] Distance reports now limited to 2 digits after the decimal point. --- src/main/lemondronor/circlebot.cljs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/lemondronor/circlebot.cljs b/src/main/lemondronor/circlebot.cljs index 54b587c..646b093 100644 --- a/src/main/lemondronor/circlebot.cljs +++ b/src/main/lemondronor/circlebot.cljs @@ -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))